Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58606 - trunk/libs/program_options/test
From: ghost_at_[hidden]
Date: 2009-12-31 03:34:08


Author: vladimir_prus
Date: 2009-12-31 03:34:07 EST (Thu, 31 Dec 2009)
New Revision: 58606
URL: http://svn.boost.org/trac/boost/changeset/58606

Log:
Make tests works regardless of what the current directory is.

Text files modified:
   trunk/libs/program_options/test/Jamfile.v2 | 15 ++++++++-------
   trunk/libs/program_options/test/parsers_test.cpp | 8 ++++----
   trunk/libs/program_options/test/required_test.cpp | 12 ++++++------
   3 files changed, 18 insertions(+), 17 deletions(-)

Modified: trunk/libs/program_options/test/Jamfile.v2
==============================================================================
--- trunk/libs/program_options/test/Jamfile.v2 (original)
+++ trunk/libs/program_options/test/Jamfile.v2 2009-12-31 03:34:07 EST (Thu, 31 Dec 2009)
@@ -9,19 +9,20 @@
 # <define>_GLIBCXX_DEBUG
     ;
     
-rule po-test ( source )
+rule po-test ( source : input-file ? )
 {
     return
- [ run $(source) ]
- [ run $(source) : : : <link>shared <define>BOOST_PROGRAM_OPTIONS_DYN_LINK=1
- : $(source:B)_dll ]
- ;
+ [ run $(source) : : $(input-file) ]
+ [ run $(source) : : $(input-file)
+ : <link>shared <define>BOOST_PROGRAM_OPTIONS_DYN_LINK=1
+ : $(source:B)_dll ]
+ ;
 }
 
 test-suite program_options :
 
     [ po-test options_description_test.cpp ]
- [ po-test parsers_test.cpp ]
+ [ po-test parsers_test.cpp : config_test.cfg ]
     [ po-test variable_map_test.cpp ]
     [ po-test cmdline_test.cpp ]
     [ po-test positional_options_test.cpp ]
@@ -30,7 +31,7 @@
     [ po-test exception_test.cpp ]
     [ po-test split_test.cpp ]
     [ po-test unrecognized_test.cpp ]
- [ po-test required_test.cpp ]
+ [ po-test required_test.cpp : required_test.cfg ]
     ;
         
 exe test_convert : test_convert.cpp ;

Modified: trunk/libs/program_options/test/parsers_test.cpp
==============================================================================
--- trunk/libs/program_options/test/parsers_test.cpp (original)
+++ trunk/libs/program_options/test/parsers_test.cpp 2009-12-31 03:34:07 EST (Thu, 31 Dec 2009)
@@ -196,7 +196,7 @@
     BOOST_CHECK_EQUAL(a6[1].value[0], "some_file");
 }
 
-void test_config_file()
+void test_config_file(const char* config_file)
 {
     options_description desc;
     desc.add_options()
@@ -231,7 +231,7 @@
     check_value(a1[5], "m1.v2", "2");
     
     // same test, but now options come from file
- vector<option> a2 = parse_config_file<char>("config_test.cfg", desc).options;
+ vector<option> a2 = parse_config_file<char>(config_file, desc).options;
     BOOST_REQUIRE(a2.size() == 6);
     check_value(a2[0], "gv1", "0");
     check_value(a2[1], "empty_value", "");
@@ -316,10 +316,10 @@
     check_value(a3[1], "m1.v1", "1");
 }
 
-int main(int, char* [])
+int main(int, char* av[])
 {
     test_command_line();
- test_config_file();
+ test_config_file(av[1]);
     test_environment();
     test_unregistered();
     return 0;

Modified: trunk/libs/program_options/test/required_test.cpp
==============================================================================
--- trunk/libs/program_options/test/required_test.cpp (original)
+++ trunk/libs/program_options/test/required_test.cpp 2009-12-31 03:34:07 EST (Thu, 31 Dec 2009)
@@ -16,7 +16,7 @@
 
 void required_throw_test()
 {
- options_description opts;
+ options_description opts;
    opts.add_options()
      ("cfgfile,c", value<string>()->required(), "the configfile")
      ("fritz,f", value<string>()->required(), "the output file")
@@ -57,9 +57,9 @@
 
 
 
-void simple_required_test()
+void simple_required_test(const char* config_file)
 {
- options_description opts;
+ options_description opts;
    opts.add_options()
      ("cfgfile,c", value<string>()->required(), "the configfile")
      ("fritz,f", value<string>()->required(), "the output file")
@@ -75,7 +75,7 @@
       try {
          // options coming from different sources
          store(command_line_parser(tokens).options(opts).run(), vm);
- store(parse_config_file<char>("required_test.cfg", opts), vm);
+ store(parse_config_file<char>(config_file, opts), vm);
          notify(vm);
       }
       catch (required_option& e) {
@@ -87,10 +87,10 @@
 
 
 
-int main(int /*argc*/, char** /*argv*/)
+int main(int /*argc*/, char* av[])
 {
    required_throw_test();
- simple_required_test();
+ simple_required_test(av[1]);
    
    return 0;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk