Skip to content
  • Igor Sugak's avatar
    rocksdb: switch to gtest · b4b69e4f
    Igor Sugak authored
    Our existing test notation is very similar to what is used in gtest. It makes it easy to adopt what is different.
    In this diff I modify existing [[ | test fixture ]] classes to inherit from `testing::Test`. Also for unit tests that use fixture class, `TEST` is replaced with `TEST_F` as required in gtest.
    There are several custom `main` functions in our existing tests. To make this transition easier, I modify all `main` functions to fallow gtest notation. But eventually we can remove them and use implementation of `main` that gtest provides.
    % cat ~/transform
    files=$(git ls-files '*test\.cc')
    for file in $files
      if grep -q "rocksdb::test::RunAllTests()" $file
        if grep -Eq '^class \w+Test {' $file
          perl -pi -e 's/^(class \w+Test) {/${1}: public testing::Test {/g' $file
          perl -pi -e 's/^(TEST)/${1}_F/g' $file
        perl -pi -e 's/(int main.*\{)/${1}::testing::InitGoogleTest(&argc, argv);/g' $file
        perl -pi -e 's/rocksdb::test::RunAllTests/RUN_ALL_TESTS/g' $file
    % sh ~/transform
    % make format
    Second iteration of this diff contains only scripted changes.
    Third iteration contains manual changes to fix last errors and make it compilable.
    Test Plan:
    Build and notice no errors.
    % USE_CLANG=1 make check -j55
    Tests are still testing.
    Reviewers: meyering, sdong, rven, igor
    Reviewed By: igor
    Subscribers: dhruba, leveldb
    Differential Revision: