Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abort on fail not working #150

Open
hl037 opened this issue Mar 17, 2021 · 1 comment
Open

Abort on fail not working #150

hl037 opened this issue Mar 17, 2021 · 1 comment

Comments

@hl037
Copy link

hl037 commented Mar 17, 2021

I tried to run this unit test (ttt.hpp):

#include <cxxtest/TestSuite.h>

class TestT : public CxxTest::TestSuite{
public:
  void test_t1(){
    TS_ASSERT_EQUALS(0,1);
  }
  void test_t2(){
    TS_ASSERT_EQUALS(0,1);
  }
  void test_t3(){
    TS_ASSERT_EQUALS(0,1);
  }
  void test_t4(){
    TS_ASSERT_EQUALS(0,1);
  }
  
};

by executing :

cxxtestgen --error-printer --have-eh --abort-on-fail -o testrunner_abort.cpp ttt.hpp
g++ -O0 testrunner_abort.cpp -o aa.out
./a.out

but It does not abort on any fail as the documentation says :

Running cxxtest tests (4 tests)
In TestT::test_t1:
ttt.hpp:6: Error: Expected (0 == 1), found (0 != 1)
In TestT::test_t2:
ttt.hpp:9: Error: Expected (0 == 1), found (0 != 1)
In TestT::test_t3:
ttt.hpp:12: Error: Expected (0 == 1), found (0 != 1)
In TestT::test_t4:
ttt.hpp:15: Error: Expected (0 == 1), found (0 != 1)
Failed 4 and Skipped 0 of 4 tests
Success rate: 0%

(I also tried to exec it with gdb and nothing is reported, the program exit normally with only the exit code non zero, but nothing about an abort...)

This may be caused by the "do nothing" at this line : https://github.com/CxxTest/cxxtest/blob/master/cxxtest/RealDescriptions.cpp#L122

@hl037
Copy link
Author

hl037 commented Mar 17, 2021

By the way, why throwing and catching an exception on abort ?

I think, the goal of aborting on fail is to be able to use a debugger to stop where the problem is... Thus why not simply call std::abort() (or a user-defined abort function if no std libs) in TestSuite::doAbortTest?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant