diff options
-rw-r--r-- | test-ymake.cpp | 69 |
1 files changed, 66 insertions, 3 deletions
diff --git a/test-ymake.cpp b/test-ymake.cpp index dc50bdb..886a43b 100644 --- a/test-ymake.cpp +++ b/test-ymake.cpp @@ -871,6 +871,72 @@ extern int hello(); EXPECT_TRUE(!fs::exists("runmain")); } +TEST_F(ymakeTest, use_one_static_lib_from_subsubdir) +{ + create_file("YMakefile", R"( +<ymake> + <build> + <name>runmain</name> + <source>runmain.cpp</source> + <linklib>subdir1/subdir2/hello.a</linklib> + </build> +</ymake> +)"); + + create_file("runmain.cpp", R"(#include "subdir1/subdir2/hello.h" +int main(int argc, char* argv[]) +{ + hello(); + return 0; +})"); + + fs::create_directories("subdir1/subdir2"); + create_file("subdir1/subdir2/YMakefile", R"( +<ymake> + <build> + <name>hello.a</name> + <source>hello.cpp</source> + </build> +</ymake> +)"); + + create_file("subdir1/subdir2/hello.cpp", R"(#include "hello.h" +#include <iostream> +int hello() +{ + std::cout << "Hello." << std::endl; + return 0; +})"); + + create_file("subdir1/subdir2/hello.h", R"(#pragma once +extern int hello(); +)"); + + std::vector<std::string> output; + int result = run_command("../ymake", output); + EXPECT_EQ(result, 0); + ASSERT_EQ(output.size(), 4); // compile, link, compile, link + + EXPECT_TRUE(fs::exists("subdir1/subdir2/hello.o")); + EXPECT_TRUE(fs::exists("subdir1/subdir2/hello.a")); + EXPECT_TRUE(fs::exists("runmain.o")); + EXPECT_TRUE(fs::exists("runmain")); + + result = run_command("./runmain", output); + EXPECT_EQ(result, 0); + ASSERT_EQ(output.size(), 1); + EXPECT_EQ(output[0], "Hello."); + + result = run_command("../ymake clean", output); + EXPECT_EQ(result, 0); + ASSERT_EQ(output.size(), 6); // hello.o, hello.d, hello.a, runmain.o, runmain.d, runmain + + EXPECT_TRUE(!fs::exists("subdir1/subdir2/hello.o")); + EXPECT_TRUE(!fs::exists("subdir1/subdir2/hello.a")); + EXPECT_TRUE(!fs::exists("runmain.o")); + EXPECT_TRUE(!fs::exists("runmain")); +} + TEST_F(ymakeTest, use_one_dynamic_lib) { create_file("YMakefile", R"( @@ -1077,9 +1143,6 @@ __attribute__((visibility("default"))) int hello(); EXPECT_TRUE(!fs::exists("runmain")); } -// TODO: -// use static lib from subdir in subdir - TEST_F(yscanTest, no_cpp_file) { std::string output; |