Skip to content

Commit

Permalink
Count (unexpected) escaping exceptions as a test failure. (#316)
Browse files Browse the repository at this point in the history
* 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()
  • Loading branch information
bcsgh committed May 5, 2023
1 parent 82ae1f0 commit 84996ea
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/verify-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,17 @@ jobs:
run: brew install autoconf automake libtool
if: ${{ matrix.os == 'macos-latest' }}

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

- name: Setup coverage dependencies (only on linux)
run: |
sudo pip install gcovr ;
if: ${{ matrix.os-type == 'ubuntu' && matrix.c-compiler == 'gcc' && matrix.debug == 'debug' && matrix.coverage == 'coverage' }}

- name: Setup gnutls dependency (only on linux)
run: |
sudo apt-get install libgnutls28-dev ;
Expand Down
25 changes: 19 additions & 6 deletions test/littletest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@
{ \
(__lt_operation__) ;\
} \
catch(std::exception& e) \
{ \
std::stringstream __lt_ss__; \
__lt_ss__ << "(" << __lt_file__ << ":" << __lt_line__ << ") - error in " << "\"" << __lt_name__ << "\": exceptions thown by " << #__lt_operation__; \
__lt_ss__ << " [ " << e.what() << " ]"; \
LT_SWITCH_MODE(__lt_mode__) \
} \
catch(...) \
{ \
std::stringstream __lt_ss__; \
Expand Down Expand Up @@ -522,12 +529,14 @@ class test : public test_base
}
catch(std::exception& e)
{
std::cout << "Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " set up" << std::endl;
std::cout << "[FAILURE] Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " set up" << std::endl;
std::cout << e.what() << std::endl;
tr->add_failure();
}
catch(...)
{
std::cout << "Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " set up" << std::endl;
std::cout << "[FAILURE] Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " set up" << std::endl;
tr->add_failure();
}
try
{
Expand All @@ -540,16 +549,18 @@ class test : public test_base
}
catch(std::exception& e)
{
std::cout << "Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " run" << std::endl;
std::cout << "[FAILURE] Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " run" << std::endl;
std::cout << e.what() << std::endl;
if(tr->last_checkpoint_line != -1)
std::cout << "Last checkpoint in " << tr->last_checkpoint_file << ":" << tr->last_checkpoint_line << std::endl;
tr->add_failure();
}
catch(...)
{
std::cout << "Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " run" << std::endl;
std::cout << "[FAILURE] Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " run" << std::endl;
if(tr->last_checkpoint_line != -1)
std::cout << "Last checkpoint in " << tr->last_checkpoint_file << ":" << tr->last_checkpoint_line << std::endl;
tr->add_failure();
}
gettimeofday(&after, NULL);

Expand All @@ -569,12 +580,14 @@ class test : public test_base
}
catch(std::exception& e)
{
std::cout << "Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " tear down" << std::endl;
std::cout << "[FAILURE] Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " tear down" << std::endl;
std::cout << e.what() << std::endl;
tr->add_failure();
}
catch(...)
{
std::cout << "Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " tear down" << std::endl;
std::cout << "[FAILURE] Exception during " << static_cast<test_impl* >(this)->__lt_name__ << " tear down" << std::endl;
tr->add_failure();
}
double total = set_up_duration + test_duration + tear_down_duration;
tr->add_total_time(total);
Expand Down

0 comments on commit 84996ea

Please sign in to comment.