Debugging at home

Sorry if this has been brought up before but is there a way to use a debugging tool locally? All the code can seem fine but fail a test. If that happens the project won’t build so I can’t debug. Is there a way around this? Debugging to see why a test failed worked fine on the C track.

I’m not sure I understand.
Are you talking about code that does not compile, or code that compiles but does not pass the tests?

If there are compilation errors you will have to look at the error messages and try to fix them.
If the code compiles you can debug it like any other program.

I’m not sure I understand either.

If you want to use the online editor, you can see the output of std::cout for the failed exercises.

In a nutshell I’m talking about catching semantic errors. It is possible to copy source and header file to a new project and write my own main then use a debugging tool there. Using cout all over the place is not fun. On the C track a test could fail and still the project would be built and I could watch variables. On the C++ track a failed test prevents a build.

Using a bad example (I can’t think of a specific one from an exercise right now), the goal might be to multiply some the input by 2.5 deep in a process. The code that’s written multiplies by 2, (whoops! shouldn’t have that result defined as an int) so the wrong result is being produced. If a test fails the project won’t build and you can’t watch variables. Yes, you can usually see the result in the test output but in more complicated code that might not be very helpful. You can also debug with many print statements but that is tedious. How do you catch semantic errors?

I’m not suggesting rewriting all the *_test.cpp but was hoping someone who know more about the test framework might know some preprocessor directives or something that could run the code inside a test and continue with the build even if a test failed.

You could move the #if defined(EXERCISM_RUN_ALL_TESTS) for each test. Everything that is inside the definition is ignored if you do not pass the flag to the compiler. So you can build even if some parts are not yet done.
That is the whole reason the macro is there in the first place.

You do not need to rewrite the whole test file, just move that line.

Yeah but the thing is that I don’t really care about the debugging the tests that pass, it’s the ones that fail that I want to debug

1 Like