Fix multiplayer tests failing in Travis CI
It depends on timing whether or not the guest shows the wait dialog between
scenarios. If the second scenario has already started when the guest tries
to show the dialog, the dialog is skipped: otherwise it's shown and it
changes the plugin context.
The join.lua plugin assumed the change of plugin context to mean that the
test is over and that the plugin should quit the game. As a result, it
ended up quitting in the middle of the test if the second scenario hadn't
started yet.
Commit 6016bdf2
tried to fix the problem by allowing the plugin context to
change once during the test. It resulted in the opposite problem: if the
second scenario *had* started, the plugin context didn't change. When the
test ended and the guest was thrown into the lobby, then the plugin
assumed that it was just the scenario change and kept waiting for the next
scenario that wasn't coming.
This commit finally fixes the problem by explicitly polling the name of the
scenario being played. Now join.lua ignores plugin context changes as long
as the last scenario hasn't started, but starts waiting for the game to end
when the scenario starts.
I verified locally that, with these changes applied, the tests pass both
with an unmodified build and with a build that has an artificial delay to
simulate the timing in Travis.
This commit is contained in:
parent
74f1fe1e15
commit
2c4d72f544
2 changed files with 3 additions and 7 deletions
9
join.lua
9
join.lua
|
@ -127,13 +127,8 @@ local function plugin()
|
|||
|
||||
repeat
|
||||
events, context, info = coroutine.yield()
|
||||
idle_text("in " .. info.name .. " waiting for not game")
|
||||
until info.name ~= "Game"
|
||||
|
||||
repeat
|
||||
events, context, info = coroutine.yield()
|
||||
idle_text("in " .. info.name .. " waiting for game")
|
||||
until info.name == "Game"
|
||||
idle_text("in " .. info.name .. " waiting for the last scenario")
|
||||
until info.scenario_name ~= nil and info.scenario_name().scenario_name == "Multiplayer Unit Test test2"
|
||||
|
||||
repeat
|
||||
events, context, info = coroutine.yield()
|
||||
|
|
|
@ -297,6 +297,7 @@ void play_controller::init(CVideo& video, const config& level)
|
|||
plugins_context_->set_callback("save_game", [this](const config& cfg) { save_game_auto(cfg["filename"]); }, true);
|
||||
plugins_context_->set_callback("save_replay", [this](const config& cfg) { save_replay_auto(cfg["filename"]); }, true);
|
||||
plugins_context_->set_callback("quit", throw_end_level(), false);
|
||||
plugins_context_->set_accessor_string("scenario_name", [this](config) { return get_scenario_name(); });
|
||||
});
|
||||
//Do this after the loadingscreen, so that ita happens in the main thread.
|
||||
gui_->join();
|
||||
|
|
Loading…
Add table
Reference in a new issue