mirror of
https://github.com/facebook/rocksdb.git
synced 2026-07-07 14:47:40 +08:00
Fix tests broken by gtest upgrade (#13661)
Summary: Some tests were failing due to apparent missing include of iomanip. I suspect this was from a gtest upgrade, because in open source, the include iomanip comes from gtest.h. To ensure we maintain compatibility with older gtest as well as the newer one, I pulled the include iomanip out of the in-repo gtest.h. Note that other places in gtest code only instantiate floating-point related templates with `float` and `double` types. Also, to avoid `make format` being insanely slow on gtest.h, I've excluded third-party from the formatting check. Pull Request resolved: https://github.com/facebook/rocksdb/pull/13661 Test Plan: make check, internal CI, manually ensure formatting check works outside of third-party/ Reviewed By: jaykorean Differential Revision: D75963897 Pulled By: pdillinger fbshipit-source-id: ed5737dd456e74068185f1ac5d57046d7509df7a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fccc881894
commit
eaa4f9d23b
@@ -118,6 +118,9 @@ fi
|
||||
# fi
|
||||
set -e
|
||||
|
||||
# Exclude third-party from formatting
|
||||
EXCLUDE=':!third-party/'
|
||||
|
||||
uncommitted_code=`git diff HEAD`
|
||||
|
||||
# If there's no uncommitted changes, we assume user are doing post-commit
|
||||
@@ -137,11 +140,11 @@ then
|
||||
# should be relevant for formatting fixes.
|
||||
FORMAT_UPSTREAM_MERGE_BASE="$(git merge-base "$FORMAT_UPSTREAM" HEAD)"
|
||||
# Get the differences
|
||||
diffs=$(git diff -U0 "$FORMAT_UPSTREAM_MERGE_BASE" | $CLANG_FORMAT_DIFF -p 1) || true
|
||||
diffs=$(git diff -U0 "$FORMAT_UPSTREAM_MERGE_BASE" -- $EXCLUDE | $CLANG_FORMAT_DIFF -p 1) || true
|
||||
echo "Checking format of changes not yet in $FORMAT_UPSTREAM..."
|
||||
else
|
||||
# Check the format of uncommitted lines,
|
||||
diffs=$(git diff -U0 HEAD | $CLANG_FORMAT_DIFF -p 1) || true
|
||||
diffs=$(git diff -U0 HEAD -- $EXCLUDE | $CLANG_FORMAT_DIFF -p 1) || true
|
||||
echo "Checking format of uncommitted changes..."
|
||||
fi
|
||||
|
||||
@@ -187,9 +190,9 @@ fi
|
||||
# Do in-place format adjustment.
|
||||
if [ -z "$uncommitted_code" ]
|
||||
then
|
||||
git diff -U0 "$FORMAT_UPSTREAM_MERGE_BASE" | $CLANG_FORMAT_DIFF -i -p 1
|
||||
git diff -U0 "$FORMAT_UPSTREAM_MERGE_BASE" -- $EXCLUDE | $CLANG_FORMAT_DIFF -i -p 1
|
||||
else
|
||||
git diff -U0 HEAD | $CLANG_FORMAT_DIFF -i -p 1
|
||||
git diff -U0 HEAD -- $EXCLUDE | $CLANG_FORMAT_DIFF -i -p 1
|
||||
fi
|
||||
echo "Files reformatted!"
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
#include "db/db_test_util.h"
|
||||
#include "port/stack_trace.h"
|
||||
#include "test_util/testutil.h"
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
@@ -477,6 +477,38 @@ GTEST_DECLARE_bool_(death_test_use_fork);
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <typename RawType>
|
||||
AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
|
||||
const char* rhs_expression,
|
||||
RawType lhs_value, RawType rhs_value) {
|
||||
const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value);
|
||||
|
||||
if (lhs.AlmostEquals(rhs)) {
|
||||
return AssertionSuccess();
|
||||
}
|
||||
|
||||
::std::stringstream lhs_ss;
|
||||
lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
|
||||
<< lhs_value;
|
||||
|
||||
::std::stringstream rhs_ss;
|
||||
rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
|
||||
<< rhs_value;
|
||||
|
||||
return EqFailure(lhs_expression, rhs_expression,
|
||||
StringStreamToString(&lhs_ss), StringStreamToString(&rhs_ss),
|
||||
false);
|
||||
}
|
||||
|
||||
template
|
||||
AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
|
||||
const char* rhs_expression,
|
||||
float lhs_value, float rhs_value);
|
||||
template
|
||||
AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
|
||||
const char* rhs_expression,
|
||||
double lhs_value, double rhs_value);
|
||||
|
||||
// The value of GetTestTypeId() as seen from within the Google Test
|
||||
// library. This is solely for testing GetTestTypeId().
|
||||
GTEST_API_ extern const TypeId kTestTypeIdInGoogleTest;
|
||||
|
||||
+2
-22
@@ -3973,7 +3973,7 @@ const char* StringFromGTestEnv(const char* flag, const char* default_val);
|
||||
#include <ctype.h>
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
#include <iomanip>
|
||||
// #include <iomanip> // Not included in newer versions of gtest
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <set>
|
||||
@@ -21451,27 +21451,7 @@ template <typename RawType>
|
||||
AssertionResult CmpHelperFloatingPointEQ(const char* lhs_expression,
|
||||
const char* rhs_expression,
|
||||
RawType lhs_value,
|
||||
RawType rhs_value) {
|
||||
const FloatingPoint<RawType> lhs(lhs_value), rhs(rhs_value);
|
||||
|
||||
if (lhs.AlmostEquals(rhs)) {
|
||||
return AssertionSuccess();
|
||||
}
|
||||
|
||||
::std::stringstream lhs_ss;
|
||||
lhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
|
||||
<< lhs_value;
|
||||
|
||||
::std::stringstream rhs_ss;
|
||||
rhs_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
|
||||
<< rhs_value;
|
||||
|
||||
return EqFailure(lhs_expression,
|
||||
rhs_expression,
|
||||
StringStreamToString(&lhs_ss),
|
||||
StringStreamToString(&rhs_ss),
|
||||
false);
|
||||
}
|
||||
RawType rhs_value);
|
||||
|
||||
// Helper function for implementing ASSERT_NEAR.
|
||||
//
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "rocksdb/utilities/ldb_cmd.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <iomanip>
|
||||
|
||||
#include "db/db_test_util.h"
|
||||
#include "db/version_edit.h"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user