18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-14 12:22:24 +01:00

fix(simulation): a test run that can't start ends with the error code and says why

- `--test` is looked for before the rest of the command line is read. An
  unknown option before it (e.g. `-s x.scn --test-timout 90 --test`) used
  to end the run with exit code 0, which a caller reads as a pass.
- `--test-timeout` without a value, or with one that isn't a number of
  seconds, fails the run instead of leaving the default or, through atof,
  turning the timeout off.
- These, a missing -s, a failed start and an exception caught in main()
  end the test through test_manager::conclude(), which writes the usual
  `test: error (exit code 5) ... : <reason>` line to stdout and the log.
  Before, `eu07 --test` alone exited with 5 and nothing anywhere: the
  error went to the log queue and the process ended before the log
  thread wrote it. In test mode main() now stops the log thread and
  waits for it before _Exit().

Outside the test mode nothing changes: conclude() does nothing there.
This commit is contained in:
jerrrrycho
2026-11-08 09:36:28 +01:00
parent 547706b54d
commit 4356e7c3fd
4 changed files with 63 additions and 8 deletions

View File

@@ -156,9 +156,15 @@ void test_manager::signal_passed_at_danger(std::string_view const Vehicle, std::
}
void test_manager::finish(test_result const Result, std::string_view const Reason)
{
if (conclude(Result, Reason))
Application.queue_quit(true);
}
bool test_manager::conclude(test_result const Result, std::string_view const Reason)
{
if (m_finished || false == Global.test.enabled)
return;
return false;
m_finished = true;
m_result = Result;
@@ -170,8 +176,7 @@ void test_manager::finish(test_result const Result, std::string_view const Reaso
// the process has no console of its own; whoever started it with a redirected output gets the verdict there too
std::fprintf(stdout, "%s\n", line.c_str());
std::fflush(stdout);
Application.queue_quit(true);
return true;
}
} // namespace simulation