Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

[Temp] Backport r21402 from the bleeding_edge branch. #22

Merged
merged 1 commit into from
May 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/promises-aplus/testcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import shutil
import sys
import tarfile
import urllib

from testrunner.local import testsuite
from testrunner.local import utils
from testrunner.objects import testcase


Expand Down Expand Up @@ -102,7 +102,7 @@ def DownloadTestData(self):
directory = os.path.join(self.root, TEST_NAME)
if not os.path.exists(archive):
print('Downloading {0} from {1} ...'.format(TEST_NAME, TEST_URL))
urllib.urlretrieve(TEST_URL, archive)
utils.URLRetrieve(TEST_URL, archive)
if os.path.exists(directory):
shutil.rmtree(directory)

Expand All @@ -129,7 +129,7 @@ def DownloadSinon(self):
os.mkdir(directory)
path = os.path.join(directory, SINON_FILENAME)
if not os.path.exists(path):
urllib.urlretrieve(SINON_URL, path)
utils.URLRetrieve(SINON_URL, path)
hash = hashlib.sha256()
with open(path, 'rb') as f:
for chunk in iter(lambda: f.read(8192), ''):
Expand Down
4 changes: 2 additions & 2 deletions test/test262/testcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import shutil
import sys
import tarfile
import urllib

from testrunner.local import testsuite
from testrunner.local import utils
from testrunner.objects import testcase


Expand Down Expand Up @@ -97,7 +97,7 @@ def DownloadData(self):
directory_old_name = os.path.join(self.root, "data.old")
if not os.path.exists(archive_name):
print "Downloading test data from %s ..." % archive_url
urllib.urlretrieve(archive_url, archive_name)
utils.URLRetrieve(archive_url, archive_name)
if os.path.exists(directory_name):
if os.path.exists(directory_old_name):
shutil.rmtree(directory_old_name)
Expand Down
8 changes: 8 additions & 0 deletions tools/testrunner/local/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from os.path import join
import platform
import re
import urllib2


def GetSuitePaths(test_root):
Expand Down Expand Up @@ -113,3 +114,10 @@ def GuessWordsize():

def IsWindows():
return GuessOS() == 'windows'


def URLRetrieve(source, destination):
"""urllib is broken for SSL connections via a proxy therefore we
can't use urllib.urlretrieve()."""
with open(destination, 'w') as f:
f.write(urllib2.urlopen(source).read())