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
properly use defined source and build dirs for testing #4392
base: master
Are you sure you want to change the base?
Conversation
ah thanks for the chore! never had the motivation so far, but it's so annoying to get all the test maps dumped in the wrong directory and messing up git (plus the inability to run them in some ways..) |
yeah was working on #4390 and it was annoying me so last night i decided i was going to remedy it. i didnt check the gurka directory yet but i can get that in another pass |
Should we just add the |
i had the same th ought yep |
target_compile_definitions(valhalla_test PRIVATE | ||
VALHALLA_SOURCE_DIR="${VALHALLA_SOURCE_DIR}/" | ||
VALHALLA_BUILD_DIR="${VALHALLA_BUILD_DIR}/") |
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.
all test targets get these two dirs defined so that..
#if !defined(VALHALLA_SOURCE_DIR) | ||
#define VALHALLA_SOURCE_DIR | ||
#endif | ||
|
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.
we dont have to have this random hack in there and we always get the right value (i have no idea why this kind of thing was hacked in here..)
using namespace valhalla::mjolnir; | ||
using namespace valhalla::baldr; | ||
|
||
namespace { | ||
|
||
const std::string config_file = "test/test_config_country"; | ||
const std::string config_file = VALHALLA_BUILD_DIR "test/test_config_country"; |
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.
in places where we dont use make_config
we use the thing manually
@@ -151,16 +151,16 @@ const gurka::ways ways = {{"AB", {{"highway", "primary"}}}, {"BC", {{"highway", | |||
|
|||
boost::property_tree::ptree get_config() { | |||
|
|||
return test::make_config(VALHALLA_BUILD_DIR "test/data/transit_tests", | |||
return test::make_config("test/data/transit_tests", |
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.
in places where we do use make_config
we rely on it to do the work for us
@@ -334,7 +335,7 @@ TEST(MapMatchRoute, IgnoreRestrictions) { | |||
}, | |||
{{"type", "restriction"}, {"restriction", "no_straight_on"}}}}; | |||
const gurka::map map = | |||
gurka::buildtiles(layout, ways, {}, relations, "test/data/mapmatch_restrictions", | |||
gurka::buildtiles(layout, ways, {}, relations, VALHALLA_BUILD_DIR "test/data/mapmatch_restrictions", | |||
{{"mjolnir.timezone", VALHALLA_BUILD_DIR "test/data/tz.sqlite"}}); |
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 felt it made sense to do it manually in these cases where we use the config option overrides because if we rely on make_config
doing the right thing by prefixing directories with VALHALLA_BUILD_DIR
, but then we add a config override for timezone and we ourselves dont prefix it, then we've defeated ourselves.
alternatively i could have written code to see if any override value begins with "test/data" and then prefixed that but it felt a little too much? i dont feel stronly about it
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.
not sure I understand this: on line 205 you're removing the prefix for tzdb, on line 337 you're adding it for the graph build (which should be covered already by make_config) and on line 339 you left it again for tzdb. probably an oversight?
IMO it'd be more consistent that noone ever has to specify VALHALLA_BUILD_DIR manually, but it's also a much rarer thing to do, so I'm ok with it too.
// we should use absolute paths so the binaries work regardless of CWD | ||
std::string absolute; | ||
if (path_prefix.find("test/") == 0) { | ||
absolute = VALHALLA_BUILD_DIR; | ||
} | ||
|
||
// force the paths to be different | ||
boost::replace_all(defaults, "%%", path_prefix); | ||
boost::replace_all(defaults, "%%", absolute + path_prefix); |
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.
this is the important part, we detect if your data prefix doesnt have the absolute path on and add it if not. this lets the binaries be run from any working directory (which can be useful)
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.
also note that gurka::buildtiles
calls into this function so its covered too
this is ready for review |
{"mjolnir.transit_pbf_limit", | ||
"1"}, // so we create more than one file per tile | ||
{"mjolnir.hierarchy", "1"}, | ||
{"mjolnir.timezone", VALHALLA_BUILD_DIR "test/data/tz.sqlite"}, |
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.
hm, do we really want to remove it here? or maybe it's added somewhere else I didn't yet?
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.
yeah this is the primary open issue at this point. the signature for make_config
takes first the directory argument and second a map of key values replacements, some of which might be things that are directories some not.
it was easy for me to patch the first arg when it didnt have the absolute path because i knew it was a directory but for the key values i dont know which ones are and arent directories. this means detecting and patching those is harder.
there are two options to do it automatically:
- something simple where i see the value begins with
"test/data"
this will not catch everythign but it should get most of everything - figure out which ones should be directories by looking at the default config for the path value that got substituted in everywhere and then patching only those that were substituted paths
i think ill take a try at the 2nd one because then everything can be completely automatic and i can remove any of these that exist
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.
that'd be much appreciated, albeit quite a sizable mechanical chore
@@ -67,7 +67,8 @@ class ProbableRestrictions : public testing::TestWithParam<int> { | |||
{gurka::node_member, "I", "via"}, | |||
}, | |||
{{"type", "restriction"}, {"restriction:probable", "no_left_turn @ probability=0"}}}}; | |||
map = gurka::buildtiles(layout, ways, {}, relations, "test/data/gurka_time_probable_restrictions", | |||
map = gurka::buildtiles(layout, ways, {}, relations, | |||
VALHALLA_BUILD_DIR "test/data/gurka_time_probable_restrictions", |
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.
yeah I'm confused.. isn't this the graph directory? don't we set that now in make_config()?
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.
same in lots of other places in gurka
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.
we do and I went through 2 rounds of this and missed this in the last round. it's surprisingly annoying to find all occurances at midnight after a long day at work hahaha
trivial one but in a lot of the tests we dont use directories in a CWD safe way which causes some tests to fail when you run them outside of their narrow working criteria. this pr simply fixes the tests that rely on paths to either source stuff or stuff we are building in the build directory