mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1184405 - Add a test to fail the build if file patterns are present in test dependency annotations that don't correspond to any files on disk. r=gps
This commit is contained in:
parent
67b90fc80e
commit
4be656c8d4
@ -5,11 +5,14 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from mozunit import main
|
||||
|
||||
from mozbuild.base import MozbuildObject
|
||||
from mozpack.files import FileFinder
|
||||
from mozbuild.frontend.context import Files
|
||||
from mozbuild.frontend.reader import (
|
||||
BuildReader,
|
||||
EmptyConfig,
|
||||
@ -66,5 +69,45 @@ class TestMozbuildReading(unittest.TestCase):
|
||||
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
|
||||
|
||||
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))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user