mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 00:35:59 +01:00
fix(simulation): any exception ends a test run with error, other runs as on master
main() tells a test run (--test) apart before anything runs. Only a test run catches every exception and installs a std::terminate handler, both ending the run with the error code and a test: line; any other run keeps master's exception handling, so on Linux an uncaught runtime_error aborts at the throw site again. A test run doesn't start the Discord RPC thread: it published the test scenery as the player's presence and held the closing up to 5 s. run.py drops a case scenery's .sbt cache after a run cut short (wall_timeout, error, a crash, killed by run.py), which could have been writing it. The -edit branch of the test command line parser had no effect (a token that isn't an option is ignored either way) and is gone; its test checks what can be seen instead.
This commit is contained in:
@@ -100,15 +100,28 @@ test_command_line parse_test_command_line(std::span<char const *const> const Arg
|
||||
{
|
||||
++i;
|
||||
}
|
||||
else if (option == "-edit" && i + 1 < Arguments.size() && Arguments[i + 1][0] != '-')
|
||||
{
|
||||
// the scenery to edit is optional
|
||||
++i;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string describe_exception(std::exception_ptr const &Exception)
|
||||
{
|
||||
if (nullptr == Exception)
|
||||
return "the simulator was terminated";
|
||||
try
|
||||
{
|
||||
std::rethrow_exception(Exception);
|
||||
}
|
||||
catch (std::exception const &Error)
|
||||
{
|
||||
return std::format("critical error: {}", Error.what());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return "critical error: an exception of unknown type";
|
||||
}
|
||||
}
|
||||
|
||||
double wall_clock_limit(std::optional<double> const Given, double const Simulationtimeout)
|
||||
{
|
||||
if (Given.has_value())
|
||||
|
||||
@@ -9,6 +9,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <exception>
|
||||
#include <optional>
|
||||
#include <span>
|
||||
#include <string>
|
||||
@@ -53,6 +54,10 @@ std::optional<double> parse_seconds(std::string_view Text);
|
||||
// options are skipped, so a scenery named like an option isn't taken for one; options it doesn't know are left alone
|
||||
test_command_line parse_test_command_line(std::span<char const *const> Arguments);
|
||||
|
||||
// what ended a test run that the simulator didn't end itself: the exception caught (or being handled when the
|
||||
// program was terminated), or nothing
|
||||
std::string describe_exception(std::exception_ptr const &Exception);
|
||||
|
||||
// time allowed for loading the scenery, on top of the simulation time, when the real time limit isn't given [s]
|
||||
inline constexpr double wall_timeout_loading_allowance{600.0};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user