Merge pull request #7172 from jon-turney/test-output-check-mandatory

Make the expected output check mandatory for failing-meson and warning-meson tests
pull/7186/head
Jussi Pakkanen 5 years ago committed by GitHub
commit 0871b1032c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 83
      run_project_tests.py
  2. 7
      test cases/failing/100 fallback consistency/test.json
  3. 7
      test cases/failing/101 no native compiler/test.json
  4. 7
      test cases/failing/102 subdir parse error/test.json
  5. 7
      test cases/failing/103 invalid option file/test.json
  6. 7
      test cases/failing/104 no lang/test.json
  7. 7
      test cases/failing/105 no glib-compile-resources/test.json
  8. 7
      test cases/failing/36 pkgconfig dependency impossible conditions/test.json
  9. 7
      test cases/failing/67 subproj different versions/test.json
  10. 7
      test cases/failing/84 gtest dependency with version/test.json
  11. 7
      test cases/failing/98 fallback consistency/test.json

@ -594,17 +594,15 @@ def _run_test(test: TestDef, test_build_dir: str, install_dir: str, extra_args,
return testresult return testresult
def gather_tests(testdir: Path) -> T.List[TestDef]: def gather_tests(testdir: Path, stdout_mandatory: bool) -> T.List[TestDef]:
tests = [t.name for t in testdir.iterdir() if t.is_dir()] tests = [t.name for t in testdir.iterdir() if t.is_dir()]
tests = [t for t in tests if not t.startswith('.')] # Filter non-tests files (dot files, etc) tests = [t for t in tests if not t.startswith('.')] # Filter non-tests files (dot files, etc)
test_defs = [TestDef(testdir / t, None, []) for t in tests] test_defs = [TestDef(testdir / t, None, []) for t in tests]
all_tests = [] # type: T.List[TestDef] all_tests = [] # type: T.List[TestDef]
for t in test_defs: for t in test_defs:
test_def = {}
test_def_file = t.path / 'test.json' test_def_file = t.path / 'test.json'
if not test_def_file.is_file(): if test_def_file.is_file():
all_tests += [t]
continue
test_def = json.loads(test_def_file.read_text()) test_def = json.loads(test_def_file.read_text())
# Handle additional environment variables # Handle additional environment variables
@ -623,6 +621,8 @@ def gather_tests(testdir: Path) -> T.List[TestDef]:
# Handle expected output # Handle expected output
stdout = test_def.get('stdout', []) stdout = test_def.get('stdout', [])
if stdout_mandatory and not stdout:
raise RuntimeError("{} must contain a non-empty stdout key".format(test_def_file))
# Handle the do_not_set_opts list # Handle the do_not_set_opts list
do_not_set_opts = test_def.get('do_not_set_opts', []) # type: T.List[str] do_not_set_opts = test_def.get('do_not_set_opts', []) # type: T.List[str]
@ -897,45 +897,50 @@ def detect_tests_to_run(only: T.List[str], use_tmp: bool) -> T.List[T.Tuple[str,
shutil.which('pgfortran') or shutil.which('pgfortran') or
shutil.which('ifort')) shutil.which('ifort'))
# Name, subdirectory, skip condition. class TestCategory:
def __init__(self, category: str, subdir: str, skip: bool = False, stdout_mandatory: bool = False):
self.category = category # category name
self.subdir = subdir # subdirectory
self.skip = skip # skip condition
self.stdout_mandatory = stdout_mandatory # expected stdout is mandatory for tests in this categroy
all_tests = [ all_tests = [
('cmake', 'cmake', not shutil.which('cmake') or (os.environ.get('compiler') == 'msvc2015' and under_ci)), TestCategory('cmake', 'cmake', not shutil.which('cmake') or (os.environ.get('compiler') == 'msvc2015' and under_ci)),
('common', 'common', False), TestCategory('common', 'common'),
('warning-meson', 'warning', False), TestCategory('warning-meson', 'warning', stdout_mandatory=True),
('failing-meson', 'failing', False), TestCategory('failing-meson', 'failing', stdout_mandatory=True),
('failing-build', 'failing build', False), TestCategory('failing-build', 'failing build'),
('failing-test', 'failing test', False), TestCategory('failing-test', 'failing test'),
('keyval', 'keyval', False), TestCategory('keyval', 'keyval'),
TestCategory('platform-osx', 'osx', not mesonlib.is_osx()),
('platform-osx', 'osx', not mesonlib.is_osx()), TestCategory('platform-windows', 'windows', not mesonlib.is_windows() and not mesonlib.is_cygwin()),
('platform-windows', 'windows', not mesonlib.is_windows() and not mesonlib.is_cygwin()), TestCategory('platform-linux', 'linuxlike', mesonlib.is_osx() or mesonlib.is_windows()),
('platform-linux', 'linuxlike', mesonlib.is_osx() or mesonlib.is_windows()), TestCategory('java', 'java', backend is not Backend.ninja or mesonlib.is_osx() or not have_java()),
TestCategory('C#', 'csharp', skip_csharp(backend)),
('java', 'java', backend is not Backend.ninja or mesonlib.is_osx() or not have_java()), TestCategory('vala', 'vala', backend is not Backend.ninja or not shutil.which(os.environ.get('VALAC', 'valac'))),
('C#', 'csharp', skip_csharp(backend)), TestCategory('rust', 'rust', should_skip_rust(backend)),
('vala', 'vala', backend is not Backend.ninja or not shutil.which(os.environ.get('VALAC', 'valac'))), TestCategory('d', 'd', backend is not Backend.ninja or not have_d_compiler()),
('rust', 'rust', should_skip_rust(backend)), TestCategory('objective c', 'objc', backend not in (Backend.ninja, Backend.xcode) or not have_objc_compiler(options.use_tmpdir)),
('d', 'd', backend is not Backend.ninja or not have_d_compiler()), TestCategory('objective c++', 'objcpp', backend not in (Backend.ninja, Backend.xcode) or not have_objcpp_compiler(options.use_tmpdir)),
('objective c', 'objc', backend not in (Backend.ninja, Backend.xcode) or not have_objc_compiler(options.use_tmpdir)), TestCategory('fortran', 'fortran', skip_fortran or backend != Backend.ninja),
('objective c++', 'objcpp', backend not in (Backend.ninja, Backend.xcode) or not have_objcpp_compiler(options.use_tmpdir)), TestCategory('swift', 'swift', backend not in (Backend.ninja, Backend.xcode) or not shutil.which('swiftc')),
('fortran', 'fortran', skip_fortran or backend != Backend.ninja),
('swift', 'swift', backend not in (Backend.ninja, Backend.xcode) or not shutil.which('swiftc')),
# CUDA tests on Windows: use Ninja backend: python run_project_tests.py --only cuda --backend ninja # CUDA tests on Windows: use Ninja backend: python run_project_tests.py --only cuda --backend ninja
('cuda', 'cuda', backend not in (Backend.ninja, Backend.xcode) or not shutil.which('nvcc')), TestCategory('cuda', 'cuda', backend not in (Backend.ninja, Backend.xcode) or not shutil.which('nvcc')),
('python3', 'python3', backend is not Backend.ninja), TestCategory('python3', 'python3', backend is not Backend.ninja),
('python', 'python', backend is not Backend.ninja), TestCategory('python', 'python', backend is not Backend.ninja),
('fpga', 'fpga', shutil.which('yosys') is None), TestCategory('fpga', 'fpga', shutil.which('yosys') is None),
('frameworks', 'frameworks', False), TestCategory('frameworks', 'frameworks'),
('nasm', 'nasm', False), TestCategory('nasm', 'nasm'),
('wasm', 'wasm', shutil.which('emcc') is None or backend is not Backend.ninja), TestCategory('wasm', 'wasm', shutil.which('emcc') is None or backend is not Backend.ninja),
] ]
names = [t[0] for t in all_tests] categories = [t.category for t in all_tests]
assert names == ALL_TESTS, 'argparse("--only", choices=ALL_TESTS) need to be updated to match all_tests names' assert categories == ALL_TESTS, 'argparse("--only", choices=ALL_TESTS) need to be updated to match all_tests categories'
if only: if only:
ind = [names.index(o) for o in only] all_tests = [t for t in all_tests if t.category in only]
all_tests = [all_tests[i] for i in ind]
gathered_tests = [(name, gather_tests(Path('test cases', subdir)), skip) for name, subdir, skip in all_tests] gathered_tests = [(t.category, gather_tests(Path('test cases', t.subdir), t.stdout_mandatory), t.skip) for t in all_tests]
return gathered_tests return gathered_tests
def run_tests(all_tests: T.List[T.Tuple[str, T.List[TestDef], bool]], def run_tests(all_tests: T.List[T.Tuple[str, T.List[TestDef], bool]],

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/100 fallback consistency/meson.build:7:0: ERROR: Inconsistency: Subproject has overridden the dependency with another variable than 'dep2'"
}
]
}

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/101 no native compiler/meson.build:12:0: ERROR: No host machine compiler for \"main.c\""
}
]
}

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/102 subdir parse error/subdir/meson.build:1:0: ERROR: Plusassignment target must be an id."
}
]
}

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/103 invalid option file/meson_options.txt:1:0: ERROR: lexer"
}
]
}

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/104 no lang/meson.build:2:0: ERROR: No host machine compiler for \"main.c\""
}
]
}

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/105 no glib-compile-resources/meson.build:8:0: ERROR: Could not execute glib-compile-resources."
}
]
}

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/36 pkgconfig dependency impossible conditions/meson.build:7:0: ERROR: Dependency 'zlib' was already checked and was not found"
}
]
}

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/67 subproj different versions/subprojects/b/meson.build:3:0: ERROR: Dependency 'c' was already checked and was not found"
}
]
}

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/84 gtest dependency with version/meson.build:8:0: ERROR: Dependency 'gtest' was already checked and was not found"
}
]
}

@ -0,0 +1,7 @@
{
"stdout": [
{
"line": "test cases/failing/98 fallback consistency/meson.build:4:0: ERROR: Inconsistency: Subproject has overridden the dependency with another variable than 'dep2'"
}
]
}
Loading…
Cancel
Save