Bug 756083 - Part a: Factor out Makefile utilities; r=jhammel
authorMs2ger <ms2ger@gmail.com>
Wed, 18 Jul 2012 12:36:07 +0200
changeset 99518 afc9d034a2473fade715f3996d2ad3e6a109b1a6
parent 99517 c3c2badd015a3d25e3cf8a8d96056dedf2ef0847
child 99519 dcca069277d0deb5d5a7ff1ba354aad57a78fb72
push id23139
push userMs2ger@gmail.com
push dateWed, 18 Jul 2012 10:37:46 +0000
treeherdermozilla-central@bf09f11b69d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhammel
bugs756083
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 756083 - Part a: Factor out Makefile utilities; r=jhammel
dom/imptests/README
dom/imptests/editing/Makefile.in
dom/imptests/editing/conformancetest/Makefile.in
dom/imptests/editing/css/Makefile.in
dom/imptests/editing/selecttest/Makefile.in
dom/imptests/html/tests/submission/Mozilla/Makefile.in
dom/imptests/html/tests/submission/Opera/microdata/Makefile.in
dom/imptests/importTestsuite.py
dom/imptests/webapps/DOMCore/tests/approved/Makefile.in
dom/imptests/webapps/DOMCore/tests/submissions/Opera/Makefile.in
dom/imptests/webapps/WebStorage/tests/submissions/Infraware/Makefile.in
dom/imptests/webapps/WebStorage/tests/submissions/Infraware/iframe/Makefile.in
dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/Makefile.in
dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/Makefile.in
dom/imptests/writeMakefile.py
--- a/dom/imptests/README
+++ b/dom/imptests/README
@@ -44,16 +44,20 @@ Source;  Usage and purpose;  License
 
 * importTestsuite.py
   Imports a test suite from a remote repository. Takes one argument, a file in
   the format described under webapps.txt.
   Note: removes both source and destination directory before starting. Do not
         use with outstanding changes in either directory.
   MPL
 
+* writeMakefile.py
+  Helper functions to write out Makefiles.
+  MPL
+
 * Makefile.in
   Integration with our build system. Installs support files into /resources and
   includes a .mk file for each repository.
   MPL
 
 * failures/
   Expected failures for tests in each repository.  Each test's failures, if
   any, are in a file with the same path and name with .json appended.  New
--- a/dom/imptests/editing/Makefile.in
+++ b/dom/imptests/editing/Makefile.in
@@ -11,18 +11,15 @@ DIRS = \
   css \
   conformancetest \
   selecttest \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TESTS = \
-  $(NULL)
-
-_TESTS += \
+_FILES = \
   implementation.js \
   tests.js \
   $(NULL)
 
