diff options
author | Abseil Team <absl-team@google.com> | 2024-01-31 14:50:36 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-01-31 14:51:14 (GMT) |
commit | 456574145cf71a5375777cab58453acfd92a920b (patch) | |
tree | 402c6c14b3944dca1245ac7042f3e6069bb7012a | |
parent | 6fdb4c303f5e5fe42baf818ced2d82bee01e9b8c (diff) | |
download | googletest-456574145cf71a5375777cab58453acfd92a920b.zip googletest-456574145cf71a5375777cab58453acfd92a920b.tar.gz googletest-456574145cf71a5375777cab58453acfd92a920b.tar.bz2 |
Modifications to improve portability of googletest tests.
PiperOrigin-RevId: 603034597
Change-Id: I4d716ed67f80f41075bfa266d975460d2ac27eb6
-rw-r--r-- | googletest/test/googletest-options-test.cc | 5 | ||||
-rw-r--r-- | googletest/test/gtest_unittest.cc | 12 |
2 files changed, 12 insertions, 5 deletions
diff --git a/googletest/test/googletest-options-test.cc b/googletest/test/googletest-options-test.cc index b712c06..91d06a5 100644 --- a/googletest/test/googletest-options-test.cc +++ b/googletest/test/googletest-options-test.cc @@ -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; } diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 67d776e..0b383ea 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -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 |