Skip to content

Commit c852145

Browse files
committed
[clang-format][NFC] Skip stability test if input is pre-formatted
This shortens the run-time of FormatTests by about 10% on average (and by up to 50% if formatting would not change the input). Differential Revision: https://reviews.llvm.org/D158925
1 parent 6b2cb3b commit c852145

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

clang/unittests/Format/FormatTestBase.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ class FormatTestBase : public ::testing::Test {
8585
const std::optional<FormatStyle> &Style = {},
8686
const std::vector<tooling::Range> &Ranges = {}) {
8787
testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());
88-
EXPECT_EQ(Expected.str(),
89-
format(Expected, Style, SC_ExpectComplete, Ranges))
90-
<< "Expected code is not stable";
88+
if (Expected != Code) {
89+
EXPECT_EQ(Expected.str(),
90+
format(Expected, Style, SC_ExpectComplete, Ranges))
91+
<< "Expected code is not stable";
92+
}
9193
EXPECT_EQ(Expected.str(), format(Code, Style, SC_ExpectComplete, Ranges));
9294
auto UsedStyle = Style ? Style.value() : getDefaultStyle();
9395
if (UsedStyle.Language == FormatStyle::LK_Cpp) {

0 commit comments

Comments
 (0)