Skip to content
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

Better way to run parallel test processes in different directories #48399

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build-scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ then
make -j$num_jobs
cd ..
# Run regular tests
[ -f "${bin_path}cata_test" ] && parallel --verbose --linebuffer "run_test $(printf %q "${bin_path}")'/cata_test' {} '('{}')=> '" ::: "crafting_skill_gain" "[slow] ~crafting_skill_gain" "~[slow] ~[.]"
[ -f "${bin_path}cata_test-tiles" ] && parallel --verbose --linebuffer "run_test $(printf %q "${bin_path}")'/cata_test-tiles' {} '('{}')=> '" ::: "crafting_skill_gain" "[slow] ~crafting_skill_gain" "~[slow] ~[.]"
[ -f "${bin_path}cata_test" ] && parallel --verbose --linebuffer --link "run_test $(printf %q "${bin_path}")'/cata_test' {2} {1} '('{1}')=> '" ::: "crafting_skill_gain" "[slow] ~crafting_skill_gain" "~[slow] ~[.]" ::: "--user-dir=process1" "--user-dir=process2" "--user-dir=process3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to change the run_test function to accept the new argument. (Or you can instead append the command line option to the first argument, I suppose.)

[ -f "${bin_path}cata_test-tiles" ] && parallel --verbose --linebuffer --link "run_test $(printf %q "${bin_path}")'/cata_test-tiles' {2} {1} '('{1}')=> '" ::: "crafting_skill_gain" "[slow] ~crafting_skill_gain" "~[slow] ~[.]" ::: "--user-dir=process1" "--user-dir=process2" "--user-dir=process3"
fi
elif [ "$NATIVE" == "android" ]
then
Expand All @@ -187,10 +187,10 @@ else

export ASAN_OPTIONS=detect_odr_violation=1
export UBSAN_OPTIONS=print_stacktrace=1
parallel --verbose --linebuffer "run_test './tests/cata_test' {} '('{}')=> '" ::: "crafting_skill_gain" "[slow] ~crafting_skill_gain" "~[slow] ~[.]"
parallel --verbose --linebuffer --link "run_test './tests/cata_test' {2} {1} '('{1}')=> '" ::: "crafting_skill_gain" "[slow] ~crafting_skill_gain" "~[slow] ~[.]" ::: "--user-dir=process1" "--user-dir=process2" "--user-dir=process3"
if [ -n "$MODS" ]
then
parallel --verbose --linebuffer "run_test './tests/cata_test --user-dir=modded '$(printf %q "${MODS}") {} 'Mods-('{}')=> '" ::: "crafting_skill_gain" "[slow] ~crafting_skill_gain" "~[slow] ~[.]"
parallel --verbose --linebuffer --link "run_test './tests/cata_test {2} '$(printf %q "${MODS}") {1} 'Mods-('{1}')=> '" ::: "crafting_skill_gain" "[slow] ~crafting_skill_gain" "~[slow] ~[.]" ::: "--user-dir=modded-process1" "--user-dir=modded-process2" "--user-dir=modded-process3"
fi

if [ -n "$TEST_STAGE" ]
Expand Down
16 changes: 0 additions & 16 deletions src/worldfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,6 @@ WORLD::WORLD()
active_mod_order = world_generator->get_mod_manager().get_default_mods();
}

WORLD::WORLD( const std::string &name )
{
world_name = name;
WORLD_OPTIONS = get_options().get_world_defaults();

world_saves.clear();
active_mod_order = world_generator->get_mod_manager().get_default_mods();
}

void WORLD::COPY_WORLD( const WORLD *world_to_copy )
{
world_name = world_to_copy->world_name + "_copy";
Expand Down Expand Up @@ -139,13 +130,6 @@ WORLDPTR worldfactory::make_new_world( const std::vector<mod_id> &mods )
return add_world( std::move( retworld ) );
}

WORLDPTR worldfactory::make_new_world( const std::string &name, const std::vector<mod_id> &mods )
{
std::unique_ptr<WORLD> retworld = std::make_unique<WORLD>( name );
retworld->active_mod_order = mods;
return add_world( std::move( retworld ) );
}

WORLDPTR worldfactory::make_new_world( bool show_prompt, const std::string &world_to_copy )
{
// World to return after generating
Expand Down
2 changes: 0 additions & 2 deletions src/worldfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ struct WORLD {
std::vector<mod_id> active_mod_order;

WORLD();
explicit WORLD( const std::string &name );
void COPY_WORLD( const WORLD *world_to_copy );

bool save_exists( const save_t &name ) const;
Expand Down Expand Up @@ -95,7 +94,6 @@ class worldfactory
WORLDPTR make_new_world( bool show_prompt = true, const std::string &world_to_copy = "" );
WORLDPTR make_new_world( special_game_type special_type );
// Used for unit tests - does NOT verify if the mods can be loaded
WORLDPTR make_new_world( const std::string &name, const std::vector<mod_id> &mods );
WORLDPTR make_new_world( const std::vector<mod_id> &mods );
/// Returns the *existing* world of given name.
WORLDPTR get_world( const std::string &name );
Expand Down
16 changes: 2 additions & 14 deletions tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@
#include <ostream>
#include <string>
#include <utility>
#include <vector>

#include "calendar.h"
#include "catch/catch.hpp"
#include "coordinates.h"
#ifndef _WIN32
#include <unistd.h>
#endif

#include "avatar.h"
#include "cached_options.h"
#include "cata_assert.h"
#include "cata_utility.h"
#include "catch/catch.hpp"
#include "color.h"
#include "debug.h"
#include "filesystem.h"
Expand Down Expand Up @@ -132,12 +125,7 @@ static void init_global_game_state( const std::vector<mod_id> &mods,

world_generator->set_active_world( nullptr );
world_generator->init();
#ifndef _WIN32
const std::string test_world_name = "Test World " + std::to_string( getpid() );
#else
const std::string test_world_name = "Test World";
#endif
WORLDPTR test_world = world_generator->make_new_world( test_world_name, mods );
WORLDPTR test_world = world_generator->make_new_world( mods );
cata_assert( test_world != nullptr );
world_generator->set_active_world( test_world );
cata_assert( world_generator->active_world != nullptr );
Expand Down