Skip to content

Improve command-line options handling in ToolTest.cc #2238

Description

@lahwaacz

ToolTest.cc has terrible handling of command-line options:

GTEST_API_intmain(int argc, char** argv) {
GOOGLE_PROTOBUF_VERIFY_VERSION;
std::cout << "ORC version: " << ORC_VERSION << "\n";
if (argc >= 2) {
exampleDirectory = argv[1];
} else {
exampleDirectory = "../examples";
}
if (argc >= 3) {
buildDirectory = argv[2];
} else {
buildDirectory = ".";
}
std::cout << "example dir = " << exampleDirectory << "\n";
if (buildDirectory) {
std::cout << "build dir = " << buildDirectory << "\n";
}
testing::InitGoogleTest(&argc, argv);
int result = RUN_ALL_TESTS();
google::protobuf::ShutdownProtobufLibrary();
return result;
}

First, it interprets argv[1] as exampleDirectory and argv[2] as buildDirectory. Then it passes all options to testing::InitGoogleTest(&argc, argv);

This means that passing optional arguments like --gtest_* does not work. If I do

gtest_filter="-TestMatchParam/FileParam.Contents/19:-TestMatchParam/FileParam.Contents/23"
build/tools/test/tool-test --gtest_filter="$gtest_filter"

then all tests except one fail with an error like

C++ exception with description "Can't open --gtest_filter=-TestMatchParam/FileParam.Contents/19:-TestMatchParam/FileParam.Contents/23/TestOrcFile.testDate2038.orc" thrown in the test body.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions