add --mp-tests option and preproc defines, and mp unit tests folder
These tests are meant to be run in a networked context to check for OOS and similar.
This commit is contained in:
parent
d50057e5a6
commit
489074b0a4
8 changed files with 153 additions and 0 deletions
|
@ -26,6 +26,11 @@
|
|||
|
||||
#ifdef MULTIPLAYER
|
||||
{multiplayer/}
|
||||
|
||||
#ifdef MP_TEST
|
||||
{test/multiplayer/}
|
||||
#endif
|
||||
|
||||
#else
|
||||
{era_blank.cfg}
|
||||
#endif
|
||||
|
|
15
data/test/multiplayer/_main.cfg
Normal file
15
data/test/multiplayer/_main.cfg
Normal file
|
@ -0,0 +1,15 @@
|
|||
#textdomain wesnoth-test
|
||||
|
||||
[textdomain]
|
||||
name="wesnoth-test"
|
||||
[/textdomain]
|
||||
|
||||
#ifdef MP_TEST
|
||||
|
||||
#Load test macros
|
||||
{test/multiplayer/macros}
|
||||
|
||||
#Load mp test scenarios
|
||||
{test/multiplayer/scenarios}
|
||||
|
||||
#endif
|
58
data/test/multiplayer/macros/mp_unit_test_macros.cfg
Normal file
58
data/test/multiplayer/macros/mp_unit_test_macros.cfg
Normal file
|
@ -0,0 +1,58 @@
|
|||
#textdomain wesnoth
|
||||
#define RETURN X
|
||||
[if]
|
||||
{X}
|
||||
[then]
|
||||
[endlevel]
|
||||
result=victory
|
||||
linger_mode = yes
|
||||
[/endlevel]
|
||||
[/then]
|
||||
[else]
|
||||
[endlevel]
|
||||
result=defeat
|
||||
linger_mode = yes
|
||||
[/endlevel]
|
||||
[/else]
|
||||
[/if]
|
||||
#enddef
|
||||
|
||||
#define ASSERT X
|
||||
[if]
|
||||
{X}
|
||||
[else]
|
||||
[endlevel]
|
||||
result=defeat
|
||||
linger_mode = yes
|
||||
[/endlevel]
|
||||
[/else]
|
||||
[/if]
|
||||
#enddef
|
||||
|
||||
#define MP_UNIT_TEST NAME CONTENT
|
||||
[multiplayer]
|
||||
name = "Multiplayer Unit Test " + {NAME}
|
||||
map_data = "{test/maps/generic_unit_test.map}"
|
||||
turns = -1
|
||||
id = {NAME}
|
||||
|
||||
{DAWN}
|
||||
|
||||
[side]
|
||||
side=1
|
||||
controller=human
|
||||
name = "Alice"
|
||||
type = Elvish Archer
|
||||
id=alice
|
||||
[/side]
|
||||
[side]
|
||||
side=2
|
||||
controller=human
|
||||
name = "Bob"
|
||||
type = Orcish Grunt
|
||||
id=bob
|
||||
[/side]
|
||||
|
||||
{CONTENT}
|
||||
[/multiplayer]
|
||||
#enddef
|
33
data/test/multiplayer/scenarios/test1.cfg
Normal file
33
data/test/multiplayer/scenarios/test1.cfg
Normal file
|
@ -0,0 +1,33 @@
|
|||
{MP_UNIT_TEST "test1" (
|
||||
|
||||
[event]
|
||||
name = side 1 turn 2
|
||||
|
||||
[chat]
|
||||
message="second turn"
|
||||
[/chat]
|
||||
[/event]
|
||||
|
||||
[event]
|
||||
name = side 2 turn 2
|
||||
[endlevel]
|
||||
result=victory
|
||||
next_scenario=test2
|
||||
|
||||
carryover_percentage=50
|
||||
carryover_report=false
|
||||
carryover_add=true
|
||||
|
||||
linger_mode=true
|
||||
save=no
|
||||
replay_save=no
|
||||
[/endlevel]
|
||||
[/event]
|
||||
|
||||
[event]
|
||||
name = side turn
|
||||
first_time_only = no
|
||||
[end_turn]
|
||||
[/end_turn]
|
||||
[/event]
|
||||
)}
|
33
data/test/multiplayer/scenarios/test2.cfg
Normal file
33
data/test/multiplayer/scenarios/test2.cfg
Normal file
|
@ -0,0 +1,33 @@
|
|||
{MP_UNIT_TEST "test2" (
|
||||
allow_new_game = false
|
||||
|
||||
[event]
|
||||
name = side 1 turn 2
|
||||
|
||||
[chat]
|
||||
message="second turn"
|
||||
[/chat]
|
||||
[/event]
|
||||
|
||||
[event]
|
||||
name = side 2 turn 2
|
||||
[endlevel]
|
||||
result=victory
|
||||
|
||||
carryover_percentage=50
|
||||
carryover_report=false
|
||||
carryover_add=true
|
||||
|
||||
linger_mode=true
|
||||
save=no
|
||||
replay_save=no
|
||||
[/endlevel]
|
||||
[/event]
|
||||
|
||||
[event]
|
||||
name = side turn
|
||||
first_time_only = no
|
||||
[end_turn]
|
||||
[/end_turn]
|
||||
[/event]
|
||||
)}
|
|
@ -139,6 +139,7 @@ commandline_options::commandline_options (const std::vector<std::string>& args)
|
|||
unit_test(),
|
||||
headless_unit_test(false),
|
||||
noreplaycheck(false),
|
||||
mptest(false),
|
||||
userconfig_path(false),
|
||||
userconfig_dir(),
|
||||
userdata_path(false),
|
||||
|
@ -256,6 +257,7 @@ commandline_options::commandline_options (const std::vector<std::string>& args)
|
|||
("timeout", po::value<unsigned int>(), "sets a timeout (milliseconds) for the unit test. (DEPRECATED)")
|
||||
("log-strict", po::value<std::string>(), "sets the strict level of the logger. any messages sent to log domains of this level or more severe will cause the unit test to fail regardless of the victory result.")
|
||||
("noreplaycheck", "don't try to validate replay of unit test")
|
||||
("mp-test", "load the test mp scenarios")
|
||||
;
|
||||
|
||||
po::options_description preprocessor_opts("Preprocessor mode options");
|
||||
|
@ -371,6 +373,8 @@ commandline_options::commandline_options (const std::vector<std::string>& args)
|
|||
parse_log_strictness(vm["log-strict"].as<std::string>());
|
||||
if (vm.count("max-fps"))
|
||||
max_fps = vm["max-fps"].as<int>();
|
||||
if (vm.count("mp-test"))
|
||||
mptest = true;
|
||||
if (vm.count("multiplayer"))
|
||||
multiplayer = true;
|
||||
if (vm.count("multiplayer-repeat"))
|
||||
|
|
|
@ -206,6 +206,8 @@ public:
|
|||
boost::optional<unsigned int> timeout;
|
||||
/// True if --noreplaycheck was given on the comand line. Dependent on --unit.
|
||||
bool noreplaycheck;
|
||||
/// True if --mp-test was given on the command line.
|
||||
bool mptest;
|
||||
/// True if --userconfig-path was given on the command line. Prints path to user config directory and exits.
|
||||
bool userconfig_path;
|
||||
/// Non-empty if --userconfig-dir was given on the command line. Sets the user config dir to the specified one.
|
||||
|
|
|
@ -81,6 +81,7 @@ bool game_config_manager::init_game_config(FORCE_RELOAD_CONFIG force_reload)
|
|||
game_config::scoped_preproc_define multiplayer("MULTIPLAYER",
|
||||
cmdline_opts_.multiplayer);
|
||||
game_config::scoped_preproc_define test("TEST", cmdline_opts_.test);
|
||||
game_config::scoped_preproc_define mptest("MP_TEST", cmdline_opts_.mptest);
|
||||
game_config::scoped_preproc_define editor("EDITOR", jump_to_editor_);
|
||||
game_config::scoped_preproc_define title_screen("TITLE_SCREEN",
|
||||
!cmdline_opts_.multiplayer && !cmdline_opts_.test && !jump_to_editor_);
|
||||
|
@ -490,6 +491,8 @@ void game_config_manager::load_game_config_for_game(
|
|||
!classification.era_define.empty());
|
||||
game_config::scoped_preproc_define multiplayer("MULTIPLAYER",
|
||||
classification.campaign_type == game_classification::MULTIPLAYER);
|
||||
game_config::scoped_preproc_define mptest("MP_TEST", cmdline_opts_.mptest &&
|
||||
classification.campaign_type == game_classification::MULTIPLAYER);
|
||||
|
||||
typedef boost::shared_ptr<game_config::scoped_preproc_define> define;
|
||||
std::deque<define> extra_defines;
|
||||
|
|
Loading…
Add table
Reference in a new issue