Skip to content

Commit 85b2b1c

Browse files
committed
Make tests works regardless of what the current directory is.
[SVN r58606]
1 parent 524460c commit 85b2b1c

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

test/Jamfile.v2

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@ project
99
# <define>_GLIBCXX_DEBUG
1010
;
1111

12-
rule po-test ( source )
12+
rule po-test ( source : input-file ? )
1313
{
1414
return
15-
[ run $(source) ]
16-
[ run $(source) : : : <link>shared <define>BOOST_PROGRAM_OPTIONS_DYN_LINK=1
17-
: $(source:B)_dll ]
18-
;
15+
[ run $(source) : : $(input-file) ]
16+
[ run $(source) : : $(input-file)
17+
: <link>shared <define>BOOST_PROGRAM_OPTIONS_DYN_LINK=1
18+
: $(source:B)_dll ]
19+
;
1920
}
2021

2122
test-suite program_options :
2223

2324
[ po-test options_description_test.cpp ]
24-
[ po-test parsers_test.cpp ]
25+
[ po-test parsers_test.cpp : config_test.cfg ]
2526
[ po-test variable_map_test.cpp ]
2627
[ po-test cmdline_test.cpp ]
2728
[ po-test positional_options_test.cpp ]
@@ -30,7 +31,7 @@ test-suite program_options :
3031
[ po-test exception_test.cpp ]
3132
[ po-test split_test.cpp ]
3233
[ po-test unrecognized_test.cpp ]
33-
[ po-test required_test.cpp ]
34+
[ po-test required_test.cpp : required_test.cfg ]
3435
;
3536

3637
exe test_convert : test_convert.cpp ;

test/parsers_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void test_command_line()
196196
BOOST_CHECK_EQUAL(a6[1].value[0], "some_file");
197197
}
198198

199-
void test_config_file()
199+
void test_config_file(const char* config_file)
200200
{
201201
options_description desc;
202202
desc.add_options()
@@ -231,7 +231,7 @@ void test_config_file()
231231
check_value(a1[5], "m1.v2", "2");
232232

233233
// same test, but now options come from file
234-
vector<option> a2 = parse_config_file<char>("config_test.cfg", desc).options;
234+
vector<option> a2 = parse_config_file<char>(config_file, desc).options;
235235
BOOST_REQUIRE(a2.size() == 6);
236236
check_value(a2[0], "gv1", "0");
237237
check_value(a2[1], "empty_value", "");
@@ -316,10 +316,10 @@ void test_unregistered()
316316
check_value(a3[1], "m1.v1", "1");
317317
}
318318

319-
int main(int, char* [])
319+
int main(int, char* av[])
320320
{
321321
test_command_line();
322-
test_config_file();
322+
test_config_file(av[1]);
323323
test_environment();
324324
test_unregistered();
325325
return 0;

test/required_test.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ using namespace std;
1616

1717
void required_throw_test()
1818
{
19-
options_description opts;
19+
options_description opts;
2020
opts.add_options()
2121
("cfgfile,c", value<string>()->required(), "the configfile")
2222
("fritz,f", value<string>()->required(), "the output file")
@@ -57,9 +57,9 @@ void required_throw_test()
5757

5858

5959

60-
void simple_required_test()
60+
void simple_required_test(const char* config_file)
6161
{
62-
options_description opts;
62+
options_description opts;
6363
opts.add_options()
6464
("cfgfile,c", value<string>()->required(), "the configfile")
6565
("fritz,f", value<string>()->required(), "the output file")
@@ -75,7 +75,7 @@ void simple_required_test()
7575
try {
7676
// options coming from different sources
7777
store(command_line_parser(tokens).options(opts).run(), vm);
78-
store(parse_config_file<char>("required_test.cfg", opts), vm);
78+
store(parse_config_file<char>(config_file, opts), vm);
7979
notify(vm);
8080
}
8181
catch (required_option& e) {
@@ -87,10 +87,10 @@ void simple_required_test()
8787

8888

8989

90-
int main(int /*argc*/, char** /*argv*/)
90+
int main(int /*argc*/, char* av[])
9191
{
9292
required_throw_test();
93-
simple_required_test();
93+
simple_required_test(av[1]);
9494

9595
return 0;
9696
}

0 commit comments

Comments
 (0)