def test_orphan_file_patterns(self): if sys.platform == 'win32': raise unittest.SkipTest('failing on windows builds') mb = MozbuildObject.from_environment(detect_virtualenv_mozinfo=False) try: config = mb.config_environment except Exception as e: if str(e) == 'config.status not available. Run configure.': raise unittest.SkipTest('failing without config.status') raise if config.substs['MOZ_BUILD_APP'] == 'js': raise unittest.SkipTest('failing in Spidermonkey builds') reader = BuildReader(config) all_paths = self._mozbuilds(reader) _, contexts = reader.read_relevant_mozbuilds(all_paths) finder = FileFinder(config.topsrcdir, ignore=['obj*']) def pattern_exists(pat): return [p for p in finder.find(pat)] != [] for ctx in contexts: if not isinstance(ctx, Files): continue relsrcdir = ctx.relsrcdir for p in ctx.patterns: if not pattern_exists(os.path.join(relsrcdir, p)): self.fail("The pattern '%s' in a Files() entry in " "'%s' corresponds to no files in the tree.\n" "Please update this entry." % (p, ctx.main_path))
def test_filesystem_traversal_reading(self): """Reading moz.build according to filesystem traversal works. We attempt to read every known moz.build file via filesystem traversal. If this test fails, it means that metadata extraction will fail. """ mb = MozbuildObject.from_environment(detect_virtualenv_mozinfo=False) config = mb.config_environment reader = BuildReader(config) all_paths = self._mozbuilds(reader) paths, contexts = reader.read_relevant_mozbuilds(all_paths) self.assertEqual(set(paths), all_paths) self.assertGreaterEqual(len(contexts), len(paths))
def test_filesystem_traversal_reading(self): """Reading moz.build according to filesystem traversal works. We attempt to read every known moz.build file via filesystem traversal. If this test fails, it means that metadata extraction will fail. """ mb = MozbuildObject.from_environment(detect_virtualenv_mozinfo=False) config = mb.config_environment reader = BuildReader(config) all_paths = self._mozbuilds(reader) paths, contexts = reader.read_relevant_mozbuilds(all_paths) self.assertEqual(set(paths), all_paths) self.assertGreaterEqual(len(contexts), len(paths))
def test_filesystem_traversal_no_config(self): """Reading moz.build files via filesystem traversal mode with no build config. This is similar to the above test except no build config is applied. This will likely fail in more scenarios than the above test because a lot of moz.build files assumes certain variables are present. """ here = os.path.abspath(os.path.dirname(__file__)) root = os.path.normpath(os.path.join(here, '..', '..')) config = EmptyConfig(root) reader = BuildReader(config) all_paths = self._mozbuilds(reader) paths, contexts = reader.read_relevant_mozbuilds(all_paths) self.assertEqual(set(paths.keys()), all_paths) self.assertGreaterEqual(len(contexts), len(paths))
def test_filesystem_traversal_no_config(self): """Reading moz.build files via filesystem traversal mode with no build config. This is similar to the above test except no build config is applied. This will likely fail in more scenarios than the above test because a lot of moz.build files assumes certain variables are present. """ here = os.path.abspath(os.path.dirname(__file__)) root = os.path.normpath(os.path.join(here, '..', '..')) config = EmptyConfig(root) reader = BuildReader(config) all_paths = self._mozbuilds(reader) paths, contexts = reader.read_relevant_mozbuilds(all_paths) self.assertEqual(set(paths.keys()), all_paths) self.assertGreaterEqual(len(contexts), len(paths))
def test_orphan_file_patterns(self): if sys.platform == 'win32': raise unittest.SkipTest('failing on windows builds') mb = MozbuildObject.from_environment(detect_virtualenv_mozinfo=False) try: config = mb.config_environment except Exception as e: if e.message == 'config.status not available. Run configure.': raise unittest.SkipTest('failing without config.status') raise if config.substs['MOZ_BUILD_APP'] == 'js': raise unittest.SkipTest('failing in Spidermonkey builds') reader = BuildReader(config) all_paths = self._mozbuilds(reader) _, contexts = reader.read_relevant_mozbuilds(all_paths) finder = FileFinder(config.topsrcdir, find_executables=False, ignore=['obj*']) def pattern_exists(pat): return [p for p in finder.find(pat)] != [] for ctx in contexts: if not isinstance(ctx, Files): continue relsrcdir = ctx.relsrcdir if not pattern_exists(os.path.join(relsrcdir, ctx.pattern)): self.fail("The pattern '%s' in a Files() entry in " "'%s' corresponds to no files in the tree.\n" "Please update this entry." % (ctx.pattern, ctx.main_path)) test_files = ctx['IMPACTED_TESTS'].files for p in test_files: if not pattern_exists(os.path.relpath(p.full_path, config.topsrcdir)): self.fail("The pattern '%s' in a dependent tests entry " "in '%s' corresponds to no files in the tree.\n" "Please update this entry." % (p, ctx.main_path))
def test_orphan_file_patterns(self): if sys.platform == 'win32': raise unittest.SkipTest('failing on windows builds') mb = MozbuildObject.from_environment(detect_virtualenv_mozinfo=False) try: config = mb.config_environment except Exception as e: if e.message == 'config.status not available. Run configure.': raise unittest.SkipTest('failing without config.status') raise reader = BuildReader(config) all_paths = self._mozbuilds(reader) _, contexts = reader.read_relevant_mozbuilds(all_paths) finder = FileFinder(config.topsrcdir, find_executables=False, ignore=['obj*']) def pattern_exists(pat): return [p for p in finder.find(pat)] != [] for ctx in contexts: if not isinstance(ctx, Files): continue relsrcdir = ctx.relsrcdir if not pattern_exists(os.path.join(relsrcdir, ctx.pattern)): self.fail("The pattern '%s' in a Files() entry in " "'%s' corresponds to no files in the tree.\n" "Please update this entry." % (ctx.pattern, ctx.main_path)) test_files = ctx['IMPACTED_TESTS'].files for p in test_files: if not pattern_exists( os.path.relpath(p.full_path, config.topsrcdir)): self.fail("The pattern '%s' in a dependent tests entry " "in '%s' corresponds to no files in the tree.\n" "Please update this entry." % (p, ctx.main_path))