Skip to content

Commit afc030d

Browse files
authored
[clang-format] Don't test stability if JS format test fails (#136662)
1 parent 037657d commit afc030d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

clang/unittests/Format/FormatTestJS.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,22 @@ class FormatTestJS : public testing::Test {
4848
static void verifyFormat(
4949
StringRef Code,
5050
const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) {
51-
EXPECT_EQ(Code.str(), format(Code, Style)) << "Expected code is not stable";
52-
std::string Result = format(test::messUp(Code), Style);
53-
EXPECT_EQ(Code.str(), Result) << "Formatted:\n" << Result;
51+
auto Result = format(test::messUp(Code), Style);
52+
EXPECT_EQ(Code, Result) << "Formatted:\n" << Result;
53+
if (Code != Result)
54+
return;
55+
EXPECT_EQ(Code, format(Code, Style)) << "Expected code is not stable";
5456
}
5557

5658
static void verifyFormat(
5759
StringRef Expected, StringRef Code,
5860
const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) {
59-
EXPECT_EQ(Expected.str(), format(Expected, Style))
61+
auto Result = format(Code, Style);
62+
EXPECT_EQ(Expected, Result) << "Formatted:\n" << Result;
63+
if (Expected != Result)
64+
return;
65+
EXPECT_EQ(Expected, format(Expected, Style))
6066
<< "Expected code is not stable";
61-
std::string Result = format(Code, Style);
62-
EXPECT_EQ(Expected.str(), Result) << "Formatted:\n" << Result;
6367
}
6468
};
6569

0 commit comments

Comments
 (0)