def test_add_two_tags_filters(self): tag1 = tags('foo') tag2 = tags('bar') fl = filterlist([tag1]) with self.assertRaises(ValueError): fl.append(tag1) fl.append(tag2) self.assertEquals(len(fl), 2)
def test_tags(self): ftags1 = tags([]) ftags2 = tags(['bar', 'baz']) tests = deepcopy(self.tests) tests = list(ftags1(tests, {})) self.assertEquals(len(tests), 0) tests = deepcopy(self.tests) tests = list(ftags2(tests, {})) self.assertEquals(len(tests), 1) self.assertIn(self.tests[7], tests)
def add_test(self, test, expected='pass', test_container=None): filepath = os.path.abspath(test) if os.path.isdir(filepath): for root, dirs, files in os.walk(filepath): for filename in files: if (filename.endswith('.ini')): msg_tmpl = ("Ignoring manifest '{0}'; running all tests in '{1}'." " See --help for details.") relpath = os.path.relpath(os.path.join(root, filename), filepath) self.logger.warning(msg_tmpl.format(relpath, filepath)) elif (filename.startswith('test_') and (filename.endswith('.py') or filename.endswith('.js'))): test_file = os.path.join(root, filename) self.add_test(test_file) return file_ext = os.path.splitext(os.path.split(filepath)[-1])[1] if file_ext == '.ini': manifest = TestManifest() manifest.read(filepath) filters = [] if self.test_tags: filters.append(tags(self.test_tags)) json_path = update_mozinfo(filepath) self.logger.info("mozinfo updated with the following: {}".format(None)) manifest_tests = manifest.active_tests(exists=False, disabled=True, filters=filters, app=self.appName, e10s=self.e10s, **mozinfo.info) if len(manifest_tests) == 0: self.logger.error("no tests to run using specified " "combination of filters: {}".format( manifest.fmt_filters())) target_tests = [] for test in manifest_tests: if test.get('disabled'): self.manifest_skipped_tests.append(test) else: target_tests.append(test) for i in target_tests: if not os.path.exists(i["path"]): raise IOError("test file: %s does not exist" % i["path"]) file_ext = os.path.splitext(os.path.split(i['path'])[-1])[-1] test_container = None self.add_test(i["path"], i["expected"], test_container) return self.tests.append({'filepath': filepath, 'expected': expected, 'test_container': test_container})
def add_test(self, test, expected="pass", test_container=None): filepath = os.path.abspath(test) if os.path.isdir(filepath): for root, dirs, files in os.walk(filepath): for filename in files: if filename.startswith("test_") and (filename.endswith(".py") or filename.endswith(".js")): filepath = os.path.join(root, filename) self.add_test(filepath) return file_ext = os.path.splitext(os.path.split(filepath)[-1])[1] if file_ext == ".ini": manifest = TestManifest() manifest.read(filepath) filters = [] if self.test_tags: filters.append(tags(self.test_tags)) json_path = update_mozinfo(filepath) self.logger.info("mozinfo updated with the following: {}".format(None)) manifest_tests = manifest.active_tests( exists=False, disabled=True, filters=filters, device=self.device, app=self.appName, e10s=self.e10s, **mozinfo.info ) if len(manifest_tests) == 0: self.logger.error( "no tests to run using specified " "combination of filters: {}".format(manifest.fmt_filters()) ) target_tests = [] for test in manifest_tests: if test.get("disabled"): self.manifest_skipped_tests.append(test) else: target_tests.append(test) for i in target_tests: if not os.path.exists(i["path"]): raise IOError("test file: %s does not exist" % i["path"]) file_ext = os.path.splitext(os.path.split(i["path"])[-1])[-1] test_container = None self.add_test(i["path"], i["expected"], test_container) return self.tests.append({"filepath": filepath, "expected": expected, "test_container": test_container})
def add_test(self, test, expected='pass', test_container=None): filepath = os.path.abspath(test) if os.path.isdir(filepath): for root, dirs, files in os.walk(filepath): for filename in files: if (filename.startswith('test_') and (filename.endswith('.py') or filename.endswith('.js'))): filepath = os.path.join(root, filename) self.add_test(filepath) return file_ext = os.path.splitext(os.path.split(filepath)[-1])[1] if file_ext == '.ini': manifest = TestManifest() manifest.read(filepath) filters = [] if self.test_tags: filters.append(tags(self.test_tags)) manifest_tests = manifest.active_tests(exists=False, disabled=True, filters=filters, e10s=self.e10s, **mozinfo.info) if len(manifest_tests) == 0: self.logger.error("no tests to run using specified " "combination of filters: {}".format( manifest.fmt_filters())) target_tests = [] for test in manifest_tests: if test.get('disabled'): self.manifest_skipped_tests.append(test) else: target_tests.append(test) for i in target_tests: if not os.path.exists(i["path"]): raise IOError("test file: %s does not exist" % i["path"]) file_ext = os.path.splitext(os.path.split(i['path'])[-1])[-1] test_container = None self.add_test(i["path"], i["expected"], test_container) return self.tests.append({'filepath': filepath, 'expected': expected, 'test_container': test_container})
def add_test(self, test, expected='pass', test_container=None): filepath = os.path.abspath(test) if os.path.isdir(filepath): for root, dirs, files in os.walk(filepath): for filename in files: if (filename.startswith('test_') and (filename.endswith('.py') or filename.endswith('.js'))): filepath = os.path.join(root, filename) self.add_test(filepath) return testargs = {} if self.type is not None: testtypes = self.type.replace('+', ' +').replace('-', ' -').split() for atype in testtypes: if atype.startswith('+'): testargs.update({ atype[1:]: 'true' }) elif atype.startswith('-'): testargs.update({ atype[1:]: 'false' }) else: testargs.update({ atype: 'true' }) testarg_b2g = bool(testargs.get('b2g')) file_ext = os.path.splitext(os.path.split(filepath)[-1])[1] if file_ext == '.ini': manifest = TestManifest() manifest.read(filepath) filters = [] if self.test_tags: filters.append(tags(self.test_tags)) manifest_tests = manifest.active_tests(exists=False, disabled=True, filters=filters, device=self.device, app=self.appName, **mozinfo.info) if len(manifest_tests) == 0: self.logger.error("no tests to run using specified " "combination of filters: {}".format( manifest.fmt_filters())) unfiltered_tests = [] for test in manifest_tests: if test.get('disabled'): self.manifest_skipped_tests.append(test) else: unfiltered_tests.append(test) target_tests = manifest.get(tests=unfiltered_tests, **testargs) for test in unfiltered_tests: if test['path'] not in [x['path'] for x in target_tests]: test.setdefault('disabled', 'filtered by type (%s)' % self.type) self.manifest_skipped_tests.append(test) for i in target_tests: if not os.path.exists(i["path"]): raise IOError("test file: %s does not exist" % i["path"]) file_ext = os.path.splitext(os.path.split(i['path'])[-1])[-1] test_container = None if i.get('test_container') and testarg_b2g: if i.get('test_container') == "true": test_container = True elif i.get('test_container') == "false": test_container = False self.add_test(i["path"], i["expected"], test_container) return self.tests.append({'filepath': filepath, 'expected': expected, 'test_container': test_container})
def add_test(self, test, expected='pass'): filepath = os.path.abspath(test) if os.path.isdir(filepath): for root, dirs, files in os.walk(filepath): for filename in files: if filename.endswith('.ini'): msg_tmpl = ("Ignoring manifest '{0}'; running all tests in '{1}'." " See --help for details.") relpath = os.path.relpath(os.path.join(root, filename), filepath) self.logger.warning(msg_tmpl.format(relpath, filepath)) elif self._is_filename_valid(filename): test_file = os.path.join(root, filename) self.add_test(test_file) return file_ext = os.path.splitext(os.path.split(filepath)[-1])[1] if file_ext == '.ini': manifest = TestManifest() manifest.read(filepath) json_path = update_mozinfo(filepath) self.logger.info("mozinfo updated from: {}".format(json_path)) self.logger.info("mozinfo is: {}".format(mozinfo.info)) filters = [] if self.test_tags: filters.append(tags(self.test_tags)) values = { "appname": self.appName, "e10s": self.e10s, "manage_instance": self.marionette.instance is not None, } values.update(mozinfo.info) manifest_tests = manifest.active_tests(exists=False, disabled=True, filters=filters, **values) if len(manifest_tests) == 0: self.logger.error("No tests to run using specified " "combination of filters: {}".format( manifest.fmt_filters())) target_tests = [] for test in manifest_tests: if test.get('disabled'): self.manifest_skipped_tests.append(test) else: target_tests.append(test) for i in target_tests: if not os.path.exists(i["path"]): raise IOError("test file: {} does not exist".format(i["path"])) file_ext = os.path.splitext(os.path.split(i['path'])[-1])[-1] self.add_test(i["path"], i["expected"]) return self.tests.append({'filepath': filepath, 'expected': expected})
def add_test(self, test, expected='pass', group='default'): filepath = os.path.abspath(test) if os.path.isdir(filepath): for root, dirs, files in os.walk(filepath): for filename in files: if filename.endswith('.ini'): msg_tmpl = ("Ignoring manifest '{0}'; running all tests in '{1}'." " See --help for details.") relpath = os.path.relpath(os.path.join(root, filename), filepath) self.logger.warning(msg_tmpl.format(relpath, filepath)) elif self._is_filename_valid(filename): test_file = os.path.join(root, filename) self.add_test(test_file) return file_ext = os.path.splitext(os.path.split(filepath)[-1])[1] if file_ext == '.ini': group = filepath manifest = TestManifest() manifest.read(filepath) json_path = update_mozinfo(filepath) self.logger.info("mozinfo updated from: {}".format(json_path)) self.logger.info("mozinfo is: {}".format(mozinfo.info)) filters = [] if self.test_tags: filters.append(tags(self.test_tags)) values = { "appname": self.appName, "e10s": self.e10s, "manage_instance": self.marionette.instance is not None, "headless": self.headless } values.update(mozinfo.info) manifest_tests = manifest.active_tests(exists=False, disabled=True, filters=filters, **values) if len(manifest_tests) == 0: self.logger.error("No tests to run using specified " "combination of filters: {}".format( manifest.fmt_filters())) target_tests = [] for test in manifest_tests: if test.get('disabled'): self.manifest_skipped_tests.append(test) else: target_tests.append(test) for i in target_tests: if not os.path.exists(i["path"]): raise IOError("test file: {} does not exist".format(i["path"])) self.add_test(i["path"], i["expected"], group=group) return self.tests.append({'filepath': filepath, 'expected': expected, 'group': group})
def add_test(self, test, expected='pass', test_container=None): filepath = os.path.abspath(test) if os.path.isdir(filepath): for root, dirs, files in os.walk(filepath): for filename in files: if (filename.startswith('test_') and (filename.endswith('.py') or filename.endswith('.js'))): filepath = os.path.join(root, filename) self.add_test(filepath) return testargs = {} if self.type is not None: testtypes = self.type.replace('+', ' +').replace('-', ' -').split() for atype in testtypes: if atype.startswith('+'): testargs.update({atype[1:]: 'true'}) elif atype.startswith('-'): testargs.update({atype[1:]: 'false'}) else: testargs.update({atype: 'true'}) testarg_b2g = bool(testargs.get('b2g')) file_ext = os.path.splitext(os.path.split(filepath)[-1])[1] if file_ext == '.ini': manifest = TestManifest() manifest.read(filepath) filters = [] if self.test_tags: filters.append(tags(self.test_tags)) json_path = update_mozinfo(filepath) self.logger.info( "mozinfo updated with the following: {}".format(None)) manifest_tests = manifest.active_tests(exists=False, disabled=True, filters=filters, device=self.device, app=self.appName, e10s=self.e10s, **mozinfo.info) if len(manifest_tests) == 0: self.logger.error("no tests to run using specified " "combination of filters: {}".format( manifest.fmt_filters())) unfiltered_tests = [] for test in manifest_tests: if test.get('disabled'): self.manifest_skipped_tests.append(test) else: unfiltered_tests.append(test) target_tests = manifest.get(tests=unfiltered_tests, **testargs) for test in unfiltered_tests: if test['path'] not in [x['path'] for x in target_tests]: test.setdefault('disabled', 'filtered by type (%s)' % self.type) self.manifest_skipped_tests.append(test) for i in target_tests: if not os.path.exists(i["path"]): raise IOError("test file: %s does not exist" % i["path"]) file_ext = os.path.splitext(os.path.split(i['path'])[-1])[-1] test_container = None if i.get('test_container') and testarg_b2g: if i.get('test_container') == "true": test_container = True elif i.get('test_container') == "false": test_container = False self.add_test(i["path"], i["expected"], test_container) return self.tests.append({ 'filepath': filepath, 'expected': expected, 'test_container': test_container })
def add_test(self, test, expected='pass', test_container=None): filepath = os.path.abspath(test) if os.path.isdir(filepath): for root, dirs, files in os.walk(filepath): for filename in files: if filename.endswith('.ini'): msg_tmpl = ( "Ignoring manifest '{0}'; running all tests in '{1}'." " See --help for details.") relpath = os.path.relpath(os.path.join(root, filename), filepath) self.logger.warning(msg_tmpl.format(relpath, filepath)) elif self._is_filename_valid(filename): test_file = os.path.join(root, filename) self.add_test(test_file) return file_ext = os.path.splitext(os.path.split(filepath)[-1])[1] if file_ext == '.ini': manifest = TestManifest() manifest.read(filepath) filters = [] if self.test_tags: filters.append(tags(self.test_tags)) json_path = update_mozinfo(filepath) self.logger.info( "mozinfo updated with the following: {}".format(None)) manifest_tests = manifest.active_tests(exists=False, disabled=True, filters=filters, app=self.appName, e10s=self.e10s, **mozinfo.info) if len(manifest_tests) == 0: self.logger.error("no tests to run using specified " "combination of filters: {}".format( manifest.fmt_filters())) target_tests = [] for test in manifest_tests: if test.get('disabled'): self.manifest_skipped_tests.append(test) else: target_tests.append(test) for i in target_tests: if not os.path.exists(i["path"]): raise IOError("test file: %s does not exist" % i["path"]) file_ext = os.path.splitext(os.path.split(i['path'])[-1])[-1] test_container = None self.add_test(i["path"], i["expected"], test_container) return self.tests.append({ 'filepath': filepath, 'expected': expected, 'test_container': test_container })
def add_test(self, test, expected="pass", test_container=None): filepath = os.path.abspath(test) if os.path.isdir(filepath): for root, dirs, files in os.walk(filepath): for filename in files: if filename.startswith("test_") and (filename.endswith(".py") or filename.endswith(".js")): filepath = os.path.join(root, filename) self.add_test(filepath) return testargs = {} if self.type is not None: testtypes = self.type.replace("+", " +").replace("-", " -").split() for atype in testtypes: if atype.startswith("+"): testargs.update({atype[1:]: "true"}) elif atype.startswith("-"): testargs.update({atype[1:]: "false"}) else: testargs.update({atype: "true"}) testarg_b2g = bool(testargs.get("b2g")) file_ext = os.path.splitext(os.path.split(filepath)[-1])[1] if file_ext == ".ini": manifest = TestManifest() manifest.read(filepath) filters = [] if self.test_tags: filters.append(tags(self.test_tags)) manifest_tests = manifest.active_tests( exists=False, disabled=True, filters=filters, device=self.device, app=self.appName, **mozinfo.info ) if len(manifest_tests) == 0: self.logger.error( "no tests to run using specified " "combination of filters: {}".format(manifest.fmt_filters()) ) unfiltered_tests = [] for test in manifest_tests: if test.get("disabled"): self.manifest_skipped_tests.append(test) else: unfiltered_tests.append(test) target_tests = manifest.get(tests=unfiltered_tests, **testargs) for test in unfiltered_tests: if test["path"] not in [x["path"] for x in target_tests]: test.setdefault("disabled", "filtered by type (%s)" % self.type) self.manifest_skipped_tests.append(test) for i in target_tests: if not os.path.exists(i["path"]): raise IOError("test file: %s does not exist" % i["path"]) file_ext = os.path.splitext(os.path.split(i["path"])[-1])[-1] test_container = None if i.get("test_container") and testarg_b2g: if i.get("test_container") == "true": test_container = True elif i.get("test_container") == "false": test_container = False self.add_test(i["path"], i["expected"], test_container) return self.tests.append({"filepath": filepath, "expected": expected, "test_container": test_container})