From 9e71a5cd236e0b6639f55f2f6520aaa06eac0523 Mon Sep 17 00:00:00 2001 From: Gavin Andresen Date: Thu, 26 Apr 2012 11:20:44 -0400 Subject: Define TEST_DATA_DIR so unit tests can be run from any current working directory --- src/test/script_tests.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 988bd24de8..745df4bd7b 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -5,8 +5,9 @@ #include #include #include -#include #include +#include +#include #include "json/json_spirit_reader_template.h" #include "json/json_spirit_writer_template.h" #include "json/json_spirit_utils.h" @@ -87,10 +88,13 @@ read_json(const std::string& filename) { namespace fs = boost::filesystem; fs::path testFile = fs::current_path() / "test" / "data" / filename; + +#ifdef TEST_DATA_DIR if (!fs::exists(testFile)) { - fs::path testFile = fs::path(__FILE__).parent_path() / "data" / filename; + testFile = fs::path(BOOST_PP_STRINGIZE(TEST_DATA_DIR)) / filename; } +#endif ifstream ifs(testFile.string().c_str(), ifstream::in); Value v; -- cgit v1.2.3