Skip to content

Commit

Permalink
fix abort_test for limited Windows regex. Refs mesonbuild/wrapdb#1611
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 662785270
  • Loading branch information
jan-wassenberg authored and copybara-github committed Aug 14, 2024
1 parent ce836a7 commit 82bce70
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions hwy/abort_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "hwy/abort.h"

#include <stdio.h>

#include <string>

#include "hwy/base.h"
Expand All @@ -27,14 +29,17 @@ TEST(AbortDeathTest, AbortDefault) {
}

TEST(AbortDeathTest, AbortOverride) {
// googletest regex does not support `+` for digits on Windows?!
// https://google.github.io/googletest/advanced.html#regular-expression-syntax
// We assume the line number is exactly 2 digits.
std::string expected =
std::string("Test Abort from [0-9]+ of ") + GetBaseName(__FILE__);
std::string("Test Abort from \\d\\d of ") + GetBaseName(__FILE__);

ASSERT_DEATH(
{
AbortFunc CustomAbortHandler = [](const char* file, int line,
const char* formatted_err) -> void {
fprintf(stderr, "%s from %d of %s", formatted_err, line,
fprintf(stderr, "%s from %02d of %s", formatted_err, line,
GetBaseName(file).data());
};

Expand All @@ -43,7 +48,7 @@ TEST(AbortDeathTest, AbortOverride) {
},
expected);
}
#endif
#endif // GTEST_HAS_DEATH_TEST

TEST(AbortTest, AbortOverrideChain) {
AbortFunc FirstHandler = [](const char* file, int line,
Expand Down

0 comments on commit 82bce70

Please sign in to comment.