diff options
Diffstat (limited to 'tests/tests-common.cc')
-rw-r--r-- | tests/tests-common.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/tests-common.cc b/tests/tests-common.cc index 703e1c5..3c66e1b 100644 --- a/tests/tests-common.cc +++ b/tests/tests-common.cc @@ -7,9 +7,14 @@ #include <sstream> #include <fstream> -Module *parsefile(const char *filename) +/*! + fakepath is used to force the parser to believe that the file is + read from this location, in order to ensure that filepaths are + eavluated relative to this path (for testing purposes). +*/ +FileModule *parsefile(const char *filename, const char *fakepath) { - Module *root_module = NULL; + FileModule *root_module = NULL; handle_dep(filename); std::ifstream ifs(filename); @@ -19,7 +24,9 @@ Module *parsefile(const char *filename) else { std::string text((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); text += "\n" + commandline_commands; - std::string pathname = boosty::stringy(fs::path(filename).parent_path()); + std::string pathname; + if (fakepath) pathname = fakepath; + else pathname = boosty::stringy(fs::path(filename).parent_path()); root_module = parse(text.c_str(), pathname.c_str(), false); if (root_module) { root_module->handleDependencies(); |