-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add game testing. #2050
Add game testing. #2050
Conversation
6f03327
to
a13b0ae
Compare
test/game/TestGame.cpp
Outdated
} | ||
to_process = true; | ||
} else { | ||
if(to_process) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space between (
and if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Rebased. Refactored and set time limits on game starting and turn processing. |
Rebased. Added environment variables |
Rebased. Implement testing saves. Add options |
2a098b0
to
07ecea5
Compare
Rebased. Tested against new docker image. |
default/stringtables/en.txt
Outdated
@@ -1186,6 +1186,9 @@ Start server in hostless mode. Server accepts players in the multiplayer lobby, | |||
OPTIONS_DB_SKIP_CHECKSUM | |||
Skip comparing the resource directory checksums. This allows faster startup when client and server are on the same machine, using the same resource directory. | |||
|
|||
OPTIONS_DB_TESTING | |||
Start server in testing mode. AI playing will be output log to colnsole instead file (Linux only). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
colnsole
rewrite second sentence
Not clear if this option is Linux-only, or the to-consolve vs. to-file part is Linux-only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Option is no-op in other than Linux OS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the "Linux only" at the start.
And perhaps don't even add it as an option in those cases...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the option to macro condition for FREEORION_LINUX
.
server/ServerApp.cpp
Outdated
@@ -260,6 +260,14 @@ void ServerApp::CreateAIClients(const std::vector<PlayerSetupData>& player_setup | |||
args.push_back(GetOptionsDB().Get<std::string>("log-level")); | |||
} | |||
|
|||
if (GetOptionsDB().Get<bool>("testing")) { | |||
#ifdef FREEORION_LINUX | |||
// Dirty hack to output log to console. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use the standard log files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it possible to get them from Travis CI to get detailed information about possible errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running the tests isn't possible on AppVeyor as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It possible but logs will be output to files.
test/game/ClientAppFixture.cpp
Outdated
#include <boost/format.hpp> | ||
|
||
ClientAppFixture::ClientAppFixture() | ||
:m_game_started(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:
to previous line, with space between it and )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
test/game/ClientAppFixture.cpp
Outdated
// Dirty hack to output log to console. | ||
InitLoggingSystem("/proc/self/fd/1", "Test"); | ||
#else | ||
InitLoggingSystem((GetUserDataDir() / "test.log").string(), "Test"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use standard log file location?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetUserDataDir()
is a standard folder for logs. test.log
is used instead freeorion.log
to distinguish unit test from human client.
test/game/ClientAppFixture.cpp
Outdated
} | ||
|
||
int ClientAppFixture::EffectsProcessingThreads() const | ||
{ return 1; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use standard option for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It requires unittest to have a fully initialized OptionsDB
.
test/game/ClientAppFixture.cpp
Outdated
{ return m_networking->ConnectToLocalHostServer(); } | ||
|
||
void ClientAppFixture::HostSPGame(unsigned int num_AIs) { | ||
std::vector<std::pair<std::string, std::string>> game_rules = GetGameRules().GetRulesAsStrings(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer auto
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Stop test on elimination or win.
Rebased. |
What if merge it into 0.4.8 branch too so release will be tested too? |
no. adding new / potentially problematic stuff immediately before release not appropriate. |
Considering the amount of changes to the codebase, this isn't a purely "infrastructure" PR anyway. I'm going to add "component:internal" and a proper milestone (post release). |
This PR adds tests for the game itself.
Test acts as a host for the game server. It starts singleplayer game, make a turns and check if server and AIs acts correctly and within time limits.
Test accepts environment variables
FO_TEST_GAME_AIS
to manage number of AI players,FO_TEST_GAME_TURNS
to manage numbers of turns to make, andFO_TEST_GAME_SAVE
to save game after each turn.Test will stop when test player will be eliminated or someone wins the game.
Other changes:
Process::Terminate
method to ensure server was stopped correctly.ClientApp::VerifyCheckSum
returnsbool
insteadvoid
.--testing
to output AI logs tostdout
.