Skip to content

[clang-format] Don't test stability if JS format test fails #136662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025

Conversation

owenca
Copy link
Contributor

@owenca owenca commented Apr 22, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Apr 22, 2025

@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/136662.diff

1 Files Affected:

  • (modified) clang/unittests/Format/FormatTestJS.cpp (+10-6)
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;
   }
 };
 

@owenca owenca merged commit afc030d into llvm:main Apr 23, 2025
13 checks passed
@owenca owenca deleted the JS-verifyFormat branch April 23, 2025 04:09
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants