Modifications to improve portability of googletest tests.

PiperOrigin-RevId: 603034597
Change-Id: I4d716ed67f80f41075bfa266d975460d2ac27eb6
This commit is contained in:
Abseil Team 2024-01-31 06:50:36 -08:00 committed by Copybara-Service
parent 6fdb4c303f
commit 456574145c
2 changed files with 12 additions and 5 deletions

View File

@ -115,11 +115,14 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
strcasecmp("gtest_dll_test", exe_str.c_str()) == 0;
#elif defined(GTEST_OS_FUCHSIA)
const bool success = exe_str == "app";
#elif defined(__EMSCRIPTEN__)
const bool success = exe_str == "patched_googletest-options-test.js";
#else
const bool success =
exe_str == "googletest-options-test" || exe_str == "gtest_all_test" ||
exe_str == "lt-gtest_all_test" || exe_str == "gtest_dll_test";
#endif // GTEST_OS_WINDOWS
#endif // platform ifdefs
if (!success) FAIL() << "GetCurrentExecutableName() returns " << exe_str;
}

View File

@ -422,11 +422,14 @@ TEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) {
EXPECT_EQ("-1234567.89", FormatTimeInMillisAsSeconds(-1234567890));
}
// TODO: b/287046337 - In emscripten, local time zone modification is not
// supported.
#if !defined(__EMSCRIPTEN__)
// Tests FormatEpochTimeInMillisAsIso8601(). The correctness of conversion
// for particular dates below was verified in Python using
// datetime.datetime.fromutctimestamp(<timestamp>/1000).
// FormatEpochTimeInMillisAsIso8601 depends on the current timezone, so we
// FormatEpochTimeInMillisAsIso8601 depends on the local timezone, so we
// have to set up a particular timezone to obtain predictable results.
class FormatEpochTimeInMillisAsIso8601Test : public Test {
public:
@ -445,9 +448,8 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
}
GTEST_DISABLE_MSC_DEPRECATED_POP_()
// Set up the time zone for FormatEpochTimeInMillisAsIso8601 to use. We
// cannot use the local time zone because the function's output depends
// on the time zone.
// Set the local time zone for FormatEpochTimeInMillisAsIso8601 to be
// a fixed time zone for reproducibility purposes.
SetTimeZone("UTC+00");
}
@ -514,6 +516,8 @@ TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsEpochStart) {
EXPECT_EQ("1970-01-01T00:00:00.000", FormatEpochTimeInMillisAsIso8601(0));
}
#endif // __EMSCRIPTEN__
#ifdef __BORLANDC__
// Silences warnings: "Condition is always true", "Unreachable code"
#pragma option push -w-ccc -w-rch