[clang] afc030d - [clang-format] Don't test stability if JS format test fails (#136662)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 22 21:09:24 PDT 2025
Author: Owen Pan
Date: 2025-04-22T21:09:21-07:00
New Revision: afc030dd30e377ca7bf225a97179fa1b64eedd28
URL: https://github.com/llvm/llvm-project/commit/afc030dd30e377ca7bf225a97179fa1b64eedd28
DIFF: https://github.com/llvm/llvm-project/commit/afc030dd30e377ca7bf225a97179fa1b64eedd28.diff
LOG: [clang-format] Don't test stability if JS format test fails (#136662)
Added:
Modified:
clang/unittests/Format/FormatTestJS.cpp
Removed:
################################################################################
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 1cfacc060d944..91577b9a49167 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -48,18 +48,22 @@ class FormatTestJS : public testing::Test {
static void verifyFormat(
StringRef Code,
const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) {
- EXPECT_EQ(Code.str(), format(Code, Style)) << "Expected code is not stable";
- std::string Result = format(test::messUp(Code), Style);
- EXPECT_EQ(Code.str(), Result) << "Formatted:\n" << Result;
+ auto Result = format(test::messUp(Code), Style);
+ EXPECT_EQ(Code, Result) << "Formatted:\n" << Result;
+ if (Code != Result)
+ return;
+ EXPECT_EQ(Code, format(Code, Style)) << "Expected code is not stable";
}
static void verifyFormat(
StringRef Expected, StringRef Code,
const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_JavaScript)) {
- EXPECT_EQ(Expected.str(), format(Expected, Style))
+ auto Result = format(Code, Style);
+ EXPECT_EQ(Expected, Result) << "Formatted:\n" << Result;
+ if (Expected != Result)
+ return;
+ EXPECT_EQ(Expected, format(Expected, Style))
<< "Expected code is not stable";
- std::string Result = format(Code, Style);
- EXPECT_EQ(Expected.str(), Result) << "Formatted:\n" << Result;
}
};
More information about the cfe-commits
mailing list