23
23
import subprocess
24
24
from mesonbuild import mesonlib
25
25
from mesonbuild .coredata import version as meson_version
26
+ from pathlib import Path
27
+ import json
28
+ import os
26
29
27
30
28
- def runtests (cross_file , failfast , cross_only ):
29
- tests = ['--only' , 'common' ]
31
+ def runtests (cross_file , failfast , cross_only , test_list , env = None ):
32
+ tests = ['--only' ] + test_list
30
33
if not cross_only :
31
34
tests .append ('native' )
32
35
cmd = mesonlib .python_command + ['run_project_tests.py' , '--backend' , 'ninja' ]
@@ -36,15 +39,24 @@ def runtests(cross_file, failfast, cross_only):
36
39
cmd += ['--cross-file' , cross_file ]
37
40
if cross_only :
38
41
cmd += ['--native-file' , 'cross/none.txt' ]
39
- return subprocess .call (cmd )
42
+ return subprocess .call (cmd , env = env )
40
43
41
44
def main ():
42
45
parser = argparse .ArgumentParser ()
43
46
parser .add_argument ('--failfast' , action = 'store_true' )
44
47
parser .add_argument ('--cross-only' , action = 'store_true' )
45
48
parser .add_argument ('cross_file' )
46
49
options = parser .parse_args ()
47
- return runtests (options .cross_file , options .failfast , options .cross_only )
50
+ cf_path = Path (options .cross_file )
51
+ try :
52
+ data = json .loads (cf_path .read_text ())
53
+ real_cf = cf_path .resolve ().parent / data ['file' ]
54
+ assert real_cf .exists ()
55
+ env = os .environ .copy ()
56
+ env .update (data ['env' ])
57
+ return runtests (real_cf .as_posix (), options .failfast , options .cross_only , data ['tests' ], env = env )
58
+ except Exception :
59
+ return runtests (options .cross_file , options .failfast , options .cross_only , ['common' ])
48
60
49
61
if __name__ == '__main__' :
50
62
print ('Meson build system' , meson_version , 'Cross Tests' )
0 commit comments