Re: [Boost-bugs] [Boost C++ Libraries] #12953: access to master_test_suite().{argc, argv}

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12953: access to master_test_suite().{argc, argv}
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2018-06-27 06:42:18


#12953: access to master_test_suite().{argc, argv}
-------------------------------+-----------------------------
  Reporter: ope-devel@… | Owner: Raffi Enficiaud
      Type: Feature Requests | Status: assigned
 Milestone: Boost 1.66.0 | Component: test
   Version: Boost 1.63.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+-----------------------------

Comment (by ope-devel@…):

 Hello Raffi,

 thanks a lot; ''master_access_make_ds_with_arity'' solves it in the manner
 I considered to use before.

 Is it correct, that inside the BOOST_DATA_TEST_CASE I've access to
 argc/argv anywhere?

 The use case is further using an own 'reporter':

 {{{
 BOOST_DATA_TEST_CASE( foo,
       foo_dataset.input()
     ^ foo_dataset.expect()
     ^ foo_dataset.test_case_name(),
     input, expected, test_case_name)
 {
     ...
     testing_parser<attribute_type> parse;
     auto [parse_ok, parse_result] = parse(input, parser, test_case_name);

     BOOST_TEST(parse_ok);
     BOOST_REQUIRE_MESSAGE(parse_ok,
         report_diagnostic(test_case_name, input, parse_result)
     );

     BOOST_TEST(parse_result == expected, btt::per_element());
     BOOST_REQUIRE_MESSAGE(current_test_passing(),
         report_diagnostic(test_case_name, input, parse_result)
     );
 }
 }}}

 where

 {{{
 std::string report_diagnostic(
     fs::path const& test_case_name,
     std::string const& input,
     std::string const& result
 )
 {
     ...
     // only write in case of failed test
     if(!current_test_passing()) {
         test_case_result_writer result_writer(test_case_name);
         result_writer.write(result);
     }
     return ss.str();
 }
 }}}

 where the path to be written (is hardcoded at this time) shall be given as
 argv too.

 {{{
 struct test_case_result_writer
 {
 test_case_result_writer(fs::path const& test_case)
 : m_dest_dir{ CMAKE_BT_TEST_CASE_WRITE_PATH } // ARGV[4]
 , m_test_case{ test_case }
 { /* FixMe: Gather write path 'm_dest_dir' from argv */}
 ....

 void write(std::string const& parse_result)
 {
     fs::path const full_pathname = m_dest_dir / "test_case" / m_test_case;
     fs::path const write_path = full_pathname.parent_path();
     std::string const ext{ ".parsed" };

     if(!create_directory(write_path)) { ... }
     fs::path const filename =
 full_pathname.filename().replace_extension(ext);
     write_file(write_path / filename, parse_result);
 }

 }}}

 So the dataset_loader can be used independing of what to check/load.

 One point using ''dataset-master-test-suite-accessible-test.cpp'':

 {{{
> bin\bt_issue12953.exe -- --param1=1 --param2=2
 Running 22 test cases...

 *** No errors detected
 }}}

 but:

 {{{
 bin\bt_issue12953.exe --list_content
 Test setup error: Can't zip datasets of different sizes
 }}}

 How to handle this?

 Best,
 Olaf

 PS: As you can see ''current_test_passing()'' serves arround another
 problem not related to the feature request.

-- 
Ticket URL: <https://svn.boost.org/trac10/ticket/12953#comment:12>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2018-06-27 06:47:23 UTC