@ -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 ] ] ,