Merge pull request #409 from apir8181/issue-344

Issue 344 - Better boost test output
This commit is contained in:
Ryan Curtin
2015-02-24 11:16:14 -05:00
3 changed files with 39 additions and 3 deletions
+6
View File
@@ -15,6 +15,7 @@ option(DEBUG "Compile with debugging information" ON)
option(PROFILE "Compile with profiling information" ON)
option(ARMA_EXTRA_DEBUG "Compile with extra Armadillo debugging symbols." OFF)
option(MATLAB_BINDINGS "Compile MATLAB bindings if MATLAB is found." OFF)
option(TEST_VERBOSE "Running test cases with verbose ouput" OFF)
# This is as of yet unused.
#option(PGO "Use profile-guided optimization if not a debug build" ON)
@@ -55,6 +56,11 @@ if(CMAKE_COMPILER_IS_GNUCC AND PROFILE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
endif(CMAKE_COMPILER_IS_GNUCC AND PROFILE)
# If the user asked for running test cases with verbose output, turn that on.
if(TEST_VERBOSE)
add_definitions(-DTEST_VERBOSE)
endif(TEST_VERBOSE)
# If the user asked for extra Armadillo debugging output, turn that on.
if(ARMA_EXTRA_DEBUG)
add_definitions(-DARMA_EXTRA_DEBUG)
+1 -1
View File
@@ -77,7 +77,7 @@ add_dependencies(mlpack mlpack_headers)
# For 'make test'.
add_custom_target(test
${CMAKE_BINARY_DIR}/bin/mlpack_test
${CMAKE_BINARY_DIR}/bin/mlpack_test "--log_level=test_suite" # Set UTF runtime param
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/ # This is where test files are put.
COMMENT "Running MLPACK test"
DEPENDS mlpack_test)
+32 -2
View File
@@ -1,11 +1,14 @@
/**
* @file mlpack_test.cpp
*
* Simple file defining the name of the overall test for MLPACK. Each
* individual test is contained in its own file.
* Simple file defining the name of the overall test for MLPACK, and set up
* global test fixture for each test. Each individual test is contained in
* its own file.
*/
#define BOOST_TEST_MODULE MLPACKTest
#include <mlpack/core/util/log.hpp>
#include <boost/version.hpp>
// We only need to do this for old Boost versions.
@@ -15,3 +18,30 @@
#include <boost/test/unit_test.hpp>
#include "old_boost_test_definitions.hpp"
/**
* Provide a global fixture for each test.
*
* A global fixture is expected to be implemented as a class where the class
* constructor serves as a setup method and class destructor serves as teardown
* method.
*
* By default, Log::objects should have their output redirected, otherwise
* the UTF test output would be drown out by Log::Debug and Log::Warn messages.
*
* For more detailed test output, set cmake flag TEST_VERBOSE=ON.
*/
struct GlobalFixture {
GlobalFixture()
{
#ifndef TEST_VERBOSE
#ifdef DEBUG
mlpack::Log::Debug.ignoreInput = true;
#endif
mlpack::Log::Info.ignoreInput = true;
mlpack::Log::Warn.ignoreInput = true;
#endif
}
};
BOOST_GLOBAL_FIXTURE(GlobalFixture);