diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 11b411e..681638e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -4,6 +4,8 @@ # Distributed under the Boost Software License, Version 1.0. # See www.boost.org/LICENSE_1_0.txt +import testing ; + project : requirements /boost/filesystem//boost_filesystem @@ -14,6 +16,8 @@ project # Some tests are run both statically and as shared libraries since Filesystem # has a history of bugs that appear only in one type of build or the other. +path-constant HERE : . ; + test-suite "filesystem" : [ run config_info.cpp : : : shared always_show_run_output ] [ run config_info.cpp : : : static always_show_run_output : config_info_static ] @@ -26,7 +30,7 @@ project [ run locale_info.cpp : : : always_show_run_output ] [ run operations_test.cpp : : : shared always_show_run_output ] [ run operations_test.cpp : : : static : operations_test_static ] - [ run operations_unit_test.cpp : : : shared always_show_run_output ] + [ run operations_unit_test.cpp : $(HERE) : : shared always_show_run_output ] [ run path_test.cpp : : : shared ] [ run path_test.cpp : : : static : path_test_static ] [ run path_unit_test.cpp : : : shared ] diff --git a/test/operations_unit_test.cpp b/test/operations_unit_test.cpp index 663d280..a80a327 100644 --- a/test/operations_unit_test.cpp +++ b/test/operations_unit_test.cpp @@ -46,8 +46,6 @@ using std::string; namespace { - const path temp_dir(initial_path() / unique_path("op-unit_test-%%%%-%%%%-%%%%")); - bool cleanup = true; void check(bool ok, const char* file, int line) @@ -317,7 +315,7 @@ namespace // string_file_tests ---------------------------------------------------------------// - void string_file_tests() + void string_file_tests(const path& temp_dir) { cout << "string_file_tests..." << endl; std::string contents("0123456789"); @@ -338,7 +336,7 @@ namespace // // //--------------------------------------------------------------------------------------// -int cpp_main(int, char*[]) +int cpp_main(int argc, char* argv[]) { // document state of critical macros #ifdef BOOST_POSIX_API @@ -352,6 +350,24 @@ int cpp_main(int, char*[]) cout << "current_path() is " << current_path().string() << endl; + if (argc >= 2) + { + cout << "argv[1] is '" << argv[1] << "', changing current_path() to it" << endl; + + error_code ec; + current_path( argv[1], ec ); + + if (ec) + { + cout << "current_path('" << argv[1] << "') failed: " << ec << ": " << ec.message() << endl; + } + + cout << "current_path() is " << current_path().string() << endl; + } + + const path temp_dir(current_path() / unique_path("op-unit_test-%%%%-%%%%-%%%%")); + cout << "temp_dir is " << temp_dir.string() << endl; + create_directory(temp_dir); file_status_test(); @@ -362,7 +378,7 @@ int cpp_main(int, char*[]) directory_entry_test(); directory_entry_overload_test(); error_handling_test(); - string_file_tests(); + string_file_tests(temp_dir); cout << unique_path() << endl; cout << unique_path("foo-%%%%%-%%%%%-bar") << endl;