Skip to content

Commit

Permalink
Deduce nonzero returncode from eclrun std output
Browse files Browse the repository at this point in the history
runeclipse from subscript was used for this earlier, and this had code
to parse the stdout/stderr files for Error counts.
  • Loading branch information
berland committed Feb 11, 2025
1 parent 7477100 commit cc922a2
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import contextlib
import subprocess
import time
from os import getcwd
Expand Down Expand Up @@ -29,11 +30,21 @@ def run_simulator(simulator, data_file_path):
[simulator] + simulator_option + [data_file_path],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
check=False,
)
if (
"eclrun" in simulator
and _error_count_from_ecl_stdout(
result.stdout.decode() + result.stderr.decode()
)
> 0
):
# eclrun returns returncode 0 matter what.
result.returncode = 1

if (
result.returncode != 0
and "eclipse" in simulator
and "ecl" in simulator
and "LICENSE FAILURE" in result.stdout.decode() + result.stderr.decode()
):
print("Eclipse failed due to license server issues. Retrying in 30 seconds.")
Expand All @@ -48,3 +59,12 @@ def run_simulator(simulator, data_file_path):
print(result.stdout.decode())
print(result.stderr.decode())
raise AssertionError(f"reservoir simulator failed in {getcwd()}")


def _error_count_from_ecl_stdout(stdouterr: str):
error_count = 0
for line in stdouterr.splitlines():
if line.startswith(" Errors"):
with contextlib.suppress(ValueError):
error_count = int(line.split("Errors")[1].strip())
return error_count

0 comments on commit cc922a2

Please sign in to comment.