11api_dir = get_option (' prefix' ) + ' /api/'
2+ build_root = meson .project_build_root()
3+
4+ test_env = environment ()
5+ test_env.set(' PYTHONDONTWRITEBYTECODE' , ' 1' )
6+ test_env.prepend(' PYTHONPATH' , api_dir)
27python_exe = import (' python' ).find_installation(' python3' )
38
49install_subdir (meson .current_source_dir(), install_dir : ' .' )
510
611test (' api_template_help' ,
712 python_exe,
8- env : { ' PYTHONDONTWRITEBYTECODE ' : ' 1 ' } ,
13+ env : test_env ,
914 args : [api_dir + ' system_template.py' , ' -h' ])
1015
1116test (' api_show_solid_creators' ,
1217 python_exe,
13- env : { ' PYTHONDONTWRITEBYTECODE ' : ' 1 ' } ,
18+ env : test_env ,
1419 args : [api_dir + ' system_template.py' , ' -sl' ])
1520
1621# Test all solid creators
@@ -29,33 +34,37 @@ foreach volume: g4objects.keys()
2934 test (' api_show_template_code_for_' + volume,
3035 python_exe,
3136 is_parallel : false ,
32- env : { ' PYTHONDONTWRITEBYTECODE ' : ' 1 ' } ,
37+ env : test_env ,
3338 args : [api_dir + ' system_template.py' , ' -gv' , volume])
3439 test (' api_template_show_code_for_volume' + volume + ' _with_parameters_' + pars.replace(' ' , '' ),
3540 python_exe,
3641 is_parallel : false ,
37- env : { ' PYTHONDONTWRITEBYTECODE ' : ' 1 ' } ,
42+ env : test_env ,
3843 args : [api_dir + ' system_template.py' , ' -gv' , volume, ' -gvp' , pars.replace(' ' , '' )])
3944endforeach
4045
4146test (' api_show_template_code_for_G4Cons' ,
4247 python_exe,
4348 is_parallel : false ,
44- env : { ' PYTHONDONTWRITEBYTECODE ' : ' 1 ' } ,
49+ env : test_env ,
4550 args : [api_dir + ' system_template.py' , ' -gv' , ' G4Cons' , ' -silent' ])
4651
47- test_dir = meson .current_build_dir() + ' /../ test'
52+ test_dir = join_paths (build_root, ' test' )
4853test (' api_create_system' ,
4954 python_exe,
5055 is_parallel : false ,
51- env : {' PYTHONDONTWRITEBYTECODE' : ' 1' },
52- args : [api_dir + ' system_template.py' , ' -s' , ' test' ], priority : 5 )
56+ env : test_env,
57+ args : [api_dir + ' system_template.py' , ' -s' , ' test' ],
58+ workdir : test_dir,
59+ priority : 5 )
5360foreach format : [' ascii' , ' sqlite' ]
5461 test (' api_template_build_geometry_in_test_for_format_' + format,
5562 python_exe,
5663 is_parallel : false ,
57- env : {' PYTHONDONTWRITEBYTECODE' : ' 1' },
58- args : [' test.py' , ' -f' , format], workdir : test_dir, priority : - 1 )
64+ env : test_env,
65+ args : [' test.py' , ' -f' , format],
66+ workdir : test_dir,
67+ priority : - 1 )
5968 test (' api_run_gemc_for_format_' + format,
6069 gemc, args : [' test.yaml' , ' -gsystem="[{name: test, factory: ' + format + ' }]" ' ],
6170 workdir : test_dir,
@@ -71,24 +80,30 @@ foreach volume: g4objects.keys()
7180 python_main = test_name + ' .py'
7281 sub_name= ' -geo_sub=build_' + test_name
7382 geo_py = ' -write_to=geometry_test_' + volume + ' .py'
74- test_dir = meson .current_build_dir() + ' /../ ' + test_name
83+ test_dir = join_paths (build_root, test_name)
7584 pars = g4objects[volume]
7685 test (' api_create_template_system_with' + volume,
7786 python_exe,
7887 is_parallel : false ,
79- env : {' PYTHONDONTWRITEBYTECODE' : ' 1' },
80- args : [api_dir + ' system_template.py' , ' -s' , test_name], priority : 4 )
88+ env : test_env,
89+ args : [api_dir + ' system_template.py' , ' -s' , test_name],
90+ workdir : test_dir,
91+ priority : 4 )
8192 test (' api_template_replace_geometry_with' + volume,
8293 python_exe,
8394 is_parallel : false ,
84- env : {' PYTHONDONTWRITEBYTECODE' : ' 1' },
85- args : [api_dir + ' system_template.py' , ' -gv' , volume, ' -gvp' , pars, geo_py, sub_name], workdir : test_dir, priority : - 3 )
95+ env : test_env,
96+ args : [api_dir + ' system_template.py' , ' -gv' , volume, ' -gvp' , pars, geo_py, sub_name],
97+ workdir : test_dir,
98+ priority : - 3 )
8699 foreach format : [' ascii' , ' sqlite' ]
87100 test (' api_template_build_geometry_in_test_of_replacing_geometry_with' + volume + ' _with_format' + format,
88101 python_exe,
89102 is_parallel : false ,
90- env : {' PYTHONDONTWRITEBYTECODE' : ' 1' },
91- args : [python_main, ' -f' , format], workdir : test_dir, priority : - 4 )
103+ env : test_env,
104+ args : [python_main, ' -f' , format],
105+ workdir : test_dir,
106+ priority : - 4 )
92107 test (' api_run_gemc_with_replaced_geometry_using_' + volume + ' _with_format' + format,
93108 gemc,
94109 args : [yaml_file, ' -gsystem="[{name: ' + test_name + ' , factory: ' + format + ' }]" ' ],
0 commit comments