Skip to content

Commit 77977d0

Browse files
committed
Add multiple process add test
1 parent 4870a3b commit 77977d0

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

simvue/executor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def _execute_process(
4747
)
4848

4949
_status_code = _result.wait()
50-
5150
with open(f"{runner_name}_{proc_id}.err") as err:
5251
std_err[proc_id] = err.read()
5352

tests/refactor/test_executor.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import sys
55
import tempfile
66
import pathlib
7+
import os
78
import multiprocessing
89

910

@@ -38,6 +39,32 @@ def test_executor_add_process(
3839
run.close()
3940

4041

42+
@pytest.mark.executor
43+
def test_executor_multiprocess(request: pytest.FixtureRequest) -> None:
44+
with tempfile.TemporaryDirectory() as tempd:
45+
with simvue.Run() as run:
46+
run.init(
47+
"test_executor_multiprocess",
48+
folder="/simvue_unit_testing",
49+
tags=["simvue_client_tests", request.node.name]
50+
)
51+
52+
for i in range(10):
53+
out_file = pathlib.Path(tempd).joinpath(f"out_file_{i}.dat")
54+
run.add_process(
55+
f"cmd_{i}",
56+
executable="bash",
57+
c="for i in {0..10}; do sleep 0.5; echo $i >> "+ f"{out_file}; done"
58+
)
59+
time.sleep(1)
60+
for i in range(10):
61+
out_file = pathlib.Path(tempd).joinpath(f"out_file_{i}.dat")
62+
assert out_file.exists()
63+
for i in range(10):
64+
os.remove(f"test_executor_multiprocess_cmd_{i}.err")
65+
os.remove(f"test_executor_multiprocess_cmd_{i}.out")
66+
67+
4168
@pytest.mark.executor
4269
def test_add_process_command_assembly(request: pytest.FixtureRequest) -> None:
4370
with tempfile.TemporaryDirectory() as tempd:

0 commit comments

Comments
 (0)