Fix unit tests properly

This commit is contained in:
Jacob Dufault 2018-01-24 10:42:09 -08:00
parent 549f4f3674
commit 3f4866208f

View File

@ -543,9 +543,6 @@ TEST_SUITE("Project") {
std::cout << "Expected: " << StringJoin(expected) << std::endl; std::cout << "Expected: " << StringJoin(expected) << std::endl;
std::cout << "Actual: " << StringJoin(result.args) << std::endl; std::cout << "Actual: " << StringJoin(result.args) << std::endl;
} }
result.args.erase(std::remove(result.args.begin(), result.args.end(),
std::string("-fparse-all-comments")),
result.args.end());
for (int i = 0; i < std::min(result.args.size(), expected.size()); ++i) { for (int i = 0; i < std::min(result.args.size(), expected.size()); ++i) {
if (result.args[i] != expected[i]) { if (result.args[i] != expected[i]) {
std::cout << std::endl; std::cout << std::endl;
@ -568,25 +565,28 @@ TEST_SUITE("Project") {
/* expected */ /* expected */
{"clang", "-working-directory", "/dir/", "-xc++", "-std=c++14", {"clang", "-working-directory", "/dir/", "-xc++", "-std=c++14",
"-lstdc++", "&/dir/myfile.cc", "-resource-dir=/w/resource_dir/", "-lstdc++", "&/dir/myfile.cc", "-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option"}); "-Wno-unknown-warning-option", "-fparse-all-comments"});
CheckFlags( CheckFlags(
/* raw */ {"clang.exe"}, /* raw */ {"clang.exe"},
/* expected */ /* expected */
{"clang.exe", "-working-directory", "/dir/", "-xc++", "-std=c++14", {"clang.exe", "-working-directory", "/dir/", "-xc++", "-std=c++14",
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option"}); "-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option",
"-fparse-all-comments"});
CheckFlags( CheckFlags(
/* raw */ {"goma", "clang"}, /* raw */ {"goma", "clang"},
/* expected */ /* expected */
{"clang", "-working-directory", "/dir/", "-xc++", "-std=c++14", {"clang", "-working-directory", "/dir/", "-xc++", "-std=c++14",
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option"}); "-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option",
"-fparse-all-comments"});
CheckFlags( CheckFlags(
/* raw */ {"goma", "clang", "--foo"}, /* raw */ {"goma", "clang", "--foo"},
/* expected */ /* expected */
{"clang", "-working-directory", "/dir/", "-xc++", "-std=c++14", "--foo", {"clang", "-working-directory", "/dir/", "-xc++", "-std=c++14", "--foo",
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option"}); "-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option",
"-fparse-all-comments"});
} }
TEST_CASE("Windows path normalization") { TEST_CASE("Windows path normalization") {
@ -595,7 +595,7 @@ TEST_SUITE("Project") {
/* expected */ /* expected */
{"clang", "-working-directory", "E:/workdir", "-xc++", "-std=c++14", {"clang", "-working-directory", "E:/workdir", "-xc++", "-std=c++14",
"&E:/workdir/bar.cc", "-resource-dir=/w/resource_dir/", "&E:/workdir/bar.cc", "-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option"}); "-Wno-unknown-warning-option", "-fparse-all-comments"});
CheckFlags( CheckFlags(
"E:/workdir", "E:/workdir/bar.cc", "E:/workdir", "E:/workdir/bar.cc",
@ -603,7 +603,7 @@ TEST_SUITE("Project") {
/* expected */ /* expected */
{"clang", "-working-directory", "E:/workdir", "-xc++", "-std=c++14", {"clang", "-working-directory", "E:/workdir", "-xc++", "-std=c++14",
"&E:/workdir/bar.cc", "-resource-dir=/w/resource_dir/", "&E:/workdir/bar.cc", "-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option"}); "-Wno-unknown-warning-option", "-fparse-all-comments"});
} }
TEST_CASE("Path in args") { TEST_CASE("Path in args") {
@ -613,7 +613,7 @@ TEST_SUITE("Project") {
/* expected */ /* expected */
{"cc", "-working-directory", "/home/user", "-xc", "-std=gnu11", "-O0", {"cc", "-working-directory", "/home/user", "-xc", "-std=gnu11", "-O0",
"&/home/user/foo/bar.c", "-resource-dir=/w/resource_dir/", "&/home/user/foo/bar.c", "-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option"}); "-Wno-unknown-warning-option", "-fparse-all-comments"});
} }
TEST_CASE("Implied binary") { TEST_CASE("Implied binary") {
@ -623,7 +623,7 @@ TEST_SUITE("Project") {
/* expected */ /* expected */
{"clang++", "-working-directory", "/home/user", "-xc++", "-std=c++14", {"clang++", "-working-directory", "/home/user", "-xc++", "-std=c++14",
"-DDONT_IGNORE_ME", "-resource-dir=/w/resource_dir/", "-DDONT_IGNORE_ME", "-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option"}); "-Wno-unknown-warning-option", "-fparse-all-comments"});
} }
// Checks flag parsing for a random chromium file in comparison to what // Checks flag parsing for a random chromium file in comparison to what
@ -973,7 +973,9 @@ TEST_SUITE("Project") {
"&/w/c/s/out/Release/../../ash/login/ui/" "&/w/c/s/out/Release/../../ash/login/ui/"
"lock_screen_sanity_unittest.cc", "lock_screen_sanity_unittest.cc",
"-resource-dir=/w/resource_dir/", "-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option"}); "-Wno-unknown-warning-option",
"-fparse-all-comments"
});
} }
// Checks flag parsing for an example chromium file. // Checks flag parsing for an example chromium file.
@ -1297,7 +1299,9 @@ TEST_SUITE("Project") {
"-fvisibility-inlines-hidden", "-fvisibility-inlines-hidden",
"&/w/c/s/out/Release/../../apps/app_lifetime_monitor.cc", "&/w/c/s/out/Release/../../apps/app_lifetime_monitor.cc",
"-resource-dir=/w/resource_dir/", "-resource-dir=/w/resource_dir/",
"-Wno-unknown-warning-option"}); "-Wno-unknown-warning-option",
"-fparse-all-comments"
});
} }
TEST_CASE("Directory extraction") { TEST_CASE("Directory extraction") {