Skip to content

Commit bd62d59

Browse files
committed
using python test env correctly in api and tests
1 parent 1b2efb2 commit bd62d59

5 files changed

Lines changed: 52 additions & 27 deletions

File tree

.github/workflows/sanitize.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- name: Checkout
5757
uses: actions/checkout@v4
5858

59-
- name: Sanitizer ${{ matrix.sanitizer }}
59+
- name: Sanitizer - ${{ matrix.sanitizer }}
6060
shell: bash
6161
run: |
6262
set -euo pipefail
@@ -88,7 +88,7 @@ jobs:
8888
fi
8989
9090
- name: Upload sanitizer logs (artifact)
91-
if: ${{ always() }}
91+
if: ${{ always() }} # run regardless of earlier step outcomes
9292
uses: actions/upload-artifact@v4
9393
with:
9494
name: logs-${{ matrix.baseos }}-${{ matrix.arch }}-${{ matrix.sanitizer }}
@@ -101,6 +101,9 @@ jobs:
101101
if: ${{ always() }}
102102
needs: [ build-with-sanitizer ]
103103
runs-on: ubuntu-latest
104+
strategy:
105+
fail-fast: false
106+
matrix: ${{ fromJSON(needs.discover.outputs.matrix_sanitize) }}
104107
steps:
105108
- name: Fail if any matrix entry failed
106109
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}

api/meson.build

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
api_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)
27
python_exe = import('python').find_installation('python3')
38

49
install_subdir(meson.current_source_dir(), install_dir : '.')
510

611
test('api_template_help',
712
python_exe,
8-
env : {'PYTHONDONTWRITEBYTECODE': '1'},
13+
env: test_env,
914
args : [api_dir + 'system_template.py', '-h'])
1015

1116
test('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(' ', '')])
3944
endforeach
4045

4146
test('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')
4853
test('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)
5360
foreach 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 + '}]" '],

ci/env.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ fi
105105

106106

107107
export GEMC=${SIM_HOME}/gemc/dev
108+
109+
108110
# detect cores and cap at 16
109111
cores=$(getconf _NPROCESSORS_ONLN 2>/dev/null || nproc)
110112
jobs=$((cores < 16 ? cores : 16))

examples/meson.build

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
examples_dir = get_option('prefix') + '/examples/'
2+
test_env = environment()
3+
test_env.set('PYTHONDONTWRITEBYTECODE', '1')
4+
test_env.prepend('PYTHONPATH', api_dir)
5+
26
test_outdir = meson.current_build_dir()
37
sql_db = get_option('prefix') + '/examples/gemc.db'
48

@@ -40,7 +44,7 @@ foreach branch : examples_map.keys()
4044
args : [example_dir + example + '.py', '-f', format, '-sql', sql_db, '-v', variation], # the sql flag is ignored for ascii format
4145
workdir : example_dir,
4246
is_parallel : false,
43-
env : { 'PYTHONDONTWRITEBYTECODE' : '1' },
47+
env: test_env,
4448
priority : 10)
4549
test(run_test_name_asci,
4650
gemc,
@@ -68,7 +72,7 @@ foreach branch : examples_map.keys()
6872
args : [example_dir + example + '.py', '-f', format, '-sql', sql_db, '-r', run_value], # the sql flag is ignored for ascii format
6973
workdir : example_dir,
7074
is_parallel : false,
71-
env : { 'PYTHONDONTWRITEBYTECODE' : '1' },
75+
env: test_env,
7276
priority : 9)
7377
test(run_test_name_asci,
7478
gemc,

meson.build

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ if get_option('buildtype') == 'debug'
2020
add_project_arguments('-O2', language : 'cpp')
2121
endif
2222

23+
api_dir = get_option('prefix') + '/api/'
24+
test_env = environment()
25+
test_env.set('PYTHONDONTWRITEBYTECODE', '1')
26+
test_env.prepend('PYTHONPATH', api_dir)
27+
28+
2329
project_description = 'GEMC (GEant Monte-Carlo) is a program based on Geant4 to simulate the passage of particles through matter. '
2430

2531
# init lists
@@ -28,7 +34,6 @@ LD = []
2834
all_libs = []
2935
all_includes = []
3036
empty_dict = { 'na' : [''] }
31-
all_lib_names = [] # Store library names as linker flags
3237
lib_target_maps = {}
3338
python_exe = import('python').find_installation('python3')
3439

@@ -106,7 +111,6 @@ foreach L : LD
106111
)
107112
if not all_libs.contains(this_library)
108113
all_libs += this_library
109-
all_lib_names += 'lib' + this_lib_name + '.a' # Add as linker flag
110114
lib_target_maps += {this_lib_name: this_library}
111115
endif
112116
endif
@@ -171,7 +175,7 @@ foreach L : LD
171175
args : [geo_python_script],
172176
workdir : examples_dir,
173177
is_parallel: false,
174-
env : { 'PYTHONDONTWRITEBYTECODE' : '1' },
178+
env: test_env,
175179
priority : 20)
176180
endforeach
177181
endif
@@ -193,7 +197,6 @@ foreach L : LD
193197
dependencies : this_deps,
194198
include_directories : all_includes + this_lib_name + additional_includes,
195199
link_with : all_libs,
196-
# link_args : all_lib_names
197200
override_options : ['b_pie=true']
198201
)
199202
test(name,
@@ -225,7 +228,6 @@ gemc = executable(
225228
dependencies : [yaml_cpp_dep, qt6_deps, clhep_deps, geant4_deps, ogl_deps, assimp_dep],
226229
include_directories : all_includes,
227230
link_with : all_libs,
228-
link_args : all_lib_names,
229231
override_options : ['b_pie=true']
230232
)
231233

@@ -306,5 +308,4 @@ post_install = run_command('echo', 'Installation completed!', check : true)
306308
# requires : ['yaml-cpp', 'qt6', 'clhep', 'geant4'], # pkg-config dependencies only
307309
# version : meson.project_version(),
308310
# # libraries : all_libs
309-
# # link_args : all_lib_names
310311
#)

0 commit comments

Comments
 (0)