summaryrefslogtreecommitdiffhomepage
path: root/test-ymake.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2024-05-31 17:28:53 +0200
committerRoland Reichwein <mail@reichwein.it>2024-05-31 17:28:53 +0200
commit16e95b415d0f96be88764fb54e04d48dd3ad9302 (patch)
treec61c4ef5c5439f595e1b94e8e26f4f9fbfa7c42b /test-ymake.cpp
parent5ba7c40ffa7fff89267639df2e1d3bba13e8b451 (diff)
use lib from sub-subdir, test
Diffstat (limited to 'test-ymake.cpp')
-rw-r--r--test-ymake.cpp72
1 files changed, 71 insertions, 1 deletions
diff --git a/test-ymake.cpp b/test-ymake.cpp
index 820befe..dc50bdb 100644
--- a/test-ymake.cpp
+++ b/test-ymake.cpp
@@ -1006,9 +1006,79 @@ __attribute__((visibility("default"))) int hello();
EXPECT_TRUE(!fs::exists("runmain"));
}
+TEST_F(ymakeTest, use_one_dynamic_lib_from_subsubdir)
+{
+ create_file("YMakefile", R"(
+<ymake>
+ <build>
+ <name>runmain</name>
+ <source>runmain.cpp</source>
+ <linklib>subdir1/subdir2/libhello.so</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>libhello.so.1.0.0</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
+__attribute__((visibility("default"))) int hello();
+)");
+
+ std::vector<std::string> output;
+ int result = run_command("../ymake", output);
+ EXPECT_EQ(result, 0);
+ ASSERT_EQ(output.size(), 6); // compile, link, compile, link, 2 dyn. lib links
+
+ EXPECT_TRUE(fs::exists("subdir1/subdir2/hello.o"));
+ EXPECT_TRUE(fs::exists("subdir1/subdir2/libhello.so.1.0.0"));
+ EXPECT_TRUE(fs::exists("subdir1/subdir2/libhello.so.1"));
+ EXPECT_TRUE(fs::exists("subdir1/subdir2/libhello.so"));
+ 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(), 8); // hello.o, hello.d, hello.so.1.0.0, hello.so.1, hello.so, runmain.o, runmain.d, runmain
+
+ EXPECT_TRUE(!fs::exists("subdir1/subdir2/hello.o"));
+ EXPECT_TRUE(!fs::exists("subdir1/subdir2/libhello.so.1.0.0"));
+ EXPECT_TRUE(!fs::exists("subdir1/subdir2/libhello.so.1"));
+ EXPECT_TRUE(!fs::exists("subdir1/subdir2/libhello.so"));
+ EXPECT_TRUE(!fs::exists("runmain.o"));
+ EXPECT_TRUE(!fs::exists("runmain"));
+}
+
// TODO:
// use static lib from subdir in subdir
-// use dynamic lib from subdir in subdir
TEST_F(yscanTest, no_cpp_file)
{