def __init__(self, *args, **kwargs): self.marionette = kwargs.pop('marionette') TestResultCollection.__init__(self, 'MarionetteTest') unittest._TextTestResult.__init__(self, *args, **kwargs) self.passed = 0 self.testsRun = 0 self.result_modifiers = [] # used by mixins to modify the result
def __init__(self, *args, **kwargs): self.marionette = kwargs.pop("marionette") TestResultCollection.__init__(self, "MarionetteTest") self.passed = 0 self.testsRun = 0 self.result_modifiers = [] # used by mixins to modify the result StructuredTestResult.__init__(self, *args, **kwargs)
def setUp(self): c1 = TestContext('host1') c2 = TestContext('host2') c3 = TestContext('host2') c4 = TestContext('host1') t1 = TestResult('t1', context=c1) t2 = TestResult('t2', context=c2) t3 = TestResult('t3', context=c3) t4 = TestResult('t4', context=c4) self.collection = TestResultCollection('tests') self.collection.extend([t1, t2, t3, t4])
def setUp(self): c1 = TestContext("host1") c2 = TestContext("host2") c3 = TestContext("host2") c4 = TestContext("host1") t1 = TestResult("t1", context=c1) t2 = TestResult("t2", context=c2) t3 = TestResult("t3", context=c3) t4 = TestResult("t4", context=c4) self.collection = TestResultCollection("tests") self.collection.extend([t1, t2, t3, t4])
def __init__(self, *args, **kwargs): self.marionette = kwargs.pop('marionette') TestResultCollection.__init__(self, 'MarionetteTest') self.passed = 0 self.testsRun = 0 self.result_modifiers = [] # used by mixins to modify the result pid = kwargs.pop('b2g_pid') if pid: if B2GTestResultMixin not in self.__class__.__bases__: bases = [b for b in self.__class__.__bases__] bases.append(B2GTestResultMixin) self.__class__.__bases__ = tuple(bases) B2GTestResultMixin.__init__(self, b2g_pid=pid) unittest._TextTestResult.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): self.marionette = kwargs.pop("marionette") TestResultCollection.__init__(self, "MarionetteTest") self.passed = 0 self.testsRun = 0 self.result_modifiers = [] # used by mixins to modify the result pid = kwargs.pop("b2g_pid") logcat_stdout = kwargs.pop("logcat_stdout") if pid: if B2GTestResultMixin not in self.__class__.__bases__: bases = [b for b in self.__class__.__bases__] bases.append(B2GTestResultMixin) self.__class__.__bases__ = tuple(bases) B2GTestResultMixin.__init__(self, b2g_pid=pid, logcat_stdout=logcat_stdout) StructuredTestResult.__init__(self, *args, **kwargs)
def main(args=sys.argv[1:]): # read the manifest if args: manifests = args else: manifests = [os.path.join(here, 'test-manifest.ini')] missing = [] for manifest in manifests: # ensure manifests exist if not os.path.exists(manifest): missing.append(manifest) assert not missing, 'manifest%s not found: %s' % ((len(manifests) == 1 and '' or 's'), ', '.join(missing)) manifest = manifestparser.TestManifest(manifests=manifests) # gather the tests tests = manifest.active_tests() unittestlist = [] for test in tests: unittestlist.extend(unittests(test['path'])) # run the tests suite = unittest.TestSuite(unittestlist) runner = unittest.TextTestRunner(verbosity=2) # default=1 does not show success of unittests unittest_results = runner.run(suite) results = TestResultCollection.from_unittest_results(None, unittest_results) # exit according to results sys.exit(1 if results.num_failures else 0)
def main(args=sys.argv[1:]): # read the manifest if args: manifests = args else: manifests = [os.path.join(here, 'test-manifest.ini')] missing = [] for manifest in manifests: # ensure manifests exist if not os.path.exists(manifest): missing.append(manifest) assert not missing, 'manifest%s not found: %s' % ( (len(manifests) == 1 and '' or 's'), ', '.join(missing)) manifest = manifestparser.TestManifest(manifests=manifests) # gather the tests tests = manifest.active_tests() unittestlist = [] for test in tests: unittestlist.extend(unittests(test['path'])) # run the tests suite = unittest.TestSuite(unittestlist) runner = unittest.TextTestRunner( verbosity=2) # default=1 does not show success of unittests unittest_results = runner.run(suite) results = TestResultCollection.from_unittest_results( None, unittest_results) # exit according to results sys.exit(1 if results.num_failures else 0)
def main(args=sys.argv[1:]): # parse command line options usage = '%prog [options] manifest.ini <manifest.ini> <...>' parser = optparse.OptionParser(usage=usage, description=__doc__) parser.add_option('-b', "--binary", dest="binary", help="Binary path", metavar=None, default=None) parser.add_option('--list', dest='list_tests', action='store_true', default=False, help="list paths of tests to be run") options, args = parser.parse_args(args) # read the manifest if args: manifests = args else: manifests = [os.path.join(here, 'test-manifest.ini')] missing = [] for manifest in manifests: # ensure manifests exist if not os.path.exists(manifest): missing.append(manifest) assert not missing, 'manifest(s) not found: %s' % ', '.join(missing) manifest = manifestparser.TestManifest(manifests=manifests) if options.binary: # A specified binary should override the environment variable os.environ['BROWSER_PATH'] = options.binary # gather the tests tests = manifest.active_tests(disabled=False, **mozinfo.info) tests = [test['path'] for test in tests] if options.list_tests: # print test paths print '\n'.join(tests) sys.exit(0) # create unittests unittestlist = [] for test in tests: unittestlist.extend(unittests(test)) # run the tests suite = unittest.TestSuite(unittestlist) runner = unittest.TextTestRunner( verbosity=2, # default=1 does not show success of unittests resultclass=TBPLTextTestResult) unittest_results = runner.run(suite) results = TestResultCollection.from_unittest_results( None, unittest_results) # exit according to results sys.exit(1 if results.num_failures else 0)
class Collection(unittest.TestCase): def setUp(self): c1 = TestContext('host1') c2 = TestContext('host2') c3 = TestContext('host2') c4 = TestContext('host1') t1 = TestResult('t1', context=c1) t2 = TestResult('t2', context=c2) t3 = TestResult('t3', context=c3) t4 = TestResult('t4', context=c4) self.collection = TestResultCollection('tests') self.collection.extend([t1, t2, t3, t4]) def test_unique_contexts(self): self.assertEqual(len(self.collection.contexts), 2)
class Collection(unittest.TestCase): def setUp(self): c1 = TestContext("host1") c2 = TestContext("host2") c3 = TestContext("host2") c4 = TestContext("host1") t1 = TestResult("t1", context=c1) t2 = TestResult("t2", context=c2) t3 = TestResult("t3", context=c3) t4 = TestResult("t4", context=c4) self.collection = TestResultCollection("tests") self.collection.extend([t1, t2, t3, t4]) def test_unique_contexts(self): self.assertEqual(len(self.collection.contexts), 2)
def main(args=sys.argv[1:]): # parse command line options usage = '%prog [options] manifest.ini <manifest.ini> <...>' parser = optparse.OptionParser(usage=usage, description=__doc__) parser.add_option('-b', "--binary", dest="binary", help="Binary path", metavar=None, default=None) parser.add_option('--list', dest='list_tests', action='store_true', default=False, help="list paths of tests to be run") mozlog.commandline.add_logging_group(parser) options, args = parser.parse_args(args) logger = mozlog.commandline.setup_logging("mozbase", options, {"tbpl": sys.stdout}) # read the manifest if args: manifests = args else: manifests = [os.path.join(here, 'test-manifest.ini')] missing = [] for manifest in manifests: # ensure manifests exist if not os.path.exists(manifest): missing.append(manifest) assert not missing, 'manifest(s) not found: %s' % ', '.join(missing) manifest = manifestparser.TestManifest(manifests=manifests) if options.binary: # A specified binary should override the environment variable os.environ['BROWSER_PATH'] = options.binary # gather the tests tests = manifest.active_tests(disabled=False, **mozinfo.info) tests = [test['path'] for test in tests] logger.suite_start(tests) if options.list_tests: # print test paths print '\n'.join(tests) sys.exit(0) # create unittests unittestlist = [] for test in tests: unittestlist.extend(unittests(test)) # run the tests suite = unittest.TestSuite(unittestlist) runner = StructuredTestRunner(logger=logger) unittest_results = runner.run(suite) results = TestResultCollection.from_unittest_results(None, unittest_results) logger.suite_end() # exit according to results sys.exit(1 if results.num_failures else 0)
class Collection(unittest.TestCase): def setUp(self): c1 = TestContext("host1") c2 = TestContext("host2") c3 = TestContext("host2") c3.os = "B2G" c4 = TestContext("host1") t1 = TestResult("t1", context=c1) t2 = TestResult("t2", context=c2) t3 = TestResult("t3", context=c3) t4 = TestResult("t4", context=c4) self.collection = TestResultCollection("tests") self.collection.extend([t1, t2, t3, t4]) def test_unique_contexts(self): self.assertEqual(len(self.collection.contexts), 3)
def post_to_autolog(self, results, name): from moztest.results import TestContext, TestResult, TestResultCollection from moztest.output.autolog import AutologOutput context = TestContext( testgroup='b2g xpcshell testsuite', operating_system='android', arch='emulator', harness='xpcshell', hostname=socket.gethostname(), tree='b2g', buildtype='opt', ) collection = TestResultCollection('b2g emulator testsuite') for result in results: duration = result.get('time', 0) if 'skipped' in result: outcome = 'SKIPPED' elif 'todo' in result: outcome = 'KNOWN-FAIL' elif result['passed']: outcome = 'PASS' else: outcome = 'UNEXPECTED-FAIL' output = None if 'failure' in result: output = result['failure']['text'] t = TestResult(name=result['name'], test_class=name, time_start=0, context=context) t.finish(result=outcome, time_end=duration, output=output) collection.append(t) collection.time_taken += duration out = AutologOutput() out.post(out.make_testgroups(collection))
class Collection(unittest.TestCase): def setUp(self): c1 = TestContext('host1') c2 = TestContext('host2') c3 = TestContext('host2') c3.os = 'B2G' c4 = TestContext('host1') t1 = TestResult('t1', context=c1) t2 = TestResult('t2', context=c2) t3 = TestResult('t3', context=c3) t4 = TestResult('t4', context=c4) self.collection = TestResultCollection('tests') self.collection.extend([t1, t2, t3, t4]) def test_unique_contexts(self): self.assertEqual(len(self.collection.contexts), 3)
def post_to_autolog(self, results, name): from moztest.results import TestContext, TestResult, TestResultCollection from moztest.output.autolog import AutologOutput context = TestContext( testgroup="b2g xpcshell testsuite", operating_system="android", arch="emulator", harness="xpcshell", hostname=socket.gethostname(), tree="b2g", buildtype="opt", ) collection = TestResultCollection("b2g emulator testsuite") for result in results: duration = result.get("time", 0) if "skipped" in result: outcome = "SKIPPED" elif "todo" in result: outcome = "KNOWN-FAIL" elif result["passed"]: outcome = "PASS" else: outcome = "UNEXPECTED-FAIL" output = None if "failure" in result: output = result["failure"]["text"] t = TestResult(name=result["name"], test_class=name, time_start=0, context=context) t.finish(result=outcome, time_end=duration, output=output) collection.append(t) collection.time_taken += duration out = AutologOutput() out.post(out.make_testgroups(collection))
def setUp(self): c1 = TestContext("host1") c2 = TestContext("host2") c3 = TestContext("host2") c3.os = "B2G" c4 = TestContext("host1") t1 = TestResult("t1", context=c1) t2 = TestResult("t2", context=c2) t3 = TestResult("t3", context=c3) t4 = TestResult("t4", context=c4) self.collection = TestResultCollection("tests") self.collection.extend([t1, t2, t3, t4])
def setUp(self): c1 = TestContext('host1') c2 = TestContext('host2') c3 = TestContext('host2') c3.os = 'B2G' c4 = TestContext('host1') t1 = TestResult('t1', context=c1) t2 = TestResult('t2', context=c2) t3 = TestResult('t3', context=c3) t4 = TestResult('t4', context=c4) self.collection = TestResultCollection('tests') self.collection.extend([t1, t2, t3, t4])
def main(args=sys.argv[1:]): # parse command line options usage = '%prog [options] manifest.ini <manifest.ini> <...>' parser = optparse.OptionParser(usage=usage, description=__doc__) parser.add_option('--list', dest='list_tests', action='store_true', default=False, help="list paths of tests to be run") options, args = parser.parse_args(args) # read the manifest if args: manifests = args else: manifests = [os.path.join(here, 'test-manifest.ini')] missing = [] for manifest in manifests: # ensure manifests exist if not os.path.exists(manifest): missing.append(manifest) assert not missing, 'manifest(s) not found: %s' % ', '.join(missing) manifest = manifestparser.TestManifest(manifests=manifests) # gather the tests tests = manifest.active_tests(disabled=False, **mozinfo.info) tests = [test['path'] for test in tests] if options.list_tests: # print test paths print '\n'.join(tests) sys.exit(0) # create unittests unittestlist = [] for test in tests: unittestlist.extend(unittests(test)) # run the tests suite = unittest.TestSuite(unittestlist) runner = unittest.TextTestRunner(verbosity=2) # default=1 does not show success of unittests unittest_results = runner.run(suite) results = TestResultCollection.from_unittest_results(None, unittest_results) # exit according to results sys.exit(1 if results.num_failures else 0)
def main(args=sys.argv[1:]): # read the manifest if args: manifests = args else: manifests = [os.path.join(here, 'manifest.ini')] missing = [] for manifest_file in manifests: # ensure manifests exist if not os.path.exists(manifest_file): missing.append(manifest_file) assert not missing, 'manifest%s not found: %s' % ( (len(manifests) == 1 and '' or 's'), ', '.join(missing)) manifest = TestManifest(manifests=manifests) unittest_results = test_all(manifest) results = TestResultCollection.from_unittest_results( None, unittest_results) # exit according to results sys.exit(1 if results.num_failures else 0)
def __init__(self, *args, **kwargs): TestResultCollection.__init__(self, 'SessionTest') self.passed = 0 self.testsRun = 0 self.result_modifiers = [] # used by mixins to modify the result StructuredTestResult.__init__(self, *args, **kwargs)
def __init__(self, *args, **kwargs): self.marionette = kwargs.pop('marionette') TestResultCollection.__init__(self, 'MarionetteTest') unittest._TextTestResult.__init__(self, *args, **kwargs) self.passed = 0 self.testsRun = 0