From 5f73c7efac856c63e30a5079f6043033d13429e2 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Sun, 19 Nov 2017 14:35:16 -0800 Subject: [PATCH] Allow running unit and index tests separately --- src/command_line.cc | 36 +++++++++++++++++++----------------- src/test.cc | 2 +- src/test.h | 2 +- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/command_line.cc b/src/command_line.cc index ec69e6de..55e649ff 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -3203,33 +3203,33 @@ int main(int argc, char** argv) { std::unordered_map options = ParseOptions(argc, argv); - if (HasOption(options, "--test")) { + bool print_help = true; + + if (HasOption(options, "--test-unit")) { + print_help = false; doctest::Context context; context.applyCommandLine(argc, argv); int res = context.run(); if (context.shouldExit()) return res; + } - for (int i = 0; i < 1; ++i) - RunTests(); - - /* - for (int i = 0; i < 1; ++i) { - std::this_thread::sleep_for(std::chrono::seconds(5)); - std::cerr << "[POST] Memory usage: " << GetProcessMemoryUsedInMb() << "mb" - << std::endl; - } - */ - + if (HasOption(options, "--test-index")) { + print_help = false; + RunIndexTests(); std::cerr << std::endl << "[Enter] to exit" << std::endl; std::cin.get(); - return 0; - } else if (HasOption(options, "--language-server")) { + } + + if (HasOption(options, "--language-server")) { + print_help = false; // std::cerr << "Running language server" << std::endl; auto config = MakeUnique(); LanguageServerMain(argv[0], config.get(), &waiter); return 0; - } else { + } + + if (print_help) { std::cout << R"help(cquery help: cquery is a low-latency C++ language server. @@ -3239,7 +3239,8 @@ int main(int argc, char** argv) { --language-server Run as a language server. This implements the language server spec over STDIN and STDOUT. - --test Run tests. Does nothing if test support is not compiled in. + --test-unit Run unit tests. + --test-index Run index tests. Configuration: When opening up a directory, cquery will look for a compile_commands.json @@ -3253,8 +3254,9 @@ int main(int argc, char** argv) { describe those options. See |Config| in this source code for a detailed list of all currently supported options. )help"; - return 0; } + + return 0; } TEST_SUITE("LexFunctionDeclaration") { diff --git a/src/test.cc b/src/test.cc index 0d865708..9677e477 100644 --- a/src/test.cc +++ b/src/test.cc @@ -108,7 +108,7 @@ IndexFile* FindDbForPathEnding( return nullptr; } -void RunTests() { +void RunIndexTests() { SetTestOutputMode(); // TODO: Assert that we need to be on clang >= 3.9.1 diff --git a/src/test.h b/src/test.h index 625ebf50..7f7aee84 100644 --- a/src/test.h +++ b/src/test.h @@ -1,3 +1,3 @@ #pragma once -void RunTests(); \ No newline at end of file +void RunIndexTests(); \ No newline at end of file