Skip to content

Commit

Permalink
Use a timezone in test that is guaranteed not to fail initialize.
Browse files Browse the repository at this point in the history
Time zone look-up depends on the environment the test is running
in and sometimes absl fails to load named timezones.

PiperOrigin-RevId: 610828536
  • Loading branch information
hzeller authored and copybara-github committed Feb 27, 2024
1 parent 97a2a67 commit 7fee3c0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions xls/dslx/test_xml_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ namespace xls::dslx::test_xml {
namespace {

TEST(TestResultSerdesTest, OneTestCase) {
absl::TimeZone la;
ASSERT_TRUE(absl::LoadTimeZone("America/Los_Angeles", &la));
const absl::TimeZone la = absl::UTCTimeZone();

// For some reason clang-format has trouble keeping this in 80 column lines.
// clang-format off
Expand Down Expand Up @@ -90,10 +89,10 @@ TEST(TestResultSerdesTest, OneTestCase) {
std::string got = XmlNodeToString(*node);
EXPECT_EQ(
got,
R"(<testsuites disabled="0" errors="0" failures="0" name="all tests" skipped="0" tests="1" time="0.042" timestamp="2024-01-01T00:00:00-08:00">
<testsuite disabled="0" errors="0" failures="0" name="MyTestSuite" skipped="0" tests="1" time="0.032" timestamp="2024-01-01T00:00:01-08:00">
<testcase file="/path/to/foo.x" line="64" name="MyTestCase" result="completed" status="run" time="0.024" timestamp="2024-01-01T00:00:02-08:00" />
<testcase file="/path/to/foo.x" line="128" name="MyFailingTestCase" result="completed" status="run" time="0.024" timestamp="2024-01-01T00:00:03-08:00">
R"(<testsuites disabled="0" errors="0" failures="0" name="all tests" skipped="0" tests="1" time="0.042" timestamp="2024-01-01T00:00:00+00:00">
<testsuite disabled="0" errors="0" failures="0" name="MyTestSuite" skipped="0" tests="1" time="0.032" timestamp="2024-01-01T00:00:01+00:00">
<testcase file="/path/to/foo.x" line="64" name="MyTestCase" result="completed" status="run" time="0.024" timestamp="2024-01-01T00:00:02+00:00" />
<testcase file="/path/to/foo.x" line="128" name="MyFailingTestCase" result="completed" status="run" time="0.024" timestamp="2024-01-01T00:00:03+00:00">
<failure message="this is a one liner describing the failure with angle brackets in it for fun &lt;&gt; they should be escaped" />
</testcase>
</testsuite>
Expand Down

0 comments on commit 7fee3c0

Please sign in to comment.