Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/generate_reference_results_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,14 @@ jobs:
name: system_tests_run_${{ github.run_id }}_${{ github.run_attempt }}_reference_full
path: |
runs/*
- name: Archive main log files
- name: Archive system test logs (combined + per-stage)
uses: actions/upload-artifact@v7
with:
name: system_tests_run_${{ github.run_id }}_${{ github.run_attempt }}_reference_logs
path: |
runs/*/system-tests-stdout.log
runs/*/system-tests-stderr.log
runs/*/system-tests-build.log
runs/*/system-tests-solver.log
runs/*/system-tests-fieldcompare.log
runs/*/*/system-tests_*.log
5 changes: 4 additions & 1 deletion .github/workflows/run_testsuite_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,16 @@ jobs:
name: system_tests_run_${{ github.run_id }}_${{ github.run_attempt }}_full
path: |
runs/*
- name: Archive main log files
- name: Archive system test logs (combined + per-stage)
uses: actions/upload-artifact@v7
with:
name: system_tests_run_${{ github.run_id }}_${{ github.run_attempt }}_logs
path: |
runs/*/system-tests-stdout.log
runs/*/system-tests-stderr.log
runs/*/system-tests-build.log
runs/*/system-tests-solver.log
runs/*/system-tests-fieldcompare.log
runs/*/*/system-tests_*.log
- name: tidy up the docker
run: |
Expand Down
1 change: 1 addition & 0 deletions changelog-entries/801.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- System tests now write logs during each run (build, solver, fieldcompare), including `system-tests-build.log`, `system-tests-solver.log`, and `system-tests-fieldcompare.log`, so failures can be debugged before a test finishes. Console output is easier to scan in local runs and GitHub Actions (fixes [#790](https://github.com/precice/tutorials/issues/790)).
57 changes: 52 additions & 5 deletions tools/tests/systemtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@
from metadata_parser.metdata import Tutorials, Case
import logging
import time
import os
import sys
from paths import PRECICE_TUTORIAL_DIR, PRECICE_TESTS_RUN_DIR, PRECICE_TESTS_DIR


class _ConsoleLogFormatter(logging.Formatter):
"""Omit level prefix for INFO/DEBUG; keep it for warnings and errors."""

def format(self, record: logging.LogRecord) -> str:
if record.levelno >= logging.WARNING:
return f"{record.levelname}: {record.getMessage()}"
return record.getMessage()


def main():
parser = argparse.ArgumentParser(description='systemtest')

Expand All @@ -29,11 +40,30 @@ def main():
# Parse the command-line arguments
args = parser.parse_args()

# Configure logging based on the provided log level
logging.basicConfig(level=args.log_level, format='%(levelname)s: %(message)s')
# Configure logging: no "INFO:" prefix on routine messages (#790)
handler = logging.StreamHandler()
handler.setFormatter(_ConsoleLogFormatter())
logging.basicConfig(level=args.log_level, handlers=[handler])

print(f"Using log-level: {args.log_level}")

gh_actions = os.environ.get("GITHUB_ACTIONS", "").lower() == "true"
ansi_colors = sys.stdout.isatty() and os.environ.get("TERM", "") not in {"", "dumb"}

def _style(text: str, color_code: int | None) -> str:
if not ansi_colors or color_code is None:
return text
return f"\x1b[{color_code}m{text}\x1b[0m"

def _group_start(title: str) -> None:
# Only apply folding markers on GitHub actions.
if gh_actions:
print(f"::group::{title}")

def _group_end() -> None:
if gh_actions:
print("::endgroup::")

systemtests_to_run = []
available_tutorials = Tutorials.from_path(PRECICE_TUTORIAL_DIR)

Expand Down Expand Up @@ -72,17 +102,34 @@ def main():
if not systemtests_to_run:
raise RuntimeError("Did not find any Systemtests to execute.")

logging.info(f"About to run the following systemtest in the directory {run_directory}:\n {systemtests_to_run}")
total = len(systemtests_to_run)
logging.info(
f"About to run {total} systemtest(s) in the directory {run_directory}:\n {systemtests_to_run}")

results = []
for number, systemtest in enumerate(systemtests_to_run, start=1):
logging.info(f"Started running {systemtest}, {number}/{len(systemtests_to_run)}")
print()
test_header = f"[{number}/{total}] {systemtest}"
_group_start(test_header)
print("=" * 80)
logging.info(f"[{number}/{total}] Started {systemtest}")
t = time.perf_counter()
result = systemtest.run(run_directory)
elapsed_time = time.perf_counter() - t
logging.info(f"Running {systemtest} took {elapsed_time:^.1f} seconds")

if result.success:
status_label = _style("✅ PASS", 32)
else:
status_label = _style("❌ FAIL", 31)

logging.info(
f"[{number}/{total}] Finished {systemtest} in {elapsed_time:.1f}s [{status_label}]"
)
_group_end()
print("=" * 80)
results.append(result)

print()
system_test_success = True
for result in results:
if not result.success:
Expand Down
Loading