-libs:: $(_TESTS)
+libs:: $(_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
--- a/dom/imptests/editing/conformancetest/Makefile.in
+++ b/dom/imptests/editing/conformancetest/Makefile.in
@@ -8,19 +8,16 @@ VPATH = @srcdir@
 relativesrcdir = dom/imptests/editing/conformancetest
 
 DIRS = \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TESTS = \
+_FILES = \
   test_runtest.html \
   test_event.html \
-  $(NULL)
-
-_TESTS += \
   data.js \
   $(NULL)
 
-libs:: $(_TESTS)
+libs:: $(_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
--- a/dom/imptests/editing/css/Makefile.in
+++ b/dom/imptests/editing/css/Makefile.in
@@ -8,17 +8,14 @@ VPATH = @srcdir@
 relativesrcdir = dom/imptests/editing/css
 
 DIRS = \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TESTS = \
-  $(NULL)
-
-_TESTS += \
+_FILES = \
   reset.css \
   $(NULL)
 
-libs:: $(_TESTS)
+libs:: $(_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
--- a/dom/imptests/editing/selecttest/Makefile.in
+++ b/dom/imptests/editing/selecttest/Makefile.in
@@ -8,30 +8,27 @@ VPATH = @srcdir@
 relativesrcdir = dom/imptests/editing/selecttest
 
 DIRS = \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TESTS = \
+_FILES = \
   test_addRange.html \
   test_collapse.html \
   test_collapseToStartEnd.html \
   test_deleteFromDocument.html \
   test_Document-open.html \
   test_extend.html \
   test_getRangeAt.html \
   test_getSelection.html \
   test_interfaces.html \
   test_isCollapsed.html \
   test_removeAllRanges.html \
   test_selectAllChildren.html \
-  $(NULL)
-
-_TESTS += \
   common.js \
   test-iframe.html \
   $(NULL)
 
-libs:: $(_TESTS)
+libs:: $(_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
--- a/dom/imptests/html/tests/submission/Mozilla/Makefile.in
+++ b/dom/imptests/html/tests/submission/Mozilla/Makefile.in
@@ -8,24 +8,21 @@ VPATH = @srcdir@
 relativesrcdir = dom/imptests/html/tests/submission/Mozilla
 
 DIRS = \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TESTS = \
+_FILES = \
   test_body-onload.html \
   test_pageload-image.html \
   test_pageload-video.html \
   test_script-for-onload.html \
   test_window-onerror-parse-error.html \
   test_window-onerror-runtime-error.html \
   test_window-onerror-runtime-error-throw.html \
-  $(NULL)
-
-_TESTS += \
   nested-document-write-external.js \
   $(NULL)
 
-libs:: $(_TESTS)
+libs:: $(_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
--- a/dom/imptests/html/tests/submission/Opera/microdata/Makefile.in
+++ b/dom/imptests/html/tests/submission/Opera/microdata/Makefile.in
@@ -8,17 +8,14 @@ VPATH = @srcdir@
 relativesrcdir = dom/imptests/html/tests/submission/Opera/microdata
 
 DIRS = \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TESTS = \
+_FILES = \
   test_001.html \
   $(NULL)
 
-_TESTS += \
-  $(NULL)
-
-libs:: $(_TESTS)
+libs:: $(_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
--- a/dom/imptests/importTestsuite.py
+++ b/dom/imptests/importTestsuite.py
@@ -12,16 +12,17 @@ Note: removes both source and destinatio
 
 import os
 import shutil
 import string
 import subprocess
 import sys
 
 import parseManifest
+import writeMakefile
 
 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
@@ -72,88 +73,50 @@ def copy(thissrcdir, dest, directories):
 
     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 makefileString(entries):
-  if not len(entries):
-    return "  $(NULL)"
-  return "\n".join(["  %s \\" % (entry, ) for entry in entries]) + "\n  $(NULL)"
-
 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, "wb")
   fp.write("DIRS += \\\n")
-  fp.write(makefileString([makePath(dest, d) for d in directories]))
+  fp.write(writeMakefile.makefileString([makePath(dest, d) for d in directories]))
   fp.write("\n")
   fp.close()
   subprocess.check_call(["hg", "add", path])
 
-makefileTemplate = """# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
-
-DEPTH = ${depth}
-
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-relativesrcdir = ${relativesrcdir}
-
-DIRS = \\
-${dirs}
-
-include $$(DEPTH)/config/autoconf.mk
-include $$(topsrcdir)/config/rules.mk
-"""
-testsTemplate = """
-_TESTS = \\
-${tests}
-
-_TESTS += \\
-${support}
-
-libs:: $$(_TESTS)
-\t$$(INSTALL) $$(foreach f,$$^,"$$f") $$(DEPTH)/_tests/testing/mochitest/tests/$$(relativesrcdir)
-"""
-
 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:
     if d:
       path = "%s/%s" % (dest, d)
     else:
       # Empty directory, i.e., the repository root
       path = dest
-    abspath = "%s/%s" % (thissrcdir, path)
     print "Creating Makefile.in in %s..." % (path, )
 
     subdirs, mochitests, supportfiles = parseManifestFile(dest, d)
 
-    fp = open(path + "/Makefile.in", "wb")
-    result = string.Template(makefileTemplate).substitute({
-      "depth": "..%s" % ("/.." * abspath.count("/"), ),
-      "relativesrcdir": "%s/%s" % (thissrcdir, path),
-      "dirs": makefileString(subdirs)
-    })
+    abspath = "%s/%s" % (thissrcdir, path)
+    files = ["test_%s" % (mochitest, ) for mochitest in mochitests]
+    files.extend(supportfiles)
 
-    if len(mochitests) + len(supportfiles):
-      result += string.Template(testsTemplate).substitute({
-        "tests": makefileString(["test_%s" % (mochitest, ) for mochitest in mochitests]),
-        "support": makefileString(supportfiles)
-      })
+    result = writeMakefile.substMakefile("importTestsuite.py", abspath, subdirs, files)
 
+    fp = open(path + "/Makefile.in", "wb")
     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)])
--- a/dom/imptests/webapps/DOMCore/tests/approved/Makefile.in
+++ b/dom/imptests/webapps/DOMCore/tests/approved/Makefile.in
@@ -8,34 +8,31 @@ VPATH = @srcdir@
 relativesrcdir = dom/imptests/webapps/DOMCore/tests/approved
 
 DIRS = \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TESTS = \
+_FILES = \
   test_interfaces.html \
   test_Range-cloneContents.html \
   test_Range-cloneRange.html \
   test_Range-collapse.html \
   test_Range-commonAncestorContainer.html \
   test_Range-compareBoundaryPoints.html \
   test_Range-comparePoint.html \
   test_Range-deleteContents.html \
   test_Range-extractContents.html \
   test_Range-insertNode.html \
   test_Range-intersectsNode.html \
   test_Range-isPointInRange.html \
   test_Range-mutations.html \
   test_Range-selectNode.html \
   test_Range-set.html \
   test_Range-surroundContents.html \
-  $(NULL)
-
-_TESTS += \
   common.js \
   Range-test-iframe.html \
   $(NULL)
 
-libs:: $(_TESTS)
+libs:: $(_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
--- a/dom/imptests/webapps/DOMCore/tests/submissions/Opera/Makefile.in
+++ b/dom/imptests/webapps/DOMCore/tests/submissions/Opera/Makefile.in
@@ -8,17 +8,17 @@ VPATH = @srcdir@
 relativesrcdir = dom/imptests/webapps/DOMCore/tests/submissions/Opera
 
 DIRS = \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TESTS = \
+_FILES = \
   test_getElementsByClassName-01.htm \
   test_getElementsByClassName-02.htm \
   test_getElementsByClassName-03.htm \
   test_getElementsByClassName-04.htm \
   test_getElementsByClassName-05.htm \
   test_getElementsByClassName-06.htm \
   test_getElementsByClassName-07.htm \
   test_getElementsByClassName-08.htm \
@@ -29,13 +29,10 @@ include $(topsrcdir)/config/rules.mk
   test_getElementsByClassName-13.htm \
   test_getElementsByClassName-14.htm \
   test_getElementsByClassName-15.htm \
   test_getElementsByClassName-16.htm \
   test_getElementsByClassName-17.htm \
   test_getElementsByClassName-18.htm \
   $(NULL)
 
-_TESTS += \
-  $(NULL)
-
-libs:: $(_TESTS)
+libs:: $(_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
--- a/dom/imptests/webapps/WebStorage/tests/submissions/Infraware/Makefile.in
+++ b/dom/imptests/webapps/WebStorage/tests/submissions/Infraware/Makefile.in
@@ -9,17 +9,17 @@ relativesrcdir = dom/imptests/webapps/We
 
 DIRS = \
   iframe \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TESTS = \
+_FILES = \
   test_event_constructor.html \
   test_event_local_key.html \
   test_event_local_newvalue.html \
   test_event_local_oldvalue.html \
   test_event_local_storagearea.html \
   test_event_local_storageeventinit.html \
   test_event_local_url.html \
   test_event_session_key.html \
@@ -38,13 +38,10 @@ include $(topsrcdir)/config/rules.mk
   test_storage_session_clear.html \
   test_storage_session_getitem.html \
   test_storage_session_key.html \
   test_storage_session_length.html \
   test_storage_session_removeitem.html \
   test_storage_session_setitem.html \
   $(NULL)
 
-_TESTS += \
-  $(NULL)
-
-libs:: $(_TESTS)
+libs:: $(_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
--- a/dom/imptests/webapps/WebStorage/tests/submissions/Infraware/iframe/Makefile.in
+++ b/dom/imptests/webapps/WebStorage/tests/submissions/Infraware/iframe/Makefile.in
@@ -8,23 +8,20 @@ VPATH = @srcdir@
 relativesrcdir = dom/imptests/webapps/WebStorage/tests/submissions/Infraware/iframe
 
 DIRS = \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TESTS = \
-  $(NULL)
-
-_TESTS += \
+_FILES = \
   local_change_item_iframe.html \
   local_security_iframe.html \
   local_set_item_clear_iframe.html \
   local_set_item_iframe.html \
   session_change_item_iframe.html \
   session_set_item_clear_iframe.html \
   session_set_item_iframe.html \
   $(NULL)
 
-libs:: $(_TESTS)
+libs:: $(_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
--- a/dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/Makefile.in
+++ b/dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger/Makefile.in
@@ -8,17 +8,17 @@ VPATH = @srcdir@
 relativesrcdir = dom/imptests/webapps/WebStorage/tests/submissions/Ms2ger
 
 DIRS = \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TESTS = \
+_FILES = \
   test_event_constructor_js.html \
   test_missing_arguments.html \
   test_storage_local_clear_js.html \
   test_storage_local_getitem_js.html \
   test_storage_local_index_js.html \
   test_storage_local_in_js.html \
   test_storage_local_length_js.html \
   test_storage_local_removeitem_js.html \
@@ -27,13 +27,10 @@ include $(topsrcdir)/config/rules.mk
   test_storage_session_getitem_js.html \
   test_storage_session_index_js.html \
   test_storage_session_in_js.html \
   test_storage_session_length_js.html \
   test_storage_session_removeitem_js.html \
   test_storage_session_setitem_js.html \
   $(NULL)
 
-_TESTS += \
-  $(NULL)
-
-libs:: $(_TESTS)
+libs:: $(_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
--- a/dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/Makefile.in
+++ b/dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/Makefile.in
@@ -8,18 +8,15 @@ VPATH = @srcdir@
 relativesrcdir = dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger
 
 DIRS = \
   $(NULL)
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TESTS = \
+_FILES = \
   test_interfaces.html \
   test_setrequestheader-invalid-arguments.htm \
   $(NULL)
 
-_TESTS += \
-  $(NULL)
-
-libs:: $(_TESTS)
+libs:: $(_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
new file mode 100644
--- /dev/null
+++ b/dom/imptests/writeMakefile.py
@@ -0,0 +1,49 @@
+# 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/.
+
+import string
+
+makefileTemplate = """# THIS FILE IS AUTOGENERATED BY ${caller} - DO NOT EDIT
+
+DEPTH = ${depth}
+
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+relativesrcdir = ${relativesrcdir}
+
+DIRS = \\
+${dirs}
+
+include $$(DEPTH)/config/autoconf.mk
+include $$(topsrcdir)/config/rules.mk
+"""
+
+filesTemplate = """
+_FILES = \\
+${files}
+
+libs:: $$(_FILES)
+\t$$(INSTALL) $$(foreach f,$$^,"$$f") $$(DEPTH)/_tests/testing/mochitest/tests/$$(relativesrcdir)
+"""
+
+def makefileString(entries):
+  if not len(entries):
+    return "  $(NULL)"
+  return "\n".join(["  %s \\" % (entry, ) for entry in entries]) + "\n  $(NULL)"
+
+def substMakefile(caller, path, subdirs, files):
+  result = string.Template(makefileTemplate).substitute({
+    "caller": caller,
+    "depth": "..%s" % ("/.." * path.count("/"), ),
+    "relativesrcdir": path,
+    "dirs": makefileString(subdirs)
+  })
+
+  if files:
+    result += string.Template(filesTemplate).substitute({
+      "files": makefileString(files)
+    })
+
+  return result