Match multi-word State

From a recent test failure:

"State:\tD (disk sleep)\n"

"disk sleep" does not match \w+. We need to allow spaces.

PiperOrigin-RevId: 242762469
Change-Id: Ic8d05a16669412a72c1e76b498373e5b22fe64c4
This commit is contained in:
Michael Pratt
2019-04-09 16:26:11 -07:00
committed by Shentubot
parent b3b140ea4f
commit 0e14e48b84
+5 -2
View File
@@ -99,8 +99,11 @@ std::vector<std::string> saved_argv; // NOLINT
void CompareProcessState(absl::string_view state, int pid) {
auto status_file = ASSERT_NO_ERRNO_AND_VALUE(
GetContents(absl::StrCat("/proc/", pid, "/status")));
EXPECT_THAT(status_file, ContainsRegex(absl::StrCat("State:.[", state,
"]\\s+\\(\\w+\\)")));
// N.B. POSIX extended regexes don't support shorthand character classes (\w)
// inside of brackets.
EXPECT_THAT(status_file,
ContainsRegex(absl::StrCat("State:.[", state,
R"EOL(]\s+\([a-zA-Z ]+\))EOL")));
}
// Run callbacks while a subprocess is running, zombied, and/or exited.