Reviewers: Yang,

Description:
Implement --download-data for test harness.

This allows the test harness to download missing test suite data if
necessary. We use the bzip2 archive for test262 because it is faster
than cloning the repository and also works without any Mercurial
installation.

[email protected]


Please review this at https://chromiumcodereview.appspot.com/9619002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M test/test262/testcfg.py
  M tools/test-wrapper-gypbuild.py
  M tools/test.py


Index: test/test262/testcfg.py
diff --git a/test/test262/testcfg.py b/test/test262/testcfg.py
index aefda196a307db7677702cab6075c99d0cf65a3f..65d756b6274948d1ac3148487fb47f236e63c0e1 100644
--- a/test/test262/testcfg.py
+++ b/test/test262/testcfg.py
@@ -29,8 +29,14 @@
 import test
 import os
 from os.path import join, exists
+import urllib
+import hashlib
+import tarfile


+TEST_262_ARCHIVE_REVISION = '3a890174343c'  # This is the r309 revision.
+TEST_262_ARCHIVE_MD5 = 'be5d4cfbe69cef70430907b8f3a92b50'
+TEST_262_URL = 'http://hg.ecmascript.org/tests/test262/archive/%s.tar.bz2'
 TEST_262_HARNESS = ['sta.js']


@@ -93,6 +99,28 @@ class Test262TestConfiguration(test.TestConfiguration):
             tests.append(test)
     return tests

+  def DownloadData(self):
+    revision = TEST_262_ARCHIVE_REVISION
+    archive_url = TEST_262_URL % revision
+    archive_name = join(self.root, 'test262-%s.tar.bz2' % revision)
+    directory_name = join(self.root, "test262-%s" % revision)
+    if not exists(directory_name) or not exists(archive_name):
+      if not exists(archive_name):
+        print "Downloading test data from %s ..." % archive_url
+        urllib.urlretrieve(archive_url, archive_name)
+      if not exists(directory_name):
+        print "Extracting test262-%s.tar.bz2 ..." % revision
+        md5 = hashlib.md5()
+        with open(archive_name,'rb') as f:
+          for chunk in iter(lambda: f.read(8192), ''):
+            md5.update(chunk)
+        if md5.hexdigest() != TEST_262_ARCHIVE_MD5:
+          raise Exception("Hash mismatch of test data file")
+        archive = tarfile.open(archive_name, 'r:bz2')
+        archive.extractall(join(self.root))
+      if not exists(join(self.root, 'data')):
+        os.symlink(directory_name, join(self.root, 'data'))
+
   def GetBuildRequirements(self):
     return ['d8']

@@ -101,6 +129,5 @@ class Test262TestConfiguration(test.TestConfiguration):
     if exists(status_file):
       test.ReadConfigurationInto(status_file, sections, defs)

-
 def GetConfiguration(context, root):
   return Test262TestConfiguration(context, root)
Index: tools/test-wrapper-gypbuild.py
diff --git a/tools/test-wrapper-gypbuild.py b/tools/test-wrapper-gypbuild.py
index e9984d76c1f0b1f711a7a0c609156f8f4a8fec38..991ac25eeebfd262473dc97e8824ba782dd88d95 100755
--- a/tools/test-wrapper-gypbuild.py
+++ b/tools/test-wrapper-gypbuild.py
@@ -73,6 +73,8 @@ def BuildOptions():
       choices=PROGRESS_INDICATORS, default="mono")
result.add_option("--report", help="Print a summary of the tests to be run",
       default=False, action="store_true")
+ result.add_option("--download-data", help="Download missing test suite dara",
+      default=False, action="store_true")
   result.add_option("-s", "--suite", help="A test suite",
       default=[], action="append")
   result.add_option("-t", "--timeout", help="Timeout in seconds",
@@ -161,6 +163,8 @@ def PassOnOptions(options):
     result += ['--progress=' + options.progress]
   if options.report:
     result += ['--report']
+  if options.download_data:
+    result += ['--download-data']
   if options.suite != []:
     for suite in options.suite:
       result += ['--suite=../../test/' + suite]
Index: tools/test.py
diff --git a/tools/test.py b/tools/test.py
index 3a6f55bc26117d704e5b9855c6fed16882af7735..8746106035ddfdab0d15a6832dc7155e14952ad9 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -631,9 +631,15 @@ class TestRepository(TestSuite):
   def GetBuildRequirements(self, path, context):
     return self.GetConfiguration(context).GetBuildRequirements()

+  def DownloadData(self, context):
+    config = self.GetConfiguration(context)
+    if 'DownloadData' in dir(config):
+      config.DownloadData()
+
   def AddTestsToList(self, result, current_path, path, context, mode):
-    for v in self.GetConfiguration(context).VariantFlags():
- tests = self.GetConfiguration(context).ListTests(current_path, path, mode, v)
+    config = self.GetConfiguration(context)
+    for v in config.VariantFlags():
+      tests = config.ListTests(current_path, path, mode, v)
       for t in tests: t.variant_flags = v
       result += tests

@@ -655,6 +661,12 @@ class LiteralTestSuite(TestSuite):
         result += test.GetBuildRequirements(rest, context)
     return result

+  def DownloadData(self, path, context):
+    (name, rest) = CarCdr(path)
+    for test in self.tests:
+      if not name or name.match(test.GetName()):
+        test.DownloadData(context)
+
   def ListTests(self, current_path, path, context, mode, variant_flags):
     (name, rest) = CarCdr(path)
     result = [ ]
@@ -1192,6 +1204,8 @@ def BuildOptions():
       default='scons')
result.add_option("--report", help="Print a summary of the tests to be run",
       default=False, action="store_true")
+ result.add_option("--download-data", help="Download missing test suite dara",
+      default=False, action="store_true")
   result.add_option("-s", "--suite", help="A test suite",
       default=[], action="append")
   result.add_option("-t", "--timeout", help="Timeout in seconds",
@@ -1462,6 +1476,11 @@ def Main():
   root.GetTestStatus(context, sections, defs)
   config = Configuration(sections, defs)

+  # Download missing test suite data if requested.
+  if options.download_data:
+    for path in paths:
+      root.DownloadData(path, context)
+
   # List the tests
   all_cases = [ ]
   all_unused = [ ]


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to