Skip to content

Commit 84996ea

Browse files
authored
Count (unexpected) escaping exceptions as a test failure. (#316)
* Split 'Setup dependencies' step. * Count (unepected) escaping expections as a test failure. * Improve error message formating. * Log std::exception::what() in LT_ASSERT_NOTHROW. * Fix setup steps. Fix an oops and remove success()
1 parent 82ae1f0 commit 84996ea

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

.github/workflows/verify-build.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,17 @@ jobs:
368368
run: brew install autoconf automake libtool
369369
if: ${{ matrix.os == 'macos-latest' }}
370370

371-
- name: Setup coverage dependencies (only on linux)
371+
- name: Setup dependencies (only on linux)
372372
run: |
373373
sudo apt-get install info install-info ;
374-
sudo pip install gcovr ;
375374
sudo apt-get install cppcheck ;
376375
if: ${{ matrix.os-type == 'ubuntu' }}
377376

377+
- name: Setup coverage dependencies (only on linux)
378+
run: |
379+
sudo pip install gcovr ;
380+
if: ${{ matrix.os-type == 'ubuntu' && matrix.c-compiler == 'gcc' && matrix.debug == 'debug' && matrix.coverage == 'coverage' }}
381+
378382
- name: Setup gnutls dependency (only on linux)
379383
run: |
380384
sudo apt-get install libgnutls28-dev ;

test/littletest.hpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@
125125
{ \
126126
(__lt_operation__) ;\
127127
} \
128+
catch(std::exception& e) \
129+
{ \
130+
std::stringstream __lt_ss__; \
131+
__lt_ss__ << "(" << __lt_file__ << ":" << __lt_line__ << ") - error in " << "\"" << __lt_name__ << "\": exceptions thown by " << #__lt_operation__; \
132+
__lt_ss__ << " [ " << e.what() << " ]"; \
133+
LT_SWITCH_MODE(__lt_mode__) \
134+
} \
128135
catch(...) \
129136
{ \
130137
std::stringstream __lt_ss__; \
@@ -522,12 +529,14 @@ class test : public test_base
522529
}
523530
catch(std::exception& e)
524531
{
525-
std::cout << "Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " set up" << std::endl;
532+
std::cout << "[FAILURE] Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " set up" << std::endl;
526533
std::cout << e.what() << std::endl;
534+
tr->add_failure();
527535
}
528536
catch(...)
529537
{
530-
std::cout << "Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " set up" << std::endl;
538+
std::cout << "[FAILURE] Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " set up" << std::endl;
539+
tr->add_failure();
531540
}
532541
try
533542
{
@@ -540,16 +549,18 @@ class test : public test_base
540549
}
541550
catch(std::exception& e)
542551
{
543-
std::cout << "Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " run" << std::endl;
552+
std::cout << "[FAILURE] Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " run" << std::endl;
544553
std::cout << e.what() << std::endl;
545554
if(tr->last_checkpoint_line != -1)
546555
std::cout << "Last checkpoint in " << tr->last_checkpoint_file << ":" << tr->last_checkpoint_line << std::endl;
556+
tr->add_failure();
547557
}
548558
catch(...)
549559
{
550-
std::cout << "Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " run" << std::endl;
560+
std::cout << "[FAILURE] Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " run" << std::endl;
551561
if(tr->last_checkpoint_line != -1)
552562
std::cout << "Last checkpoint in " << tr->last_checkpoint_file << ":" << tr->last_checkpoint_line << std::endl;
563+
tr->add_failure();
553564
}
554565
gettimeofday(&after, NULL);
555566

@@ -569,12 +580,14 @@ class test : public test_base
569580
}
570581
catch(std::exception& e)
571582
{
572-
std::cout << "Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " tear down" << std::endl;
583+
std::cout << "[FAILURE] Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " tear down" << std::endl;
573584
std::cout << e.what() << std::endl;
585+
tr->add_failure();
574586
}
575587
catch(...)
576588
{
577-
std::cout << "Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " tear down" << std::endl;
589+
std::cout << "[FAILURE] Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " tear down" << std::endl;
590+
tr->add_failure();
578591
}
579592
double total = set_up_duration + test_duration + tear_down_duration;
580593
tr->add_total_time(total);

0 commit comments

Comments
 (0)