Пример #1
0
    def DownloadTestData(self):
        archive = os.path.join(self.root, TEST_ARCHIVE)
        directory = os.path.join(self.root, TEST_NAME)
        if not os.path.exists(archive):
            print('Downloading {0} from {1} ...'.format(TEST_NAME, TEST_URL))
            utils.URLRetrieve(TEST_URL, archive)
            if os.path.exists(directory):
                shutil.rmtree(directory)

        if not os.path.exists(directory):
            print('Extracting {0} ...'.format(TEST_ARCHIVE))
            hash = hashlib.sha256()
            with open(archive, 'rb') as f:
                for chunk in iter(lambda: f.read(8192), ''):
                    hash.update(chunk)
                if hash.hexdigest() != TEST_ARCHIVE_HASH:
                    os.remove(archive)
                    raise Exception('Hash mismatch of test data file')
            archive = tarfile.open(archive, 'r:gz')
            if sys.platform in ('win32', 'cygwin'):
                # Magic incantation to allow longer path names on Windows.
                archive.extractall(u'\\\\?\\%s' % self.root)
            else:
                archive.extractall(self.root)
            shutil.move(os.path.join(self.root, TEST_ARCHIVE_TOP), directory)
Пример #2
0
 def DownloadData(self):
   revision = TEST_262_ARCHIVE_REVISION
   archive_url = TEST_262_URL % revision
   archive_name = os.path.join(self.root, "tc39-test262-%s.tar.gz" % revision)
   directory_name = os.path.join(self.root, "data")
   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
     utils.URLRetrieve(archive_url, archive_name)
     if os.path.exists(directory_name):
       if os.path.exists(directory_old_name):
         shutil.rmtree(directory_old_name)
       os.rename(directory_name, directory_old_name)
   if not os.path.exists(directory_name):
     print "Extracting test262-%s.tar.gz ..." % revision
     md5 = hashlib.md5()
     with open(archive_name, "rb") as f:
       for chunk in iter(lambda: f.read(8192), ""):
         md5.update(chunk)
     print "MD5 hash is %s" % md5.hexdigest()
     if md5.hexdigest() != TEST_262_ARCHIVE_MD5:
       os.remove(archive_name)
       print "MD5 expected %s" % TEST_262_ARCHIVE_MD5
       raise Exception("MD5 hash mismatch of test data file")
     archive = tarfile.open(archive_name, "r:gz")
     if sys.platform in ("win32", "cygwin"):
       # Magic incantation to allow longer path names on Windows.
       archive.extractall(u"\\\\?\\%s" % self.root)
     else:
       archive.extractall(self.root)
     os.rename(os.path.join(self.root, "tc39-test262-%s" % revision),
               directory_name)
Пример #3
0
 def DownloadSinon(self):
     directory = os.path.join(self.root, SINON_NAME)
     if not os.path.exists(directory):
         os.mkdir(directory)
     path = os.path.join(directory, SINON_FILENAME)
     if not os.path.exists(path):
         utils.URLRetrieve(SINON_URL, path)
     hash = hashlib.sha256()
     with open(path, 'rb') as f:
         for chunk in iter(lambda: f.read(8192), ''):
             hash.update(chunk)
     if hash.hexdigest() != SINON_HASH:
         os.remove(path)
         raise Exception('Hash mismatch of test data file')
Пример #4
0
  def DownloadData(self):
    revision = SIMDJS_ARCHIVE_REVISION
    archive_url = SIMDJS_URL % revision

    archive_prefix = "ecmascript_simd-"
    archive_name = os.path.join(
        self.root, "%s%s.tar.gz" % (archive_prefix, revision))
    directory_name = os.path.join(self.root, "data")
    directory_old_name = os.path.join(self.root, "data.old")
    versionfile = os.path.join(self.root, "CHECKED_OUT_VERSION")

    checked_out_version = None
    checked_out_url = None
    checked_out_revision = None
    if os.path.exists(versionfile):
      with open(versionfile) as f:
        try:
          (checked_out_version,
           checked_out_url,
           checked_out_revision) = f.read().splitlines()
        except ValueError:
          pass
    if (checked_out_version != SIMDJS_ARCHIVE_MD5 or
        checked_out_url != archive_url or
        checked_out_revision != revision):
      if os.path.exists(archive_name):
        print "Clobbering %s because CHECK_OUT_VERSION is out of date" % (
            archive_name)
        os.remove(archive_name)

    # Clobber if the test is in an outdated state, i.e. if there are any other
    # archive files present.
    archive_files = [f for f in os.listdir(self.root)
                     if f.startswith(archive_prefix)]
    if (len(archive_files) > 1 or
        os.path.basename(archive_name) not in archive_files):
      print "Clobber outdated test archives ..."
      for f in archive_files:
        print "Removing %s" % f
        os.remove(os.path.join(self.root, f))

    if not os.path.exists(archive_name):
      print "Downloading test data from %s ..." % archive_url
      utils.URLRetrieve(archive_url, archive_name)
      if os.path.exists(directory_name):
        if os.path.exists(directory_old_name):
          shutil.rmtree(directory_old_name)
        os.rename(directory_name, directory_old_name)
    if not os.path.exists(directory_name):
      print "Extracting ecmascript_simd-%s.tar.gz ..." % revision
      md5 = hashlib.md5()
      with open(archive_name, "rb") as f:
        for chunk in iter(lambda: f.read(8192), ""):
          md5.update(chunk)
      print "MD5 hash is %s" % md5.hexdigest()
      if md5.hexdigest() != SIMDJS_ARCHIVE_MD5:
        os.remove(archive_name)
        print "MD5 expected %s" % SIMDJS_ARCHIVE_MD5
        raise Exception("MD5 hash mismatch of test data file")
      archive = tarfile.open(archive_name, "r:gz")
      if sys.platform in ("win32", "cygwin"):
        # Magic incantation to allow longer path names on Windows.
        archive.extractall(u"\\\\?\\%s" % self.root)
      else:
        archive.extractall(self.root)
      os.rename(os.path.join(self.root, "ecmascript_simd-%s" % revision),
                directory_name)

      with open(versionfile, "w") as f:
        f.write(SIMDJS_ARCHIVE_MD5 + '\n')
        f.write(archive_url + '\n')
        f.write(revision + '\n')