Skip to content

Add a setting to stop stderr output from failing a testcase#178

Open
znzryb wants to merge 1 commit into
Pushpavel:mainfrom
znzryb:ignore-stderr-option
Open

Add a setting to stop stderr output from failing a testcase#178
znzryb wants to merge 1 commit into
Pushpavel:mainfrom
znzryb:ignore-stderr-option

Conversation

@znzryb

@znzryb znzryb commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Problem

Anything a solution writes to stderr fails the testcase with [-] FAILURE: RUNTIME ERROR, even when the process exits with 0 and the answer on stdout is correct. ProcessRunner throws RuntimeErr as soon as the error stream is non-empty, so a single debug print makes every testcase — normal run and stress test alike — come back red.

stderr debug output forcing a RUNTIME ERROR verdict

Printing intermediate state to stderr is a pretty common debugging habit while stress testing (it keeps the debug log out of the answer that gets compared), and it is exactly what online judges ignore — they verdict a submission on its exit code and stdout only. Right now that habit is unusable: the stress test stops at testcase 1 with a runtime error that says nothing about correctness.

Change

Adds Settings > Tools > AutoCp > Testing > "Ignore output written to stderr", on by default.

When it is on, the error stream is captured into the verdict instead of aborting the run, so a testcase is judged by its exit code and stdout like a judge would do. A non-zero exit code still produces a runtime error, and the captured stderr is now appended to its message, which makes crashes easier to diagnose than before. Turning the setting off restores the previous behaviour of failing any testcase that writes to stderr.

a genuine crash still reported as RUNTIME ERROR via its exit code

Here the solution dies on an AddressSanitizer heap-buffer-overflow with the setting on: the non-zero exit code (134) still fails the testcase as a runtime error, with the sanitizer report from stderr attached to the message.

Captured stderr is reported through testStdErr under the testcase output behind a ___[ stderr ]___ header, for correct and wrong answers alike. Going through the error channel keeps the debug log in its own color in the test runner, so it stays visually distinct from the answer it sits next to.

stderr no longer deciding the verdict, kept in its own color

The same stress test now runs to completion: the testcases whose answer matches pass with their debug log intact, and the one that is genuinely wrong is reported as a wrong answer instead of hiding behind a runtime error.

Compiling a solution is untouched: TwoStepProcessFactory keeps the default ignoreStderr = false, so a failing build still surfaces as BuildErr through the same path as before.

Notes

  • The setting is applied where the runners are created (participant, judge, generator and correct program), so it covers normal testing, stress testing and interactive problems.
  • ProcessRunner.CapturedResults gained a stderr field with a default value, and the two verdicts gained a trailing stderr parameter with a default, so existing construction sites keep compiling.

Anything a solution wrote to stderr was turned into a RUNTIME ERROR
verdict regardless of the exit code, so a single debug print made every
testcase fail even when the answer on stdout was correct.

Capture the error stream into the verdict instead of aborting on it when
the new 'Ignore output written to stderr' setting is on (default), so the
verdict depends only on the exit code and stdout, like an online judge
does. The captured stderr is printed under the testcase output so debug
logs stay visible, and building a solution keeps its previous behaviour.
@znzryb
znzryb force-pushed the ignore-stderr-option branch from 60e0774 to 9535b16 Compare July 25, 2026 08:59
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 50 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...thub/pushpavel/autocp/tester/base/ProcessRunner.kt 0.00% 11 Missing ⚠️
...hpavel/autocp/tester/TreeTestingProcessReporter.kt 0.00% 10 Missing ⚠️
...n/com/github/pushpavel/autocp/tester/base/Judge.kt 0.00% 10 Missing ⚠️
...neralSettings/AutoCpGeneralSettingsConfigurable.kt 0.00% 5 Missing ⚠️
...pavel/autocp/tester/AutoCpTestingProcessHandler.kt 0.00% 5 Missing ⚠️
...hpavel/autocp/tester/TestcaseTreeTestingProcess.kt 0.00% 5 Missing ⚠️
.../settings/generalSettings/AutoCpGeneralSettings.kt 0.00% 2 Missing ⚠️
...m/github/pushpavel/autocp/tester/errors/Verdict.kt 0.00% 2 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Files with missing lines Coverage Δ
...ithub/pushpavel/autocp/common/res/AutoCpStrings.kt 16.21% <ø> (ø)
.../settings/generalSettings/AutoCpGeneralSettings.kt 0.00% <0.00%> (ø)
...m/github/pushpavel/autocp/tester/errors/Verdict.kt 0.00% <0.00%> (ø)
...neralSettings/AutoCpGeneralSettingsConfigurable.kt 0.00% <0.00%> (ø)
...pavel/autocp/tester/AutoCpTestingProcessHandler.kt 0.00% <0.00%> (ø)
...hpavel/autocp/tester/TestcaseTreeTestingProcess.kt 0.00% <0.00%> (ø)
...hpavel/autocp/tester/TreeTestingProcessReporter.kt 0.00% <0.00%> (ø)
...n/com/github/pushpavel/autocp/tester/base/Judge.kt 0.00% <0.00%> (ø)
...thub/pushpavel/autocp/tester/base/ProcessRunner.kt 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants