gecko/dom/imptests/importTestsuite.py

159 lines
4.9 KiB
Python
Raw Normal View History

#!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
"""
Imports a test suite from a remote repository. Takes one argument, a file in
the format described in README.
Note: removes both source and destination directory before starting. Do not
use with outstanding changes in either directory.
"""
from __future__ import print_function, unicode_literals
import os
import shutil
import subprocess
import sys
import parseManifest
import writeMakefile
HEADERS_SUFFIX = "^headers^"
def parseManifestFile(dest, dir):
subdirs, mochitests, _, __, supportfiles = parseManifest.parseManifestFile("hg-%s/%s/MANIFEST" % (dest, dir))
return subdirs, mochitests, supportfiles
def getData(confFile):
"""This function parses a file of the form
URL of remote repository|Name of the destination directory
First directory of tests
...
Last directory of tests"""
repo = ""
dest = ""
directories = []
try:
fp = open(confFile, "r")
first = True
for line in fp:
if first:
idx = line.index("|")
repo = line[:idx].strip()
dest = line[idx + 1:].strip()
first = False
else:
directories.append(line.strip())
finally:
fp.close()
return repo, dest, directories
def makePath(a, b):
if not b:
# Empty directory, i.e., the repository root.
return a
return "%s/%s" % (a, b)
def copyTest(source, dest):
"""Copy the file at source to dest, as well as any ^headers^ file associated
with it."""
shutil.copy(source, dest)
if os.path.exists(source + HEADERS_SUFFIX):
shutil.copy(source + HEADERS_SUFFIX, dest + HEADERS_SUFFIX)
def copy(thissrcdir, dest, directories):
"""Copy mochitests and support files from the external HG directory to their
place in mozilla-central.
"""
print("Copying %s..." % directories)
for d in directories:
subdirs, mochitests, supportfiles = parseManifestFile(dest, d)
sourcedir = makePath("hg-%s" % dest, d)
destdir = makePath(dest, d)
os.makedirs(destdir)
for mochitest in mochitests:
copyTest("%s/%s" % (sourcedir, mochitest), "%s/test_%s" % (destdir, mochitest))
for support in supportfiles:
copyTest("%s/%s" % (sourcedir, support), "%s/%s" % (destdir, support))
if len(subdirs):
if d:
importDirs(thissrcdir, dest, ["%s/%s" % (d, subdir) for subdir in subdirs])
else:
# Empty directory, i.e., the repository root
importDirs(thissrcdir, dest, subdirs)
def printMakefile(dest, directories):
"""Create a .mk file to be included into the main Makefile.in, which lists the
directories with tests.
"""
print("Creating .mk...")
path = dest + ".mk"
fp = open(path, "w")
fp.write("DIRS += \\\n")
fp.write(writeMakefile.makefileString([makePath(dest, d) for d in directories]))
fp.write("\n")
fp.close()
subprocess.check_call(["hg", "add", path])
def printMakefiles(thissrcdir, dest, directories):
"""Create Makefile.in files for each directory that contains tests we import.
"""
print("Creating Makefile.ins...")
for d in directories:
path = makePath(dest, d)
print("Creating Makefile.in in %s..." % path)
subdirs, mochitests, supportfiles = parseManifestFile(dest, d)
files = ["test_%s" % (mochitest, ) for mochitest in mochitests]
files.extend(supportfiles)
files.extend(f for f in os.listdir(path) if f.endswith(HEADERS_SUFFIX))
result = writeMakefile.substMakefile("importTestsuite.py", subdirs, files)
fp = open(path + "/Makefile.in", "w")
fp.write(result)
fp.close()
def hgadd(dest, directories):
"""Inform hg of the files in |directories|."""
print("hg addremoving...")
for d in directories:
subprocess.check_call(["hg", "addremove", "%s/%s" % (dest, d)])
def importDirs(thissrcdir, dest, directories):
copy(thissrcdir, dest, directories)
printMakefiles(thissrcdir, dest, directories)
def importRepo(confFile, thissrcdir):
try:
repo, dest, directories = getData(confFile)
hgdest = "hg-%s" % (dest, )
print("Going to clone %s to %s..." % (repo, hgdest))
print("Removing %s..." % dest)
subprocess.check_call(["rm", "--recursive", "--force", dest])
print("Removing %s..." % hgdest)
subprocess.check_call(["rm", "--recursive", "--force", hgdest])
print("Cloning %s to %s..." % (repo, hgdest))
subprocess.check_call(["hg", "clone", repo, hgdest])
print("Going to import %s..." % directories)
importDirs(thissrcdir, dest, directories)
printMakefile(dest, directories)
hgadd(dest, directories)
print("Removing %s again..." % hgdest)
subprocess.check_call(["rm", "--recursive", "--force", hgdest])
except subprocess.CalledProcessError as e:
print(e.returncode)
finally:
print("Done")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Need one argument.")
else:
Bug 752202 - Shorten the paths to imported tests some more to hopefully fix C-C windows builds; rs=Standard8 --HG-- rename : dom/imported-tests/Makefile.in => dom/imptests/Makefile.in rename : dom/imported-tests/README => dom/imptests/README rename : dom/imported-tests/WebIDLParser.js => dom/imptests/WebIDLParser.js rename : dom/imported-tests/failures.txt => dom/imptests/failures.txt rename : dom/imported-tests/html.json => dom/imptests/html.json rename : dom/imported-tests/html.mk => dom/imptests/html.mk rename : dom/imported-tests/html.txt => dom/imptests/html.txt rename : dom/imported-tests/html/tests/submission/Mozilla/Makefile.in => dom/imptests/html/tests/submission/Mozilla/Makefile.in rename : dom/imported-tests/html/tests/submission/Mozilla/nested-document-write-external.js => dom/imptests/html/tests/submission/Mozilla/nested-document-write-external.js rename : dom/imported-tests/html/tests/submission/Mozilla/test_body-onload.html => dom/imptests/html/tests/submission/Mozilla/test_body-onload.html rename : dom/imported-tests/html/tests/submission/Mozilla/test_pageload-image.html => dom/imptests/html/tests/submission/Mozilla/test_pageload-image.html rename : dom/imported-tests/html/tests/submission/Mozilla/test_pageload-video.html => dom/imptests/html/tests/submission/Mozilla/test_pageload-video.html rename : dom/imported-tests/html/tests/submission/Mozilla/test_script-for-onload.html => dom/imptests/html/tests/submission/Mozilla/test_script-for-onload.html rename : dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-parse-error.html => dom/imptests/html/tests/submission/Mozilla/test_window-onerror-parse-error.html rename : dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-runtime-error-throw.html => dom/imptests/html/tests/submission/Mozilla/test_window-onerror-runtime-error-throw.html rename : dom/imported-tests/html/tests/submission/Mozilla/test_window-onerror-runtime-error.html => dom/imptests/html/tests/submission/Mozilla/test_window-onerror-runtime-error.html rename : dom/imported-tests/idlharness.js => dom/imptests/idlharness.js rename : dom/imported-tests/importTestsuite.py => dom/imptests/importTestsuite.py rename : dom/imported-tests/parseManifest.py => dom/imptests/parseManifest.py rename : dom/imported-tests/testharness.css => dom/imptests/testharness.css rename : dom/imported-tests/testharness.js => dom/imptests/testharness.js rename : dom/imported-tests/testharnessreport.js.in => dom/imptests/testharnessreport.js.in rename : dom/imported-tests/updateTestharness.py => dom/imptests/updateTestharness.py rename : dom/imported-tests/webapps.json => dom/imptests/webapps.json rename : dom/imported-tests/webapps.mk => dom/imptests/webapps.mk rename : dom/imported-tests/webapps.txt => dom/imptests/webapps.txt rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/Makefile.in => dom/imptests/webapps/DOMCore/tests/submissions/Opera/Makefile.in rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-01.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-01.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-02.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-02.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-03.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-03.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-04.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-04.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-05.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-05.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-06.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-06.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-07.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-07.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-08.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-08.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-09.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-09.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-10.xml => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-10.xml rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-11.xml => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-11.xml rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-12.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-12.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-13.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-13.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-14.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-14.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-15.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-15.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-16.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-16.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-17.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-17.htm rename : dom/imported-tests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-18.htm => dom/imptests/webapps/DOMCore/tests/submissions/Opera/test_getElementsByClassName-18.htm rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/Makefile.in => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/Makefile.in rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/iframe/Makefile.in => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/iframe/Makefile.in rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/iframe/local_change_item_iframe.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/iframe/local_change_item_iframe.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/iframe/local_security_iframe.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/iframe/local_security_iframe.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/iframe/local_set_item_clear_iframe.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/iframe/local_set_item_clear_iframe.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/iframe/local_set_item_iframe.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/iframe/local_set_item_iframe.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/iframe/session_change_item_iframe.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/iframe/session_change_item_iframe.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/iframe/session_set_item_clear_iframe.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/iframe/session_set_item_clear_iframe.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/iframe/session_set_item_iframe.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/iframe/session_set_item_iframe.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_constructor.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_constructor.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_local_key.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_local_key.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_local_newvalue.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_local_newvalue.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_local_oldvalue.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_local_oldvalue.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_local_storagearea.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_local_storagearea.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_local_storageeventinit.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_local_storageeventinit.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_local_url.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_local_url.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_session_key.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_session_key.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_session_newvalue.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_session_newvalue.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_session_oldvalue.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_session_oldvalue.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_session_storagearea.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_session_storagearea.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_session_storageeventinit.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_session_storageeventinit.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_event_session_url.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_event_session_url.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_clear.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_clear.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_getitem.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_getitem.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_key.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_key.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_length.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_length.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_removeitem.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_removeitem.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_security.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_security.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_setitem.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_local_setitem.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_session_clear.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_session_clear.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_session_getitem.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_session_getitem.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_session_key.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_session_key.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_session_length.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_session_length.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_session_removeitem.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_session_removeitem.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Infraware/test_storage_session_setitem.html => dom/imptests/webapps/WebStorage/tests/submissions/Infraware/test_storage_session_setitem.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Makefile.in => dom/imptests/webapps/WebStorage/tests/submissions/Makefile.in rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/Makefile.in => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/Makefile.in rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_event_constructor_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_event_constructor_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_clear_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_clear_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_getitem_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_getitem_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_in_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_in_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_index_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_index_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_length_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_length_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_removeitem_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_removeitem_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_setitem_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_local_setitem_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_clear_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_clear_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_getitem_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_getitem_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_in_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_in_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_index_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_index_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_length_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_length_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_removeitem_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_removeitem_js.html rename : dom/imported-tests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_setitem_js.html => dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/test_storage_session_setitem_js.html rename : dom/imported-tests/writeReporter.py => dom/imptests/writeReporter.py
2012-05-05 07:00:30 -07:00
importRepo(sys.argv[1], "dom/imptests")