boost_test_debugging.qbk 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. [/
  2. / Copyright (c) 2015 Boost.Test contributors
  3. /
  4. / Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. /]
  7. [section:debugging Debugging the assertions]
  8. In case you observe a failure in unit tests and you are using a debugger to determine the cause,
  9. it may get really difficult to step into the expression inside an assertion. Because __BOOST_TEST__
  10. builds an expression tree before evaluating it, the "Step Into" function of the debugger will have
  11. to step into every step of building the expression tree before, you can go into the evaluation of
  12. the expression.
  13. In order to mitigate the problem, the test module can be build in the mode which disables the
  14. building of expression trees inside assertions.
  15. In this mode, the first thing the assertion does is to eagerly evaluate the tested expression.
  16. You enable this mode by defining symbol __BOOST_TEST_TOOLS_UNDER_DEBUGGER__ (either with `#define`
  17. or with compiler option `-D`) prior to including any of the __UTF__ headers.
  18. [caution When the eager evaluation of expressions is turned on, the expressions are evaluated
  19. ['literally]: this automatically disables any special semantics,
  20. like tolerance for floating-point types or [classref boost::test_tools::per_element] versions
  21. of sequence comparisons. This may turn passing assertions into failing assertions and vice-versa.
  22. In the case of [classref boost::test_tools::per_element] comparisons of sequences, it may render an
  23. ill-formed program, if the sequences of different types are being compared. ]
  24. The inconvenience with __BOOST_TEST_TOOLS_UNDER_DEBUGGER__ is that you have to recompile the test module.
  25. The __UTF__ gives you another option to compile two versions of the assertions and select the one to be used dynamically
  26. depending on whether the test module is run under debugger or not.
  27. This mode is enabled by defining symbol __BOOST_TEST_TOOLS_DEBUGGABLE__ (either with `#define` or with
  28. compiler option `-D`) prior to the inclusion of any of the __UTF__ headers.
  29. In order to determine if the test module is run under debugger or not, function
  30. [link boost.debug.under_debugger `boost::debug::under_debugger`] is used.
  31. [caution At present, function [link boost.debug.under_debugger `boost::debug::under_debugger`]
  32. can correctly detect the debugger only on MSVC and a few Linux variants.]
  33. [endsect] [/ debugging]