Make operations_unit_test take a current directory argument; pass one in test/Jamfile

This commit is contained in:
Peter Dimov 2017-11-22 05:05:43 +02:00
parent 93cab09a6b
commit 1dc51988bb
2 changed files with 26 additions and 6 deletions

View File

@ -4,6 +4,8 @@
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# See www.boost.org/LICENSE_1_0.txt # See www.boost.org/LICENSE_1_0.txt
import testing ;
project project
: requirements : requirements
<library>/boost/filesystem//boost_filesystem <library>/boost/filesystem//boost_filesystem
@ -14,6 +16,8 @@ project
# Some tests are run both statically and as shared libraries since Filesystem # 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. # has a history of bugs that appear only in one type of build or the other.
path-constant HERE : . ;
test-suite "filesystem" : test-suite "filesystem" :
[ run config_info.cpp : : : <link>shared <test-info>always_show_run_output ] [ run config_info.cpp : : : <link>shared <test-info>always_show_run_output ]
[ run config_info.cpp : : : <link>static <test-info>always_show_run_output : config_info_static ] [ run config_info.cpp : : : <link>static <test-info>always_show_run_output : config_info_static ]
@ -26,7 +30,7 @@ project
[ run locale_info.cpp : : : <test-info>always_show_run_output ] [ run locale_info.cpp : : : <test-info>always_show_run_output ]
[ run operations_test.cpp : : : <link>shared <test-info>always_show_run_output ] [ run operations_test.cpp : : : <link>shared <test-info>always_show_run_output ]
[ run operations_test.cpp : : : <link>static : operations_test_static ] [ run operations_test.cpp : : : <link>static : operations_test_static ]
[ run operations_unit_test.cpp : : : <link>shared <test-info>always_show_run_output ] [ run operations_unit_test.cpp : $(HERE) : : <link>shared <test-info>always_show_run_output ]
[ run path_test.cpp : : : <link>shared ] [ run path_test.cpp : : : <link>shared ]
[ run path_test.cpp : : : <link>static : path_test_static ] [ run path_test.cpp : : : <link>static : path_test_static ]
[ run path_unit_test.cpp : : : <link>shared ] [ run path_unit_test.cpp : : : <link>shared ]

View File

@ -46,8 +46,6 @@ using std::string;
namespace namespace
{ {
const path temp_dir(initial_path() / unique_path("op-unit_test-%%%%-%%%%-%%%%"));
bool cleanup = true; bool cleanup = true;
void check(bool ok, const char* file, int line) void check(bool ok, const char* file, int line)
@ -317,7 +315,7 @@ namespace
// string_file_tests ---------------------------------------------------------------// // string_file_tests ---------------------------------------------------------------//
void string_file_tests() void string_file_tests(const path& temp_dir)
{ {
cout << "string_file_tests..." << endl; cout << "string_file_tests..." << endl;
std::string contents("0123456789"); 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 // document state of critical macros
#ifdef BOOST_POSIX_API #ifdef BOOST_POSIX_API
@ -352,6 +350,24 @@ int cpp_main(int, char*[])
cout << "current_path() is " << current_path().string() << endl; 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); create_directory(temp_dir);
file_status_test(); file_status_test();
@ -362,7 +378,7 @@ int cpp_main(int, char*[])
directory_entry_test(); directory_entry_test();
directory_entry_overload_test(); directory_entry_overload_test();
error_handling_test(); error_handling_test();
string_file_tests(); string_file_tests(temp_dir);
cout << unique_path() << endl; cout << unique_path() << endl;
cout << unique_path("foo-%%%%%-%%%%%-bar") << endl; cout << unique_path("foo-%%%%%-%%%%%-bar") << endl;