@@ -404,21 +404,21 @@ def run_test_inprocess(testdir):
404
404
405
405
# Build directory name must be the same so Ccache works over
406
406
# consecutive invocations.
407
- def create_deterministic_builddir (test : TestDef ) -> str :
407
+ def create_deterministic_builddir (test : TestDef , use_tmpdir : bool ) -> str :
408
408
import hashlib
409
409
src_dir = test .path .as_posix ()
410
410
if test .name :
411
411
src_dir += test .name
412
412
rel_dirname = 'b ' + hashlib .sha256 (src_dir .encode (errors = 'ignore' )).hexdigest ()[0 :10 ]
413
- os .mkdir ( rel_dirname )
414
- abs_pathname = os .path . join ( os . getcwd (), rel_dirname )
413
+ abs_pathname = os .path . join ( tempfile . gettempdir () if use_tmpdir else os . getcwd (), rel_dirname )
414
+ os .mkdir ( abs_pathname )
415
415
return abs_pathname
416
416
417
- def run_test (test : TestDef , extra_args , compiler , backend , flags , commands , should_fail ):
417
+ def run_test (test : TestDef , extra_args , compiler , backend , flags , commands , should_fail , use_tmp : bool ):
418
418
if test .skip :
419
419
return None
420
- with AutoDeletedDir (create_deterministic_builddir (test )) as build_dir :
421
- with AutoDeletedDir (tempfile .mkdtemp (prefix = 'i ' , dir = os .getcwd ())) as install_dir :
420
+ with AutoDeletedDir (create_deterministic_builddir (test , use_tmp )) as build_dir :
421
+ with AutoDeletedDir (tempfile .mkdtemp (prefix = 'i ' , dir = None if use_tmp else os .getcwd ())) as install_dir :
422
422
try :
423
423
return _run_test (test , build_dir , install_dir , extra_args , compiler , backend , flags , commands , should_fail )
424
424
except TestResult as r :
@@ -666,8 +666,8 @@ def have_d_compiler():
666
666
return True
667
667
return False
668
668
669
- def have_objc_compiler () :
670
- with AutoDeletedDir (tempfile .mkdtemp (prefix = 'b ' , dir = '.' )) as build_dir :
669
+ def have_objc_compiler (use_tmp : bool ) -> bool :
670
+ with AutoDeletedDir (tempfile .mkdtemp (prefix = 'b ' , dir = None if use_tmp else '.' )) as build_dir :
671
671
env = environment .Environment (None , build_dir , get_fake_options ('/' ))
672
672
try :
673
673
objc_comp = env .detect_objc_compiler (MachineChoice .HOST )
@@ -682,8 +682,8 @@ def have_objc_compiler():
682
682
return False
683
683
return True
684
684
685
- def have_objcpp_compiler () :
686
- with AutoDeletedDir (tempfile .mkdtemp (prefix = 'b ' , dir = '.' )) as build_dir :
685
+ def have_objcpp_compiler (use_tmp : bool ) -> bool :
686
+ with AutoDeletedDir (tempfile .mkdtemp (prefix = 'b ' , dir = None if use_tmp else '.' )) as build_dir :
687
687
env = environment .Environment (None , build_dir , get_fake_options ('/' ))
688
688
try :
689
689
objcpp_comp = env .detect_objcpp_compiler (MachineChoice .HOST )
@@ -734,7 +734,11 @@ def skippable(suite, test):
734
734
735
735
# Scientific libraries are skippable on certain systems
736
736
# See the discussion here: https://github.com/mesonbuild/meson/pull/6562
737
- if any ([test .endswith (x ) for x in ['17 mpi' , '25 hdf5' , '30 scalapack' ]]) and skip_scientific :
737
+ if any ([x in test for x in ['17 mpi' , '25 hdf5' , '30 scalapack' ]]) and skip_scientific :
738
+ return True
739
+
740
+ # These create OS specific tests, and need to be skippable
741
+ if any ([x in test for x in ['16 sdl' , '17 mpi' ]]):
738
742
return True
739
743
740
744
# No frameworks test should be skipped on linux CI, as we expect all
@@ -805,7 +809,7 @@ def should_skip_rust(backend: Backend) -> bool:
805
809
return True
806
810
return False
807
811
808
- def detect_tests_to_run (only : T .List [str ]) -> T .List [T .Tuple [str , T .List [TestDef ], bool ]]:
812
+ def detect_tests_to_run (only : T .List [str ], use_tmp : bool ) -> T .List [T .Tuple [str , T .List [TestDef ], bool ]]:
809
813
"""
810
814
Parameters
811
815
----------
@@ -842,8 +846,8 @@ def detect_tests_to_run(only: T.List[str]) -> T.List[T.Tuple[str, T.List[TestDef
842
846
('vala' , 'vala' , backend is not Backend .ninja or not shutil .which (os .environ .get ('VALAC' , 'valac' ))),
843
847
('rust' , 'rust' , should_skip_rust (backend )),
844
848
('d' , 'd' , backend is not Backend .ninja or not have_d_compiler ()),
845
- ('objective c' , 'objc' , backend not in (Backend .ninja , Backend .xcode ) or not have_objc_compiler ()),
846
- ('objective c++' , 'objcpp' , backend not in (Backend .ninja , Backend .xcode ) or not have_objcpp_compiler ()),
849
+ ('objective c' , 'objc' , backend not in (Backend .ninja , Backend .xcode ) or not have_objc_compiler (options . use_tmpdir )),
850
+ ('objective c++' , 'objcpp' , backend not in (Backend .ninja , Backend .xcode ) or not have_objcpp_compiler (options . use_tmpdir )),
847
851
('fortran' , 'fortran' , skip_fortran or backend != Backend .ninja ),
848
852
('swift' , 'swift' , backend not in (Backend .ninja , Backend .xcode ) or not shutil .which ('swiftc' )),
849
853
# CUDA tests on Windows: use Ninja backend: python run_project_tests.py --only cuda --backend ninja
@@ -866,16 +870,16 @@ def detect_tests_to_run(only: T.List[str]) -> T.List[T.Tuple[str, T.List[TestDef
866
870
867
871
def run_tests (all_tests : T .List [T .Tuple [str , T .List [TestDef ], bool ]],
868
872
log_name_base : str , failfast : bool ,
869
- extra_args : T .List [str ]) -> T .Tuple [int , int , int ]:
873
+ extra_args : T .List [str ], use_tmp : bool ) -> T .Tuple [int , int , int ]:
870
874
global logfile
871
875
txtname = log_name_base + '.txt'
872
876
with open (txtname , 'w' , encoding = 'utf-8' , errors = 'ignore' ) as lf :
873
877
logfile = lf
874
- return _run_tests (all_tests , log_name_base , failfast , extra_args )
878
+ return _run_tests (all_tests , log_name_base , failfast , extra_args , use_tmp )
875
879
876
880
def _run_tests (all_tests : T .List [T .Tuple [str , T .List [TestDef ], bool ]],
877
881
log_name_base : str , failfast : bool ,
878
- extra_args : T .List [str ]) -> T .Tuple [int , int , int ]:
882
+ extra_args : T .List [str ], use_tmp : bool ) -> T .Tuple [int , int , int ]:
879
883
global stop , executor , futures , system_compiler
880
884
xmlname = log_name_base + '.xml'
881
885
junit_root = ET .Element ('testsuites' )
@@ -929,7 +933,7 @@ def _run_tests(all_tests: T.List[T.Tuple[str, T.List[TestDef], bool]],
929
933
930
934
t .skip = skipped or t .skip
931
935
result = executor .submit (run_test , t , extra_args + suite_args + t .args ,
932
- system_compiler , backend , backend_flags , commands , should_fail )
936
+ system_compiler , backend , backend_flags , commands , should_fail , use_tmp )
933
937
futures .append ((testname , t , result ))
934
938
for (testname , t , result ) in futures :
935
939
sys .stdout .flush ()
@@ -1047,7 +1051,7 @@ def check_meson_commands_work(options):
1047
1051
global backend , compile_commands , test_commands , install_commands
1048
1052
testdir = PurePath ('test cases' , 'common' , '1 trivial' ).as_posix ()
1049
1053
meson_commands = mesonlib .python_command + [get_meson_script ()]
1050
- with AutoDeletedDir (tempfile .mkdtemp (prefix = 'b ' , dir = '.' )) as build_dir :
1054
+ with AutoDeletedDir (tempfile .mkdtemp (prefix = 'b ' , dir = None if options . use_tmpdir else '.' )) as build_dir :
1051
1055
print ('Checking that configuring works...' )
1052
1056
gen_cmd = meson_commands + [testdir , build_dir ] + backend_flags + options .extra_args
1053
1057
pc , o , e = Popen_safe (gen_cmd )
@@ -1072,7 +1076,7 @@ def check_meson_commands_work(options):
1072
1076
def detect_system_compiler (options ):
1073
1077
global system_compiler , compiler_id_map
1074
1078
1075
- with AutoDeletedDir (tempfile .mkdtemp (prefix = 'b ' , dir = '.' )) as build_dir :
1079
+ with AutoDeletedDir (tempfile .mkdtemp (prefix = 'b ' , dir = None if options . use_tmpdir else '.' )) as build_dir :
1076
1080
fake_opts = get_fake_options ('/' )
1077
1081
if options .cross_file :
1078
1082
fake_opts .cross_file = [options .cross_file ]
@@ -1139,6 +1143,7 @@ def get_version(t: dict) -> str:
1139
1143
help = 'Not used, only here to simplify run_tests.py' )
1140
1144
parser .add_argument ('--only' , help = 'name of test(s) to run' , nargs = '+' , choices = ALL_TESTS )
1141
1145
parser .add_argument ('--cross-file' , action = 'store' , help = 'File describing cross compilation environment.' )
1146
+ parser .add_argument ('--use-tmpdir' , action = 'store_true' , help = 'Use tmp directory for temporary files.' )
1142
1147
options = parser .parse_args ()
1143
1148
if options .cross_file :
1144
1149
options .extra_args += ['--cross-file' , options .cross_file ]
@@ -1152,8 +1157,8 @@ def get_version(t: dict) -> str:
1152
1157
check_format ()
1153
1158
check_meson_commands_work (options )
1154
1159
try :
1155
- all_tests = detect_tests_to_run (options .only )
1156
- (passing_tests , failing_tests , skipped_tests ) = run_tests (all_tests , 'meson-test-run' , options .failfast , options .extra_args )
1160
+ all_tests = detect_tests_to_run (options .only , options . use_tmpdir )
1161
+ (passing_tests , failing_tests , skipped_tests ) = run_tests (all_tests , 'meson-test-run' , options .failfast , options .extra_args , options . use_tmpdir )
1157
1162
except StopException :
1158
1163
pass
1159
1164
print ('\n Total passed tests:' , green (str (passing_tests )))
0 commit comments