mirror of
https://github.com/holub/mame
synced 2025-07-01 16:19:38 +03:00
update google test (nw)
This commit is contained in:
parent
bd2e14349b
commit
1ec2f972d9
@ -2103,7 +2103,7 @@ For better readability, Google Mock also gives you:
|
|||||||
* `WithArg<N>(action)` (no `s` after `Arg`) when the inner `action` takes _one_ argument.
|
* `WithArg<N>(action)` (no `s` after `Arg`) when the inner `action` takes _one_ argument.
|
||||||
|
|
||||||
As you may have realized, `InvokeWithoutArgs(...)` is just syntactic
|
As you may have realized, `InvokeWithoutArgs(...)` is just syntactic
|
||||||
sugar for `WithoutArgs(Inovke(...))`.
|
sugar for `WithoutArgs(Invoke(...))`.
|
||||||
|
|
||||||
Here are more tips:
|
Here are more tips:
|
||||||
|
|
||||||
|
@ -1571,15 +1571,14 @@ For technical reasons, there are some caveats:
|
|||||||
1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot reference local non-static variables or non-static members of `this` object.
|
1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot reference local non-static variables or non-static members of `this` object.
|
||||||
1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot return a value.
|
1. _statement_ in `EXPECT_FATAL_FAILURE()` cannot return a value.
|
||||||
|
|
||||||
_Note:_ Google Test is designed with threads in mind. Once the
|
_Note:_ Google Test is designed with threads in mind. Once the
|
||||||
synchronization primitives in `"gtest/internal/gtest-port.h"` have
|
synchronization primitives in `"gtest/internal/gtest-port.h"` have
|
||||||
been implemented, Google Test will become thread-safe, meaning that
|
been implemented, Google Test will become thread-safe, meaning that
|
||||||
you can then use assertions in multiple threads concurrently. Before
|
you can then use assertions in multiple threads concurrently. Before
|
||||||
|
that, however, Google Test only supports single-threaded usage. Once
|
||||||
that, however, Google Test only supports single-threaded usage. Once
|
|
||||||
thread-safe, `EXPECT_FATAL_FAILURE()` and `EXPECT_NONFATAL_FAILURE()`
|
thread-safe, `EXPECT_FATAL_FAILURE()` and `EXPECT_NONFATAL_FAILURE()`
|
||||||
will capture failures in the current thread only. If _statement_
|
will capture failures in the current thread only. If _statement_
|
||||||
creates new threads, failures in these threads will be ignored. If
|
creates new threads, failures in these threads will be ignored. If
|
||||||
you want to capture failures from all threads instead, you should use
|
you want to capture failures from all threads instead, you should use
|
||||||
the following macros:
|
the following macros:
|
||||||
|
|
||||||
|
@ -2546,10 +2546,9 @@ bool ParseInt32(const Message& src_text, const char* str, Int32* value);
|
|||||||
// corresponding to the given Google Test flag.
|
// corresponding to the given Google Test flag.
|
||||||
bool BoolFromGTestEnv(const char* flag, bool default_val);
|
bool BoolFromGTestEnv(const char* flag, bool default_val);
|
||||||
GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
|
GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
|
||||||
const char* StringFromGTestEnv(const char* flag, const char* default_val);
|
std::string StringFromGTestEnv(const char* flag, const char* default_val);
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
} // namespace testing
|
} // namespace testing
|
||||||
|
|
||||||
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_
|
||||||
|
|
||||||
|
26
3rdparty/googletest/googletest/src/gtest-port.cc
vendored
26
3rdparty/googletest/googletest/src/gtest-port.cc
vendored
@ -1226,13 +1226,33 @@ Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) {
|
|||||||
|
|
||||||
// Reads and returns the string environment variable corresponding to
|
// Reads and returns the string environment variable corresponding to
|
||||||
// the given flag; if it's not set, returns default_value.
|
// the given flag; if it's not set, returns default_value.
|
||||||
const char* StringFromGTestEnv(const char* flag, const char* default_value) {
|
std::string StringFromGTestEnv(const char* flag, const char* default_value) {
|
||||||
#if defined(GTEST_GET_STRING_FROM_ENV_)
|
#if defined(GTEST_GET_STRING_FROM_ENV_)
|
||||||
return GTEST_GET_STRING_FROM_ENV_(flag, default_value);
|
return GTEST_GET_STRING_FROM_ENV_(flag, default_value);
|
||||||
#endif // defined(GTEST_GET_STRING_FROM_ENV_)
|
#endif // defined(GTEST_GET_STRING_FROM_ENV_)
|
||||||
const std::string env_var = FlagToEnvVar(flag);
|
const std::string env_var = FlagToEnvVar(flag);
|
||||||
const char* const value = posix::GetEnv(env_var.c_str());
|
const char* value = posix::GetEnv(env_var.c_str());
|
||||||
return value == NULL ? default_value : value;
|
if (value != NULL) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// As a special case for the 'output' flag, if GTEST_OUTPUT is not
|
||||||
|
// set, we look for XML_OUTPUT_FILE, which is set by the Bazel build
|
||||||
|
// system. The value of XML_OUTPUT_FILE is a filename without the
|
||||||
|
// "xml:" prefix of GTEST_OUTPUT.
|
||||||
|
//
|
||||||
|
// The net priority order after flag processing is thus:
|
||||||
|
// --gtest_output command line flag
|
||||||
|
// GTEST_OUTPUT environment variable
|
||||||
|
// XML_OUTPUT_FILE environment variable
|
||||||
|
// 'default_value'
|
||||||
|
if (strcmp(flag, "output") == 0) {
|
||||||
|
value = posix::GetEnv("XML_OUTPUT_FILE");
|
||||||
|
if (value != NULL) {
|
||||||
|
return std::string("xml:") + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
@ -87,6 +87,7 @@ class GTestEnvVarTest(gtest_test_utils.TestCase):
|
|||||||
TestFlag('break_on_failure', '1', '0')
|
TestFlag('break_on_failure', '1', '0')
|
||||||
TestFlag('color', 'yes', 'auto')
|
TestFlag('color', 'yes', 'auto')
|
||||||
TestFlag('filter', 'FooTest.Bar', '*')
|
TestFlag('filter', 'FooTest.Bar', '*')
|
||||||
|
SetEnvVar('XML_OUTPUT_FILE', None) # For 'output' test
|
||||||
TestFlag('output', 'xml:tmp/foo.xml', '')
|
TestFlag('output', 'xml:tmp/foo.xml', '')
|
||||||
TestFlag('print_time', '0', '1')
|
TestFlag('print_time', '0', '1')
|
||||||
TestFlag('repeat', '999', '1')
|
TestFlag('repeat', '999', '1')
|
||||||
@ -98,6 +99,19 @@ class GTestEnvVarTest(gtest_test_utils.TestCase):
|
|||||||
TestFlag('death_test_use_fork', '1', '0')
|
TestFlag('death_test_use_fork', '1', '0')
|
||||||
TestFlag('stack_trace_depth', '0', '100')
|
TestFlag('stack_trace_depth', '0', '100')
|
||||||
|
|
||||||
|
def testXmlOutputFile(self):
|
||||||
|
"""Tests that $XML_OUTPUT_FILE affects the output flag."""
|
||||||
|
|
||||||
|
SetEnvVar('GTEST_OUTPUT', None)
|
||||||
|
SetEnvVar('XML_OUTPUT_FILE', 'tmp/bar.xml')
|
||||||
|
AssertEq('xml:tmp/bar.xml', GetFlag('output'))
|
||||||
|
|
||||||
|
def testXmlOutputFileOverride(self):
|
||||||
|
"""Tests that $XML_OUTPUT_FILE is overridden by $GTEST_OUTPUT"""
|
||||||
|
|
||||||
|
SetEnvVar('GTEST_OUTPUT', 'xml:tmp/foo.xml')
|
||||||
|
SetEnvVar('XML_OUTPUT_FILE', 'tmp/bar.xml')
|
||||||
|
AssertEq('xml:tmp/foo.xml', GetFlag('output'))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
gtest_test_utils.Main()
|
gtest_test_utils.Main()
|
||||||
|
Loading…
Reference in New Issue
Block a user