From 6086ec079a31276c81decdd7b5b5daaafdeb58ca Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Thu, 9 May 2024 18:40:42 +0200 Subject: Sort yscan output, tests --- test-ymake.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'test-ymake.cpp') diff --git a/test-ymake.cpp b/test-ymake.cpp index dfed871..1df3ce0 100644 --- a/test-ymake.cpp +++ b/test-ymake.cpp @@ -187,14 +187,32 @@ TEST_F(ymakeTest, build_three_cpp) )"); + EXPECT_TRUE(!fs::exists("hello.o")); + EXPECT_TRUE(!fs::exists("second.o")); + EXPECT_TRUE(!fs::exists("third.o")); + EXPECT_TRUE(!fs::exists("hello")); + std::vector output; int result = run_command("../ymake", output); EXPECT_EQ(result, 0); EXPECT_EQ(output.size(), 4); // compile 3, link 1 + + EXPECT_TRUE(fs::exists("hello.o")); + EXPECT_TRUE(fs::exists("second.o")); + EXPECT_TRUE(fs::exists("third.o")); + EXPECT_TRUE(fs::exists("hello")); + + result = run_command("../ymake clean"); + EXPECT_EQ(result, 0); + + EXPECT_TRUE(!fs::exists("hello.o")); + EXPECT_TRUE(!fs::exists("second.o")); + EXPECT_TRUE(!fs::exists("third.o")); + EXPECT_TRUE(!fs::exists("hello")); } -// TODO: test .c .cc .cpp +// TODO: test file extensions .c .cc .cpp // TODO: multiple builds // TODO: test tests // TODO: test g++/clang++ @@ -234,7 +252,32 @@ TEST_F(yscanTest, one_cpp_file) )"); } -// TODO: test multiple files +TEST_F(yscanTest, one_three_files) +{ + create_file("hello.cpp", R"(int main(int argc, char* argv[]) +{ + return 0; +})"); + create_file("second.cpp", R"()"); + create_file("third.cpp", R"()"); + create_file("fourth.cpp", R"()"); + + std::string output; + int result = run_command("../yscan", output); + EXPECT_EQ(result, 0); + + EXPECT_EQ(output, R"( + + testdir1 + fourth.cpp + hello.cpp + second.cpp + third.cpp + + +)"); +} + // TODO: test multiple builds // TODO: test tests -- cgit v1.2.3