diff options
Diffstat (limited to 'test-ymake.cpp')
-rw-r--r-- | test-ymake.cpp | 85 |
1 files changed, 83 insertions, 2 deletions
diff --git a/test-ymake.cpp b/test-ymake.cpp index 9d6cd43..973e827 100644 --- a/test-ymake.cpp +++ b/test-ymake.cpp @@ -171,11 +171,16 @@ TEST_F(ymakeTest, clean_one_cpp) TEST_F(ymakeTest, YMakefile_missing) { - int result = run_command("../ymake"); + std::vector<std::string> output; + int result = run_command("../ymake", output); EXPECT_NE(result, 0); + ASSERT_EQ(output.size(), 1); + EXPECT_EQ(output[0], "ymake: YMakefile not found"); - result = run_command("../ymake clean"); + result = run_command("../ymake clean", output); EXPECT_NE(result, 0); + ASSERT_EQ(output.size(), 1); + EXPECT_EQ(output[0], "ymake: YMakefile not found"); } TEST_F(ymakeTest, build_three_cpp) @@ -229,6 +234,41 @@ TEST_F(ymakeTest, build_three_cpp) EXPECT_TRUE(!fs::exists("hello")); } +TEST_F(ymakeTest, rebuild) +{ + create_file("hello.cpp", R"(int main(int argc, char* argv[]) +{ + return 0; +})"); + create_file("second.cpp", R"( +#include "second.h" +)"); + create_file("second.h", R"( +#pragma once +)"); + + create_file("YMakefile", R"( +<ymake> + <build> + <name>hello</name> + <source>hello.cpp</source> + <source>second.cpp</source> + </build> +</ymake> +)"); + + std::vector<std::string> output; + int result = run_command("../ymake", output); + EXPECT_EQ(result, 0); + + EXPECT_EQ(output.size(), 3); // compile 2, link 1 + + run_command("touch hello.cpp"); + result = run_command("../ymake", output); + EXPECT_EQ(result, 0); + EXPECT_EQ(output.size(), 2); // compile 1, link 1 +} + TEST_F(ymakeTest, build_cpp_c_cc) { create_file("hello.cpp", R"(int main(int argc, char* argv[]) @@ -1181,6 +1221,47 @@ __attribute__((visibility("default"))) int hello(); EXPECT_TRUE(!fs::exists("runmain")); } +TEST_F(ymakeTest, dependencies_on_YMakefile) +{ + create_file("hello.cpp", R"(int main(int argc, char* argv[]) +{ + return 0; +})"); + + create_file("YMakefile", R"( +<ymake> + <build> + <name>hello</name> + <source>hello.cpp</source> + </build> +</ymake> +)"); + + std::vector<std::string> output; + int result = run_command("../ymake", output); + EXPECT_EQ(result, 0); + + EXPECT_EQ(output.size(), 2); // compile, link + + result = run_command("./hello", output); + EXPECT_EQ(result, 0); + EXPECT_EQ(output.size(), 0); // run + + result = run_command("../ymake", output); + EXPECT_EQ(result, 0); + EXPECT_EQ(output.size(), 1); // "Everything up to date" + EXPECT_EQ(output[0], "Everything up to date."); + + result = run_command("touch YMakefile"); + EXPECT_EQ(result, 0); + + result = run_command("../ymake", output); + EXPECT_EQ(result, 0); + + EXPECT_EQ(output.size(), 2); // compile, link +} + + TEST_F(yscanTest, no_cpp_file) { std::string output; |