Browse Source

Nice Error Report

cl-refactor
Dimitry 10 years ago
parent
commit
7e300407df
  1. 26
      test/TestHelper.cpp
  2. 8
      test/TestHelper.h
  3. 4
      test/fuzzTesting/fuzzHelper.cpp

26
test/TestHelper.cpp

@ -258,7 +258,11 @@ void ImportTest::compareStates(State const& _stateExpect, State const& _statePos
#define CHECK(a,b) \ #define CHECK(a,b) \
{ \ { \
if (_throw == WhenError::Throw) \ if (_throw == WhenError::Throw) \
{TBOOST_CHECK_MESSAGE(a,b);}\ { \
TBOOST_CHECK(a); \
if (!a) \
std::cerr << b << std::endl;\
} \
else \ else \
{TBOOST_WARN_MESSAGE(a,b);} \ {TBOOST_WARN_MESSAGE(a,b);} \
} }
@ -773,7 +777,27 @@ Options::Options()
} }
else if (arg == "--fulloutput") else if (arg == "--fulloutput")
fulloutput = true; fulloutput = true;
else if (arg == "--verbosity" && i + 1 < argc)
{
static std::ostringstream strCout;
std::string depthLevel = std::string{argv[i + 1]};
if (depthLevel == "0")
{
logVerbosity = Verbosity::None;
std::cout.rdbuf( strCout.rdbuf() );
std::cerr.rdbuf( strCout.rdbuf() );
}
else
if (depthLevel == "1")
logVerbosity = Verbosity::NiceReport;
else
logVerbosity = Verbosity::Full;
}
} }
//Default option
if (logVerbosity == Verbosity::NiceReport)
g_logVerbosity = -1; //disable cnote but not the cerr
} }
Options const& Options::get() Options const& Options::get()

8
test/TestHelper.h

@ -218,6 +218,13 @@ void checkAddresses(mapType& _expectedAddrs, mapType& _resultAddrs)
TBOOST_CHECK((_expectedAddrs == _resultAddrs)); TBOOST_CHECK((_expectedAddrs == _resultAddrs));
}*/ }*/
enum class Verbosity
{
Full,
NiceReport,
None
};
class Options class Options
{ {
public: public:
@ -227,6 +234,7 @@ public:
std::string statsOutFile; ///< Stats output file. "out" for standard output std::string statsOutFile; ///< Stats output file. "out" for standard output
bool checkState = false;///< Throw error when checking test states bool checkState = false;///< Throw error when checking test states
bool fulloutput = false;///< Replace large output to just it's length bool fulloutput = false;///< Replace large output to just it's length
Verbosity logVerbosity = Verbosity::NiceReport;
/// Test selection /// Test selection
/// @{ /// @{

4
test/fuzzTesting/fuzzHelper.cpp

@ -408,7 +408,7 @@ BOOST_AUTO_TEST_SUITE(RandomCodeTests)
BOOST_AUTO_TEST_CASE(rndCode) BOOST_AUTO_TEST_CASE(rndCode)
{ {
std::string code; std::string code;
std::cerr << "Testing Random Code: "; std::cout << "Testing Random Code: ";
try try
{ {
code = dev::test::RandomCode::generate(10); code = dev::test::RandomCode::generate(10);
@ -417,7 +417,7 @@ BOOST_AUTO_TEST_CASE(rndCode)
{ {
BOOST_ERROR("Exception thrown when generating random code!"); BOOST_ERROR("Exception thrown when generating random code!");
} }
std::cerr << code; std::cout << code;
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

Loading…
Cancel
Save