-
Notifications
You must be signed in to change notification settings - Fork 71
/
cyclus_default_unit_test_driver.cc
48 lines (43 loc) · 2.71 KB
/
cyclus_default_unit_test_driver.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <string>
#include <stdio.h>
#include <gtest/gtest.h>
#include "env.h"
#include "logger.h"
int main(int argc, char* argv[]) {
// tell ENV the path between the cwd and the cyclus executable
using cyclus::Env;
using cyclus::Logger;
std::string path = Env::PathBase(argv[0]);
Logger::ReportLevel() = cyclus::LEV_ERROR;
// add the build path to the environment for testing
std::string test_env = "CYCLUS_PATH=" + Env::GetBuildPath();
std::string curr_var = Env::GetEnv("CYCLUS_PATH");
if (curr_var != "") {
test_env += ":" + curr_var;
}
putenv(const_cast<char *>(test_env.c_str()));
for ( int i = 0; i < argc; i++ ) {
std::string arg = argv[i];
if ( arg == "--help" ) {
std::cout << "GTest flags" << std::endl;
std::cout << "\t--gtest_list_tests List the tests" << std::endl;
std::cout << "\t--gtest_repeat Number of times to repeat each test" << std::endl;
std::cout << "\t--gtest_filter Glob filter of test name" << std::endl;
std::cout << "\t--gtest_print_time Time required to run" << std::endl;
std::cout << "\nBy default, a Google Test program runs all tests the user has defined. Sometimes, you want to run only a subset of the tests (e.g. for debugging or quickly verifying a change). If you set the GTEST_FILTER environment variable or the --gtest_filter flag to a filter string, Google Test will only run the tests whose full names (in the form of TestCaseName.TestName) match the filter.\n"
"The format of a filter is a ':'-separated list of wildcard patterns (called the positive patterns) optionally followed by a '-' and another ':'-separated pattern list (called the negative patterns). A test matches the filter if and only if it matches any of the positive patterns but does not match any of the negative patterns.\n"
"A pattern may contain '*' (matches any string) or '?' (matches any single character). For convenience, the filter '*-NegativePatterns' can be also written as '-NegativePatterns'.\n"
"For example:\n\n"
" * ./foo_test Has no flag, and thus runs all its tests.\n"
" * ./foo_test --gtest_filter=* Also runs everything, due to the single match-everything * value.\n"
" * ./foo_test --gtest_filter=FooTest.* Runs everything in test case FooTest.\n"
" * ./foo_test --gtest_filter=*Null*:*Constructor* Runs any test whose full name contains either \"Null\" or \"Constructor\".\n"
" * ./foo_test --gtest_filter=-*DeathTest.* Runs all non-death tests.\n"
" * ./foo_test --gtest_filter=FooTest.*-FooTest.Bar Runs everything in test case FooTest except FooTest.Bar. " << std::endl;
return 0;
}
}
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}