From ed1b221fab9841a66b0314988d7c138f19e8b265 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 8 Jul 2018 17:13:41 -0700 Subject: [PATCH] Remove submodule doctest --- .gitmodules | 3 - CMakeLists.txt | 5 +- src/fuzzy_match.cc | 4 +- src/main.cc | 20 +--- src/match.cc | 14 --- src/project.cc | 251 ---------------------------------------- src/query.cc | 2 - src/test.cc | 1 - src/third_party_impl.cc | 2 - src/working_files.cc | 2 - third_party/doctest | 1 - 11 files changed, 4 insertions(+), 301 deletions(-) delete mode 100644 src/third_party_impl.cc delete mode 160000 third_party/doctest diff --git a/.gitmodules b/.gitmodules index fbe945c5..b8c34ed0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "third_party/rapidjson"] path = third_party/rapidjson url = https://github.com/miloyip/rapidjson -[submodule "third_party/doctest"] - path = third_party/doctest - url = https://github.com/onqtam/doctest diff --git a/CMakeLists.txt b/CMakeLists.txt index cfabeb32..61430618 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,9 +143,7 @@ target_compile_definitions(ccls PRIVATE target_include_directories(ccls PRIVATE src third_party - third_party/rapidjson/include - third_party/loguru - third_party/doctest) + third_party/rapidjson/include) ### Install @@ -214,7 +212,6 @@ target_sources(ccls PRIVATE src/query.cc src/serializer.cc src/test.cc - src/third_party_impl.cc src/utils.cc src/working_files.cc) diff --git a/src/fuzzy_match.cc b/src/fuzzy_match.cc index 1d5d6058..187d91c4 100644 --- a/src/fuzzy_match.cc +++ b/src/fuzzy_match.cc @@ -1,7 +1,5 @@ #include "fuzzy_match.h" -#include - #include #include #include @@ -133,6 +131,7 @@ int FuzzyMatcher::Match(std::string_view text) { return ret; } +#if 0 TEST_SUITE("fuzzy_match") { bool Ranks(std::string_view pat, std::vector texts) { FuzzyMatcher fuzzy(pat, 0); @@ -180,3 +179,4 @@ TEST_SUITE("fuzzy_match") { CHECK(Ranks("Int", {"int", "INT", "PRINT"})); } } +#endif diff --git a/src/main.cc b/src/main.cc index 495f8c47..11c7bb24 100644 --- a/src/main.cc +++ b/src/main.cc @@ -14,7 +14,6 @@ using namespace ccls; using namespace llvm; using namespace llvm::cl; -#include #include #include @@ -29,7 +28,6 @@ namespace { opt opt_help("h", desc("Alias for -help")); opt opt_verbose("v", desc("verbosity"), init(0)); opt opt_test_index("test-index", ValueOptional, init("!"), desc("run index tests")); -opt opt_test_unit("test-unit", desc("run unit tests")); opt opt_init("init", desc("extra initialization options")); opt opt_log_file("log-file", desc("log"), value_desc("filename")); @@ -53,9 +51,7 @@ int main(int argc, char** argv) { if (opt_help) { PrintHelpMessage(); - // Also emit doctest help if --test-unit is passed. - if (!opt_test_unit) - return 0; + return 0; } pipeline::Init(); @@ -77,20 +73,6 @@ int main(int argc, char** argv) { atexit(CloseLog); } - if (opt_test_unit) { - language_server = false; - doctest::Context context; - std::vector args{argv[0]}; - if (opt_help) - args.push_back("-h"); - for (auto& arg : opt_extra) - args.push_back(arg.c_str()); - context.applyCommandLine(args.size(), args.data()); - int res = context.run(); - if (res != 0 || context.shouldExit()) - return res; - } - if (opt_test_index != "!") { language_server = false; if (!RunIndexTests(opt_test_index, sys::Process::StandardInIsUserInput())) diff --git a/src/match.cc b/src/match.cc index 178095d6..58a6f73d 100644 --- a/src/match.cc +++ b/src/match.cc @@ -4,8 +4,6 @@ #include "pipeline.hh" using namespace ccls; -#include - // static std::optional Matcher::Create(const std::string& search) { /* @@ -75,15 +73,3 @@ bool GroupMatch::IsMatch(const std::string& value, return true; } - -TEST_SUITE("Matcher") { - TEST_CASE("sanity") { - // Matcher m("abc"); - // TODO: check case - // CHECK(m.IsMatch("abc")); - // CHECK(m.IsMatch("fooabc")); - // CHECK(m.IsMatch("abc")); - // CHECK(m.IsMatch("abcfoo")); - // CHECK(m.IsMatch("11a11b11c11")); - } -} diff --git a/src/project.cc b/src/project.cc index 202e7510..dc729ad0 100644 --- a/src/project.cc +++ b/src/project.cc @@ -26,7 +26,6 @@ using namespace llvm; using namespace llvm::opt; #include -#include #include #if defined(__unix__) || defined(__APPLE__) @@ -493,253 +492,3 @@ void Project::Index(WorkingFiles* wfiles, // trigger refreshing semantic highlight for all working files. pipeline::Index("", {}, false); } - -TEST_SUITE("Project") { - void CheckFlags(const std::string& directory, const std::string& file, - std::vector raw, - std::vector expected) { - if (g_config) - delete g_config; - g_config = new Config; - g_config->clang.resourceDir = "/w/resource_dir/"; - ProjectConfig project; - project.project_dir = "/w/c/s/"; - - CompileCommandsEntry entry; - entry.directory = directory; - entry.args = raw; - entry.file = file; - Project::Entry result = - GetCompilationEntryFromCompileCommandEntry(&project, entry); - - if (result.args != expected) { - fprintf(stderr, "Raw: %s\n", StringJoin(raw).c_str()); - fprintf(stderr, "Expected: %s\n", StringJoin(expected).c_str()); - fprintf(stderr, "Actual: %s\n", StringJoin(result.args).c_str()); - } - REQUIRE(result.args == expected); - } - - void CheckFlags(std::vector raw, - std::vector expected) { - CheckFlags("/dir/", "file.cc", raw, expected); - } - - TEST_CASE("strip meta-compiler invocations") { - CheckFlags( - /* raw */ {"clang", "-lstdc++", "myfile.cc"}, - /* expected */ - {"clang", "-lstdc++", "/dir/myfile.cc", - "-resource-dir=/w/resource_dir/", "-working-directory=/dir/", - "-Wno-unknown-warning-option", "-fparse-all-comments"}); - - CheckFlags( - /* raw */ {"clang.exe"}, - /* expected */ - {"clang.exe", "-resource-dir=/w/resource_dir/", - "-working-directory=/dir/", "-Wno-unknown-warning-option", - "-fparse-all-comments"}); - } - -#ifdef _WIN32 - TEST_CASE("Windows path normalization") { - CheckFlags("E:/workdir", "E:/workdir/bar.cc", /* raw */ {"clang", "bar.cc"}, - /* expected */ - {"clang", "-working-directory=E:/workdir", "E:/workdir/bar.cc", - "-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option", - "-fparse-all-comments"}); - - CheckFlags("E:/workdir", "E:/workdir/bar.cc", - /* raw */ {"clang", "E:/workdir/bar.cc"}, - /* expected */ - {"clang", "-working-directory=E:/workdir", "E:/workdir/bar.cc", - "-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option", - "-fparse-all-comments"}); - - CheckFlags("E:/workdir", "E:/workdir/bar.cc", - /* raw */ {"clang-cl.exe", "/I./test", "E:/workdir/bar.cc"}, - /* expected */ - {"clang-cl.exe", "-working-directory=E:/workdir", - "/I&E:/workdir/./test", "E:/workdir/bar.cc", - "-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option", - "-fparse-all-comments"}); - - CheckFlags("E:/workdir", "E:/workdir/bar.cc", - /* raw */ - {"cl.exe", "/I../third_party/test/include", "E:/workdir/bar.cc"}, - /* expected */ - {"cl.exe", "-working-directory=E:/workdir", - "/I&E:/workdir/../third_party/test/include", - "E:/workdir/bar.cc", "-resource-dir=/w/resource_dir/", - "-Wno-unknown-warning-option", "-fparse-all-comments"}); - } -#endif - - TEST_CASE("Path in args") { - CheckFlags( - "/home/user", "/home/user/foo/bar.c", - /* raw */ {"cc", "-O0", "foo/bar.c"}, - /* expected */ - {"cc", "-O0", "/home/user/foo/bar.c", "-resource-dir=/w/resource_dir/", - "-working-directory=/home/user", "-Wno-unknown-warning-option", - "-fparse-all-comments"}); - } - - TEST_CASE("Directory extraction") { - if (g_config) - delete g_config; - g_config = new Config; - ProjectConfig config; - config.project_dir = "/w/c/s/"; - - CompileCommandsEntry entry; - entry.directory = "/base"; - entry.args = {"clang", - "-I/a_absolute1", - "--foobar", - "-I", - "/a_absolute2", - "--foobar", - "-Ia_relative1", - "--foobar", - "-isystem", - "a_relative2", - "--foobar", - "-iquote/q_absolute1", - "--foobar", - "-iquote", - "/q_absolute2", - "--foobar", - "-iquoteq_relative1", - "--foobar", - "-iquote", - "q_relative2", - "--foobar", - "foo.cc"}; - entry.file = "foo.cc"; - Project::Entry result = - GetCompilationEntryFromCompileCommandEntry(&config, entry); - - std::unordered_set angle_expected{ - "/a_absolute1", "/a_absolute2", "/base/a_relative1", - "/base/a_relative2"}; - std::unordered_set quote_expected{ - "/a_absolute1", "/a_absolute2", "/base/a_relative1", - "/q_absolute1", "/q_absolute2", "/base/q_relative1", - "/base/q_relative2"}; - REQUIRE(config.angle_dirs == angle_expected); - REQUIRE(config.quote_dirs == quote_expected); - } - - TEST_CASE("Entry inference") { - Project p; - { - Project::Entry e; - e.args = {"arg1"}; - e.filename = "/a/b/c/d/bar.cc"; - p.entries.push_back(e); - } - { - Project::Entry e; - e.args = {"arg2"}; - e.filename = "/a/b/c/baz.cc"; - p.entries.push_back(e); - } - - // Guess at same directory level, when there are parent directories. - { - std::optional entry = - p.FindCompilationEntryForFile("/a/b/c/d/new.cc"); - REQUIRE(entry.has_value()); - REQUIRE(entry->args == std::vector{"arg1"}); - } - - // Guess at same directory level, when there are child directories. - { - std::optional entry = - p.FindCompilationEntryForFile("/a/b/c/new.cc"); - REQUIRE(entry.has_value()); - REQUIRE(entry->args == std::vector{"arg2"}); - } - - // Guess at new directory (use the closest parent directory). - { - std::optional entry = - p.FindCompilationEntryForFile("/a/b/c/new/new.cc"); - REQUIRE(entry.has_value()); - REQUIRE(entry->args == std::vector{"arg2"}); - } - } - - TEST_CASE("Entry inference remaps file names") { - Project p; - { - Project::Entry e; - e.args = {"a", "b", "aaaa.cc", "d"}; - e.filename = "absolute/aaaa.cc"; - p.entries.push_back(e); - } - - { - std::optional entry = p.FindCompilationEntryForFile("ee.cc"); - REQUIRE(entry.has_value()); - REQUIRE(entry->args == std::vector{"a", "b", "ee.cc", "d"}); - } - } - - TEST_CASE("Entry inference prefers same file endings") { - Project p; - { - Project::Entry e; - e.args = {"arg1"}; - e.filename = "common/simple_browsertest.cc"; - p.entries.push_back(e); - } - { - Project::Entry e; - e.args = {"arg2"}; - e.filename = "common/simple_unittest.cc"; - p.entries.push_back(e); - } - { - Project::Entry e; - e.args = {"arg3"}; - e.filename = "common/a/simple_unittest.cc"; - p.entries.push_back(e); - } - - // Prefer files with the same ending. - { - std::optional entry = - p.FindCompilationEntryForFile("my_browsertest.cc"); - REQUIRE(entry.has_value()); - REQUIRE(entry->args == std::vector{"arg1"}); - } - { - std::optional entry = - p.FindCompilationEntryForFile("my_unittest.cc"); - REQUIRE(entry.has_value()); - REQUIRE(entry->args == std::vector{"arg2"}); - } - { - std::optional entry = - p.FindCompilationEntryForFile("common/my_browsertest.cc"); - REQUIRE(entry.has_value()); - REQUIRE(entry->args == std::vector{"arg1"}); - } - { - std::optional entry = - p.FindCompilationEntryForFile("common/my_unittest.cc"); - REQUIRE(entry.has_value()); - REQUIRE(entry->args == std::vector{"arg2"}); - } - - // Prefer the same directory over matching file-ending. - { - std::optional entry = - p.FindCompilationEntryForFile("common/a/foo.cc"); - REQUIRE(entry.has_value()); - REQUIRE(entry->args == std::vector{"arg3"}); - } - } -} diff --git a/src/query.cc b/src/query.cc index b4f8c613..d7014065 100644 --- a/src/query.cc +++ b/src/query.cc @@ -4,8 +4,6 @@ #include "serializer.h" #include "serializers/json.h" -#include - #include #include #include diff --git a/src/test.cc b/src/test.cc index 0c89f688..cade7314 100644 --- a/src/test.cc +++ b/src/test.cc @@ -6,7 +6,6 @@ #include "serializer.h" #include "utils.h" -#include #include #include #include diff --git a/src/third_party_impl.cc b/src/third_party_impl.cc deleted file mode 100644 index 572a07d3..00000000 --- a/src/third_party_impl.cc +++ /dev/null @@ -1,2 +0,0 @@ -#define DOCTEST_CONFIG_IMPLEMENT -#include diff --git a/src/working_files.cc b/src/working_files.cc index d2448daf..1ad076c2 100644 --- a/src/working_files.cc +++ b/src/working_files.cc @@ -3,8 +3,6 @@ #include "log.hh" #include "position.h" -#include - #include #include #include diff --git a/third_party/doctest b/third_party/doctest deleted file mode 160000 index b40b7e79..00000000 --- a/third_party/doctest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b40b7e799deabac916d631d181a7f19f3060acc5