Allow specifying where the unit test output file is

The default location probably makes sense on Linux or Windows, but it is nonsensical on Mac and breaks the game's build when the tests are run.
This commit is contained in:
Celtic Minstrel 2022-07-01 21:50:11 -04:00
parent a0c2997fac
commit 8ba57c4290
2 changed files with 15 additions and 2 deletions

View file

@ -56,6 +56,10 @@
argument = "--run_test=test_preproc_defines"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "-- --output_file &quot;$(PROJECT_DIR)/../../boost_test_result.xml&quot;"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable

View file

@ -26,6 +26,7 @@
#include <boost/test/unit_test_monitor.hpp>
#include <boost/test/unit_test_parameters.hpp>
#include <boost/test/results_reporter.hpp>
#include <boost/filesystem/path.hpp>
#include <fstream>
@ -60,8 +61,16 @@ std::ofstream reporter;
struct wesnoth_global_fixture {
wesnoth_global_fixture()
{
using namespace boost::unit_test;
reporter.open("boost_test_result.xml");
using namespace boost::unit_test; using namespace std::literals;
boost::filesystem::path file("boost_test_result.xml");
for(int i = 1; i < framework::master_test_suite().argc; i++) {
if(framework::master_test_suite().argv[i - 1] == "--output_file"s) {
file = framework::master_test_suite().argv[i];
break;
}
}
reporter.open(file.c_str());
assert( reporter.is_open() );
results_reporter::set_stream(reporter);