diff --git a/source/test/Test.cpp b/source/test/Test.cpp index 3f46d6bb7dbb..49125ba8ac04 100644 --- a/source/test/Test.cpp +++ b/source/test/Test.cpp @@ -29,6 +29,7 @@ this program. If not, see . #include #include +#include #include #include #include @@ -50,6 +51,7 @@ namespace { {Test::TestStep::Type::ASSERT, "assert"}, {Test::TestStep::Type::BRANCH, "branch"}, {Test::TestStep::Type::CALL, "call"}, + {Test::TestStep::Type::DEBUG, "debug"}, {Test::TestStep::Type::INJECT, "inject"}, {Test::TestStep::Type::INPUT, "input"}, {Test::TestStep::Type::LABEL, "label"}, @@ -244,6 +246,16 @@ void Test::LoadSequence(const DataNode &node) else step.nameOrLabel = child.Token(1); break; + case TestStep::Type::DEBUG: + if(child.Size() < 2) + { + status = Status::BROKEN; + child.PrintTrace("Error: Invalid use of \"debug\" without an actual message to print:"); + return; + } + else + step.nameOrLabel = child.Token(1); + break; case TestStep::Type::INJECT: if(child.Size() < 2) { @@ -471,6 +483,12 @@ void Test::Step(TestContext &context, PlayerInfo &player, Command &commandToGive } continueGameLoop = true; break; + case TestStep::Type::DEBUG: + // Print debugging output directly to the terminal. + cout << stepToRun.nameOrLabel << endl; + cout.flush(); + ++(context.callstack.back().step); + break; case TestStep::Type::INJECT: { // Lookup the data and inject it in the game or into the environment. diff --git a/source/test/Test.h b/source/test/Test.h index 512d3aecccdd..1f755680fcc9 100644 --- a/source/test/Test.h +++ b/source/test/Test.h @@ -62,6 +62,8 @@ class Test { BRANCH, // Step that calls another test to handle some generic common actions. CALL, + // Step that prints a debug-message to the output. + DEBUG, // Step that adds game-data, either in the config-directories or in the game directly. INJECT, // Step that performs input (key, mouse, command). Does cause the game to step (to process the inputs). diff --git a/tests/integration/config/plugins/integration-tests/data/tests/tests_afterburn_flight.txt b/tests/integration/config/plugins/integration-tests/data/tests/tests_afterburn_flight.txt index 62e60a02aeca..d45e79757471 100644 --- a/tests/integration/config/plugins/integration-tests/data/tests/tests_afterburn_flight.txt +++ b/tests/integration/config/plugins/integration-tests/data/tests/tests_afterburn_flight.txt @@ -109,6 +109,7 @@ test "Afterburner-flight - Simple depart land" inject "burning flyers save" call "Load First Savegame" call "Depart" + debug "Departed from the planet" # Wait for 10 seconds to drift away from the planet. apply "test: steps to wait" = 20 @@ -121,6 +122,8 @@ test "Afterburner-flight - Simple depart land" "test: steps to wait" > 0 navigate "travel destination" Ruin + debug "Start landing" call "Land" + debug "Done landing" assert "flagship landed" == 1