Skip to content

Commit

Permalink
Pass input files properly via the run rule
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Nov 13, 2017
1 parent f983eef commit 2434bc8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 42 deletions.
4 changes: 2 additions & 2 deletions test/Jamfile.v2
Expand Up @@ -150,7 +150,7 @@ local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <defi
: : : $(DATE_TIME_PROPERTIES) ]
[ run local_time/testtz_database.cpp
../build//boost_date_time/<link>static
: : : $(DATE_TIME_PROPERTIES) ]
: : ../data/date_time_zonespec.csv local_time/poorly_formed_zonespec.csv : $(DATE_TIME_PROPERTIES) ]
[ run local_time/testlocal_time.cpp
../build//boost_date_time/<link>static
: : : $(DATE_TIME_PROPERTIES) ]
Expand All @@ -163,7 +163,7 @@ local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <defi
### streaming
[ run local_time/testlocal_time_facet.cpp
../build//boost_date_time/<link>static
: : : $(DATE_TIME_PROPERTIES) ]
: : ../data/date_time_zonespec.csv : $(DATE_TIME_PROPERTIES) ]
[ run local_time/testlocal_time_input_facet.cpp
../build//boost_date_time/<link>static
: : : $(DATE_TIME_PROPERTIES) ]
Expand Down
15 changes: 4 additions & 11 deletions test/local_time/testlocal_time_facet.cpp
Expand Up @@ -34,7 +34,7 @@ teststreaming(std::string const& testname,
#endif
}

int main(){
int main(int argc, char const* argv[]){
/* use the tz_database for the time zones.
* Chicago, Denver, Los_Angeles, New_Tork, and Phoenix
* have all had full names added */
Expand All @@ -47,18 +47,11 @@ int main(){

try {
// first try to find the data file from the test dir
time_zones.load_from_file("../data/date_time_zonespec.csv");
time_zones.load_from_file(argv[1]);
}
catch(const data_not_accessible&) {
// couldn't find the data file so assume we are being run from
// boost_root/status and try again
try {
time_zones.load_from_file("../libs/date_time/data/date_time_zonespec.csv");
}
catch(const data_not_accessible&) {
check("Cannot locate data file - aborting.", false);
return printTestStats();
}
check("Cannot locate data file - aborting.", false);
return printTestStats();
}

time_zone_ptr utc;
Expand Down
36 changes: 7 additions & 29 deletions test/local_time/testtz_database.cpp
Expand Up @@ -15,13 +15,13 @@
#include "boost/date_time/local_time/posix_time_zone.hpp"
#include <iostream>

bool run_bad_field_count_test();
bool run_bad_field_count_test(char const* fn);

int main(){
int main(int argc, char const* argv[]){
using namespace boost::gregorian;
using namespace boost::posix_time;
using namespace boost::local_time;

/* NOTE: The testlocal_time_facet tests required full names
* be added to some of the date_time_zonespec.csv entries. The
* tests here also use those full names. Those entries are:
Expand All @@ -37,25 +37,11 @@ int main(){
}catch(...){
check("Caught first unexpected exception", false);
}
check("Caught Bad field count exception", run_bad_field_count_test());
check("Caught Bad field count exception", run_bad_field_count_test(argv[2]));

/* This test-file is usually run from either $BOOST_ROOT/status, or
* $BOOST_ROOT/libs/date_time/test. Therefore, the relative path
* to the data file this test depends on will be one of two
* possible paths.
*
* If the first attempt at opening the data file fails, an exception
* will be thrown. The handling of that exception consists of
* attempting to open it again but from a different location. If that
* also fails, we abort the test. */
tz_database tz_db;
try {
// first try to find the data file from the test dir
tz_db.load_from_file("../data/date_time_zonespec.csv");
}catch(data_not_accessible&) {
// couldn't find the data file so assume we are being run from
// boost_root/status and try again
tz_db.load_from_file("../libs/date_time/data/date_time_zonespec.csv");
tz_db.load_from_file(argv[1]);
}catch(...) {
check("Cannot locate data file - aborting.", false);
return printTestStats();
Expand Down Expand Up @@ -114,25 +100,17 @@ int main(){
/* This test only checks to make sure the bad_field_count exception
* is properly thrown. It does not pay any attention to any other
* exception, those are tested elsewhere. */
bool run_bad_field_count_test()
bool run_bad_field_count_test(char const* fn)
{
using namespace boost::local_time;
bool caught_bfc = false;
tz_database other_db;
try{
other_db.load_from_file("local_time/poorly_formed_zonespec.csv");
}catch(bad_field_count&){
caught_bfc = true;
}catch(...) {
// do nothing (file not found)
}
try{
other_db.load_from_file("../libs/date_time/test/local_time/poorly_formed_zonespec.csv");
other_db.load_from_file(fn);
}catch(bad_field_count&){
caught_bfc = true;
}catch(...) {
// do nothing (file not found)
}
return caught_bfc;
}

0 comments on commit 2434bc8

Please sign in to comment.