Bug 1342828 - Support chunks in mozmill tests. r=philipp
--- a/mail/test/mozmill/runtestlist.py
+++ b/mail/test/mozmill/runtestlist.py
@@ -33,16 +33,25 @@ class RunTestListOptions(optparse.Option
help = "Directory of the tests, leave blank for current directory")
defaults["dir"] = ""
self.add_option("--symbols-path",
action = "store", type = "string", dest = "symbols",
help = "The path to the symbol files from build_symbols")
defaults["symbols"] = ""
+ self.add_option("--total-chunks",
+ action = "store", type = "int", dest = "total_chunks",
+ help="how many chunks to split the tests up into")
+ defaults["total_chunks"] = 1
+ self.add_option("--this-chunk",
+ action = "store", type = "int", dest = "this_chunk",
+ help="which chunk to run between 1 and --total-chunks")
+ defaults["this_chunk"] = 1
+
self.add_option("--plugins-path",
action = "store", type = "string", dest = "plugins",
help = "The path to the plugins folder for the test profiles")
self.add_option("--testing-modules-dir",
action="store", type="string", dest="testingmodules",
help="The path to the testing modules directory")
defaults["testingmodules"] = ""
@@ -65,18 +74,27 @@ options, args = parser.parse_args()
if options.binary == "" or options.list == "":
parser.print_help()
sys.exit(1)
totalTestErrors = 0
totalTestPasses = 0
totalDirectories = 0
-f = open(options.list, 'rt')
-for directory in f:
+tests = open(options.list, "rt").readlines()
+
+if options.total_chunks > 1:
+ tests_per_chunk = float(len(tests)) / options.total_chunks
+ start = int(round((options.this_chunk - 1) * tests_per_chunk))
+ end = int(round(options.this_chunk * tests_per_chunk))
+
+ tests = (t for t in tests[start:end])
+
+
+for directory in tests:
log.info("INFO | (runtestlist.py) | Running directory: %s",
directory.rstrip())
if options.dir != "":
testDirectory = os.path.join(options.dir, directory.rstrip())
else:
testDirectory = directory.rstrip()
args = [sys.executable, "runtest.py", "-t", testDirectory,
"--binary", os.path.abspath(options.binary), "--symbols-path", options.symbols]