[PATCH] D158925: [clang-format][NFC] Skip stability test if input is pre-formatted

2023-08-26 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc8521451708a: [clang-format][NFC] Skip stability test if 
input is pre-formatted (authored by owenpan).

Changed prior to commit:
  https://reviews.llvm.org/D158925?vs=553714&id=553765#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158925/new/

https://reviews.llvm.org/D158925

Files:
  clang/unittests/Format/FormatTestBase.h


Index: clang/unittests/Format/FormatTestBase.h
===
--- clang/unittests/Format/FormatTestBase.h
+++ clang/unittests/Format/FormatTestBase.h
@@ -85,9 +85,11 @@
  const std::optional &Style = {},
  const std::vector &Ranges = {}) {
 testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
-EXPECT_EQ(Expected.str(),
-  format(Expected, Style, SC_ExpectComplete, Ranges))
-<< "Expected code is not stable";
+if (Expected != Code) {
+  EXPECT_EQ(Expected.str(),
+format(Expected, Style, SC_ExpectComplete, Ranges))
+  << "Expected code is not stable";
+}
 EXPECT_EQ(Expected.str(), format(Code, Style, SC_ExpectComplete, Ranges));
 auto UsedStyle = Style ? Style.value() : getDefaultStyle();
 if (UsedStyle.Language == FormatStyle::LK_Cpp) {


Index: clang/unittests/Format/FormatTestBase.h
===
--- clang/unittests/Format/FormatTestBase.h
+++ clang/unittests/Format/FormatTestBase.h
@@ -85,9 +85,11 @@
  const std::optional &Style = {},
  const std::vector &Ranges = {}) {
 testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
-EXPECT_EQ(Expected.str(),
-  format(Expected, Style, SC_ExpectComplete, Ranges))
-<< "Expected code is not stable";
+if (Expected != Code) {
+  EXPECT_EQ(Expected.str(),
+format(Expected, Style, SC_ExpectComplete, Ranges))
+  << "Expected code is not stable";
+}
 EXPECT_EQ(Expected.str(), format(Code, Style, SC_ExpectComplete, Ranges));
 auto UsedStyle = Style ? Style.value() : getDefaultStyle();
 if (UsedStyle.Language == FormatStyle::LK_Cpp) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158925: [clang-format][NFC] Skip stability test if input is pre-formatted

2023-08-26 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/unittests/Format/FormatTestBase.h:88
 testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
-EXPECT_EQ(Expected.str(),
-  format(Expected, Style, SC_ExpectComplete, Ranges))
-<< "Expected code is not stable";
+if (!Expected.equals(Code)) {
+  EXPECT_EQ(Expected.str(),

Will fix it before landing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158925/new/

https://reviews.llvm.org/D158925

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158925: [clang-format][NFC] Skip stability test if input is pre-formatted

2023-08-26 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, MyDeveloperDay.
owenpan requested review of this revision.

This shortens the run-time of `FormatTests` by about 10% on average (and by up 
to 50% if formatting would not change the input).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158925

Files:
  clang/unittests/Format/FormatTestBase.h


Index: clang/unittests/Format/FormatTestBase.h
===
--- clang/unittests/Format/FormatTestBase.h
+++ clang/unittests/Format/FormatTestBase.h
@@ -85,9 +85,11 @@
  const std::optional &Style = {},
  const std::vector &Ranges = {}) {
 testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
-EXPECT_EQ(Expected.str(),
-  format(Expected, Style, SC_ExpectComplete, Ranges))
-<< "Expected code is not stable";
+if (!Expected.equals(Code)) {
+  EXPECT_EQ(Expected.str(),
+format(Expected, Style, SC_ExpectComplete, Ranges))
+  << "Expected code is not stable";
+}
 EXPECT_EQ(Expected.str(), format(Code, Style, SC_ExpectComplete, Ranges));
 auto UsedStyle = Style ? Style.value() : getDefaultStyle();
 if (UsedStyle.Language == FormatStyle::LK_Cpp) {


Index: clang/unittests/Format/FormatTestBase.h
===
--- clang/unittests/Format/FormatTestBase.h
+++ clang/unittests/Format/FormatTestBase.h
@@ -85,9 +85,11 @@
  const std::optional &Style = {},
  const std::vector &Ranges = {}) {
 testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
-EXPECT_EQ(Expected.str(),
-  format(Expected, Style, SC_ExpectComplete, Ranges))
-<< "Expected code is not stable";
+if (!Expected.equals(Code)) {
+  EXPECT_EQ(Expected.str(),
+format(Expected, Style, SC_ExpectComplete, Ranges))
+  << "Expected code is not stable";
+}
 EXPECT_EQ(Expected.str(), format(Code, Style, SC_ExpectComplete, Ranges));
 auto UsedStyle = Style ? Style.value() : getDefaultStyle();
 if (UsedStyle.Language == FormatStyle::LK_Cpp) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits