11import contextlib
22import typing
3+ import platform
34import uuid
45import pytest
56import simvue
@@ -33,12 +34,12 @@ def completion_callback(*_, trigger=trigger, **__):
3334 run = simvue .Run ()
3435 run .init (
3536 f"test_executor_{ 'success' if successful else 'fail' } " ,
36- tags = ["simvue_client_unit_tests" , request .node .name .replace ("[" , "_" ).replace ("]" , "_" )],
37+ tags = [platform . system (), "simvue_client_unit_tests" , request .node .name .replace ("[" , "_" ).replace ("]" , "_" )],
3738 folder = f"/simvue_unit_testing/{ folder_id } " ,
3839 retention_period = "2 mins"
3940 )
4041 run .add_process (
41- identifier = f"test_add_process_{ 'success' if successful else 'fail' } " ,
42+ identifier = f"test_add_process_{ 'success' if successful else 'fail' } _ { os . environ . get ( "PYTEST_XDIST_WORKER" , 0 ) } " ,
4243 c = f"exit { 0 if successful else 1 } " ,
4344 executable = "bash" if sys .platform != "win32" else "powershell" ,
4445 completion_callback = completion_callback
@@ -71,7 +72,7 @@ def test_executor_multiprocess(request: pytest.FixtureRequest) -> None:
7172 run .init (
7273 "test_executor_multiprocess" ,
7374 folder = f"/simvue_unit_testing/{ folder_id } " ,
74- tags = ["simvue_client_tests" , request .node .name ]
75+ tags = [platform . system (), "simvue_client_tests" , request .node .name ]
7576 )
7677
7778 for i in range (10 ):
@@ -82,7 +83,7 @@ def callback(*_, evts=events, ident=i, **__):
8283 callbacks [i ] = callback
8384 out_file = pathlib .Path (tempd ).joinpath (f"out_file_{ i } .dat" )
8485 run .add_process (
85- f"cmd_{ i } " ,
86+ f"cmd_{ i } _ { os . environ . get ( "PYTEST_XDIST_WORKER" , 0 ) } " ,
8687 executable = "bash" ,
8788 c = "for i in {0..10}; do sleep 0.5; echo $i >> " + f"{ out_file } ; done" ,
8889 completion_trigger = triggers [i ],
@@ -136,10 +137,10 @@ def test_add_process_command_assembly(request: pytest.FixtureRequest) -> None:
136137 run .init (
137138 "test_advanced_executor" ,
138139 folder = f"/simvue_unit_testing/{ folder_id } " ,
139- tags = ["simvue_client_tests" , request .node .name ]
140+ tags = [platform . system (), "simvue_client_tests" , request .node .name ]
140141 )
141142 run .add_process (
142- identifier = (exe_id := "advanced_run " ),
143+ identifier = (exe_id := f"advanced_run_ { os . environ . get ( "PYTEST_XDIST_WORKER" , 0 ) } " ),
143144 executable = "python" ,
144145 script = f"{ code_file } " ,
145146 input_file = f"{ in_file } " ,
@@ -162,10 +163,10 @@ def completion_callback(*_, success: dict[str, bool]=success, **__):
162163 run .init (
163164 "test_completion_callbacks_var_change" ,
164165 folder = f"/simvue_unit_testing/{ folder_id } " ,
165- tags = ["simvue_client_tests" , request .node .name ]
166+ tags = [platform . system (), "simvue_client_tests" , request .node .name ]
166167 )
167168 run .add_process (
168- identifier = "test_completion_callbacks_var_change " ,
169+ identifier = f"test_completion_callbacks_var_change_ { os . environ . get ( "PYTEST_XDIST_WORKER" , 0 ) } " ,
169170 executable = "bash" ,
170171 c = "exit 0" ,
171172 completion_callback = completion_callback
@@ -190,10 +191,10 @@ def test_completion_trigger_set(request: pytest.FixtureRequest) -> None:
190191 run .init (
191192 "test_completion_trigger_set" ,
192193 folder = f"/simvue_unit_testing/{ folder_id } " ,
193- tags = ["simvue_client_tests" , request .node .name ]
194+ tags = [platform . system (), "simvue_client_tests" , request .node .name ]
194195 )
195196 run .add_process (
196- identifier = "test_completion_trigger_set " ,
197+ identifier = f"test_completion_trigger_set_ { os . environ . get ( "PYTEST_XDIST_WORKER" , 0 ) } " ,
197198 executable = "bash" ,
198199 c = "exit 0" ,
199200 completion_trigger = trigger
@@ -221,10 +222,10 @@ def completion_callback(*_, trigger=trigger, **__):
221222 run .init (
222223 "test_completion_callbacks_trigger_set" ,
223224 folder = "/simvue_unit_testing" ,
224- tags = ["simvue_client_tests" , request .node .name ]
225+ tags = [platform . system (), "simvue_client_tests" , request .node .name ]
225226 )
226227 run .add_process (
227- identifier = "test_completion_callbacks_trigger_set " ,
228+ identifier = f"test_completion_callbacks_trigger_set_ { os . environ . get ( "PYTEST_XDIST_WORKER" , 0 ) } " ,
228229 executable = "bash" ,
229230 c = "exit 0" ,
230231 completion_callback = completion_callback
0 commit comments