Skip to content

Commit

Permalink
CI: propose timeout in forks testing to improve test robustness
Browse files Browse the repository at this point in the history
The described problem is Windows Python 3.12 test timeouts equinor#1229
but it appears to occur randomly.  This solution is a bit of a
"fumbling in the dark, and cross fingers".
  • Loading branch information
jcrivenaes committed Sep 9, 2024
1 parent 1a02b1c commit 46564b3
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions tests/test_surface/test_forks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# coding: utf-8

import logging
import subprocess

import xtgeo

xtg = xtgeo.common.XTGeoDialog()
logger = xtg.basiclogger(__name__)
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


def test_surface_forks():
Expand All @@ -17,6 +14,18 @@ def test_surface_forks():
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
stdout, stderr = process.communicate()
ret_code = process.wait()
assert ret_code == 0, stderr
try:
stdout, stderr = process.communicate(timeout=60) # timeout to prevent hanging
ret_code = process.returncode
except subprocess.TimeoutExpired:
process.kill()
stdout, stderr = process.communicate()
ret_code = -1 # Use a custom return code for timeouts

# Log more information for debugging
logger.info("Return code: %d", ret_code)
logger.info("STDOUT: %s", stdout.decode())
logger.info("STDERR: %s", stderr.decode())

assert ret_code == 0, f"Subprocess failed with exit code {ret_code}\n"
f"STDOUT: {stdout.decode()}\nSTDERR: {stderr.decode()}"

0 comments on commit 46564b3

Please sign in to comment.