Skip to content

Commit 4565741

Browse files
Abseil Teamcopybara-github
authored andcommitted
Modifications to improve portability of googletest tests.
PiperOrigin-RevId: 603034597 Change-Id: I4d716ed67f80f41075bfa266d975460d2ac27eb6
1 parent 6fdb4c3 commit 4565741

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

googletest/test/googletest-options-test.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,14 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
115115
strcasecmp("gtest_dll_test", exe_str.c_str()) == 0;
116116
#elif defined(GTEST_OS_FUCHSIA)
117117
const bool success = exe_str == "app";
118+
#elif defined(__EMSCRIPTEN__)
119+
const bool success = exe_str == "patched_googletest-options-test.js";
118120
#else
119121
const bool success =
120122
exe_str == "googletest-options-test" || exe_str == "gtest_all_test" ||
121123
exe_str == "lt-gtest_all_test" || exe_str == "gtest_dll_test";
122-
#endif // GTEST_OS_WINDOWS
124+
#endif // platform ifdefs
125+
123126
if (!success) FAIL() << "GetCurrentExecutableName() returns " << exe_str;
124127
}
125128

googletest/test/gtest_unittest.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,14 @@ TEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) {
422422
EXPECT_EQ("-1234567.89", FormatTimeInMillisAsSeconds(-1234567890));
423423
}
424424

425+
// TODO: b/287046337 - In emscripten, local time zone modification is not
426+
// supported.
427+
#if !defined(__EMSCRIPTEN__)
425428
// Tests FormatEpochTimeInMillisAsIso8601(). The correctness of conversion
426429
// for particular dates below was verified in Python using
427430
// datetime.datetime.fromutctimestamp(<timestamp>/1000).
428431

429-
// FormatEpochTimeInMillisAsIso8601 depends on the current timezone, so we
432+
// FormatEpochTimeInMillisAsIso8601 depends on the local timezone, so we
430433
// have to set up a particular timezone to obtain predictable results.
431434
class FormatEpochTimeInMillisAsIso8601Test : public Test {
432435
public:
@@ -445,9 +448,8 @@ class FormatEpochTimeInMillisAsIso8601Test : public Test {
445448
}
446449
GTEST_DISABLE_MSC_DEPRECATED_POP_()
447450

448-
// Set up the time zone for FormatEpochTimeInMillisAsIso8601 to use. We
449-
// cannot use the local time zone because the function's output depends
450-
// on the time zone.
451+
// Set the local time zone for FormatEpochTimeInMillisAsIso8601 to be
452+
// a fixed time zone for reproducibility purposes.
451453
SetTimeZone("UTC+00");
452454
}
453455

@@ -514,6 +516,8 @@ TEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsEpochStart) {
514516
EXPECT_EQ("1970-01-01T00:00:00.000", FormatEpochTimeInMillisAsIso8601(0));
515517
}
516518

519+
#endif // __EMSCRIPTEN__
520+
517521
#ifdef __BORLANDC__
518522
// Silences warnings: "Condition is always true", "Unreachable code"
519523
#pragma option push -w-ccc -w-rch

0 commit comments

Comments
 (0)