merges-7
This commit is contained in:
parent
ae4480f923
commit
995a9dfa69
|
@ -2912,16 +2912,20 @@ static int GetBitOffset(WORD color_mask) {
|
|||
|
||||
static WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
|
||||
// Let's reuse the BG
|
||||
static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||
static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||
static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN |
|
||||
BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||
static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN |
|
||||
FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||
const WORD existing_bg = old_color_attrs & background_mask;
|
||||
|
||||
WORD new_color = GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY;
|
||||
WORD new_color =
|
||||
GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY;
|
||||
static const int bg_bitOffset = GetBitOffset(background_mask);
|
||||
static const int fg_bitOffset = GetBitOffset(foreground_mask);
|
||||
|
||||
if (((new_color & background_mask) >> bg_bitOffset) == ((new_color & foreground_mask) >> fg_bitOffset)) {
|
||||
new_color ^= FOREGROUND_INTENSITY; //invert intensity
|
||||
if (((new_color & background_mask) >> bg_bitOffset) ==
|
||||
((new_color & foreground_mask) >> fg_bitOffset)) {
|
||||
new_color ^= FOREGROUND_INTENSITY; // invert intensity
|
||||
}
|
||||
return new_color;
|
||||
}
|
||||
|
@ -2982,7 +2986,6 @@ bool ShouldUseColor(bool stdout_is_tty) {
|
|||
// cannot simply emit special characters and have the terminal change colors.
|
||||
// This routine must actually emit the characters rather than return a string
|
||||
// that would be colored when printed, as can be done on Linux.
|
||||
GTEST_ATTRIBUTE_PRINTF_(2, 3)
|
||||
static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
@ -3749,7 +3752,6 @@ void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream,
|
|||
OutputXmlAttribute(stream, kTestsuites, "random_seed",
|
||||
StreamableToString(unit_test.random_seed()));
|
||||
}
|
||||
|
||||
*stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());
|
||||
|
||||
OutputXmlAttribute(stream, kTestsuites, "name", "AllTests");
|
||||
|
@ -4210,9 +4212,10 @@ void OsStackTraceGetter::UponLeavingGTest() {}
|
|||
class ScopedPrematureExitFile {
|
||||
public:
|
||||
explicit ScopedPrematureExitFile(const char* premature_exit_filepath)
|
||||
: premature_exit_filepath_(premature_exit_filepath) {
|
||||
: premature_exit_filepath_(premature_exit_filepath ?
|
||||
premature_exit_filepath : "") {
|
||||
// If a path to the premature-exit file is specified...
|
||||
if (premature_exit_filepath != NULL && *premature_exit_filepath != '\0') {
|
||||
if (!premature_exit_filepath_.empty()) {
|
||||
// create the file with a single "0" character in it. I/O
|
||||
// errors are ignored as there's nothing better we can do and we
|
||||
// don't want to fail the test because of this.
|
||||
|
@ -4223,13 +4226,18 @@ class ScopedPrematureExitFile {
|
|||
}
|
||||
|
||||
~ScopedPrematureExitFile() {
|
||||
if (premature_exit_filepath_ != NULL && *premature_exit_filepath_ != '\0') {
|
||||
remove(premature_exit_filepath_);
|
||||
if (!premature_exit_filepath_.empty()) {
|
||||
int retval = remove(premature_exit_filepath_.c_str());
|
||||
if (retval) {
|
||||
GTEST_LOG_(ERROR) << "Failed to remove premature exit filepath \""
|
||||
<< premature_exit_filepath_ << "\" with error "
|
||||
<< retval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const char* const premature_exit_filepath_;
|
||||
const std::string premature_exit_filepath_;
|
||||
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile);
|
||||
};
|
||||
|
@ -4897,13 +4905,8 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); }
|
|||
// All other functions called from RunAllTests() may safely assume that
|
||||
// parameterized tests are ready to be counted and run.
|
||||
bool UnitTestImpl::RunAllTests() {
|
||||
// Makes sure InitGoogleTest() was called.
|
||||
if (!GTestIsInitialized()) {
|
||||
GTEST_LOG_(ERROR) <<
|
||||
"\nThis test program did NOT call ::testing::InitGoogleTest "
|
||||
"before calling RUN_ALL_TESTS(). Please fix it.";
|
||||
return false;
|
||||
}
|
||||
// True iff Google Test is initialized before RUN_ALL_TESTS() is called.
|
||||
const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized();
|
||||
|
||||
// Do not run any test if the --help flag was specified.
|
||||
if (g_help_flag)
|
||||
|
@ -5031,6 +5034,20 @@ bool UnitTestImpl::RunAllTests() {
|
|||
|
||||
repeater->OnTestProgramEnd(*parent_);
|
||||
|
||||
if (!gtest_is_initialized_before_run_all_tests) {
|
||||
ColoredPrintf(
|
||||
COLOR_RED,
|
||||
"\nIMPORTANT NOTICE - DO NOT IGNORE:\n"
|
||||
"This test program did NOT call " GTEST_INIT_GOOGLE_TEST_NAME_
|
||||
"() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_
|
||||
" will start to enforce the valid usage. "
|
||||
"Please fix it ASAP, or IT WILL START TO FAIL.\n"); // NOLINT
|
||||
#if GTEST_FOR_GOOGLE_
|
||||
ColoredPrintf(COLOR_RED,
|
||||
"For more details, see http://wiki/Main/ValidGUnitMain.\n");
|
||||
#endif // GTEST_FOR_GOOGLE_
|
||||
}
|
||||
|
||||
return !failed;
|
||||
}
|
||||
|
||||
|
@ -5077,7 +5094,7 @@ bool ShouldShard(const char* total_shards_env,
|
|||
<< "Invalid environment variables: you have "
|
||||
<< kTestShardIndex << " = " << shard_index
|
||||
<< ", but have left " << kTestTotalShards << " unset.\n";
|
||||
ColoredPrintf(COLOR_RED, "%s", msg.GetString().c_str());
|
||||
ColoredPrintf(COLOR_RED, msg.GetString().c_str());
|
||||
fflush(stdout);
|
||||
exit(EXIT_FAILURE);
|
||||
} else if (total_shards != -1 && shard_index == -1) {
|
||||
|
@ -5085,7 +5102,7 @@ bool ShouldShard(const char* total_shards_env,
|
|||
<< "Invalid environment variables: you have "
|
||||
<< kTestTotalShards << " = " << total_shards
|
||||
<< ", but have left " << kTestShardIndex << " unset.\n";
|
||||
ColoredPrintf(COLOR_RED, "%s", msg.GetString().c_str());
|
||||
ColoredPrintf(COLOR_RED, msg.GetString().c_str());
|
||||
fflush(stdout);
|
||||
exit(EXIT_FAILURE);
|
||||
} else if (shard_index < 0 || shard_index >= total_shards) {
|
||||
|
@ -5094,7 +5111,7 @@ bool ShouldShard(const char* total_shards_env,
|
|||
<< kTestShardIndex << " < " << kTestTotalShards
|
||||
<< ", but you have " << kTestShardIndex << "=" << shard_index
|
||||
<< ", " << kTestTotalShards << "=" << total_shards << ".\n";
|
||||
ColoredPrintf(COLOR_RED, "%s", msg.GetString().c_str());
|
||||
ColoredPrintf(COLOR_RED, msg.GetString().c_str());
|
||||
fflush(stdout);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
@ -5361,8 +5378,7 @@ bool SkipPrefix(const char* prefix, const char** pstr) {
|
|||
// part can be omitted.
|
||||
//
|
||||
// Returns the value of the flag, or NULL if the parsing failed.
|
||||
static const char* ParseFlagValue(const char* str,
|
||||
const char* flag,
|
||||
static const char* ParseFlagValue(const char* str, const char* flag,
|
||||
bool def_optional) {
|
||||
// str and flag must not be NULL.
|
||||
if (str == NULL || flag == NULL) return NULL;
|
||||
|
@ -5535,7 +5551,7 @@ static const char kColorEncodedHelpMessage[] =
|
|||
"Test Output:\n"
|
||||
" @G--" GTEST_FLAG_PREFIX_ "color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\n"
|
||||
" Enable/disable colored output. The default is @Gauto@D.\n"
|
||||
" @G--" GTEST_FLAG_PREFIX_ "print_time=0@D\n"
|
||||
" -@G-" GTEST_FLAG_PREFIX_ "print_time=0@D\n"
|
||||
" Don't print the elapsed time of each test.\n"
|
||||
" @G--" GTEST_FLAG_PREFIX_ "output=@Y(@Gjson@Y|@Gxml@Y)[@G:@YDIRECTORY_PATH@G"
|
||||
GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n"
|
||||
|
|
Loading…
Reference in New Issue
Block a user