From b68c73a1938d382d891ace12938e990a60fc2ec0 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Fri, 9 Aug 2024 12:14:17 +0200 Subject: components: add test on dependencies Components themselves can have public dependencies; those need to be available (as compile deps) for the combined library. Verify this by extending the test such that the public dependency is actually used in the header file. While there, also increase coverage by assertions. --- tests/test_cases/deps/TARGETS | 25 +++++++++++++++++++++++++ tests/test_cases/deps/components/TARGETS | 8 ++++++++ tests/test_cases/deps/components/foo.hpp | 4 +++- tests/test_cases/deps/components/foodep.cpp | 2 +- tests/test_cases/deps/components/foodep.hpp | 4 +++- 5 files changed, 40 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test_cases/deps/TARGETS b/tests/test_cases/deps/TARGETS index 662eea2..b9b1344 100644 --- a/tests/test_cases/deps/TARGETS +++ b/tests/test_cases/deps/TARGETS @@ -288,6 +288,8 @@ , "+combined_shared_lib" , "+main" , "+main-dynamic" + , "+installed_static" + , "+installed_shared" ] , "asserts": [ "test -f foo/foo.hpp" @@ -301,13 +303,19 @@ , "test -f combined_static_lib/bar.hpp" , "! test -f combined_static_lib/libfoo.a" , "! test -f combined_static_lib/libbar.a" + , "! test -f combined_static_lib/foodep.hpp" + , "! test -f combined_static_lib/foo.o" + , "! test -f combined_static_lib/bar.o" , "test -f combined_shared_lib/libcombshared.so" , "test -f combined_shared_lib/foo.hpp" , "test -f combined_shared_lib/bar.hpp" + , "! test -f combined_shared_lib/foodep.hpp" , "! test -f combined_shared_lib/libfoo.a" , "! test -f combined_shared_lib/libbar.a" , "! test -f combined_shared_lib/libfoo.so" , "! test -f combined_shared_lib/libbar.so" + , "! test -f combined_shared_lib/foo.o" + , "! test -f combined_shared_lib/bar.o" , "./main/main" , "./main/main | grep 'Hello-from-main'" , "./main/main | grep 'bar.3'" @@ -316,6 +324,23 @@ , "./main-dynamic/bin/main | grep 'Hello-from-main'" , "./main-dynamic/bin/main | grep 'bar.3'" , "./main-dynamic/bin/main | grep 'foo.15'" + , "test -f installed_static/include/bar.hpp" + , "test -f installed_static/include/foo.hpp" + , "test -f installed_static/include/foodep.hpp" + , "test -f installed_static/lib/libcombstatic.a" + , "test -f installed_static/lib/libfoodep.a" + , "! test -f installed_static/lib/libbar.a" + , "! test -f installed_static/lib/libfoo.a" + , "test -f installed_shared/include/bar.hpp" + , "test -f installed_shared/include/foo.hpp" + , "test -f installed_shared/include/foodep.hpp" + , "test -f installed_shared/lib/libcombshared.so" + , "! test -f installed_shared/lib/libfoodep.a" + , "! test -f installed_shared/lib/libfoodep.so" + , "! test -f installed_shared/lib/libbar.a" + , "! test -f installed_shared/lib/libbar.so" + , "! test -f installed_shared/lib/libfoo.a" + , "! test -f installed_shared/lib/libfoo.so" ] , "data": [["TREE", null, "components"]] } diff --git a/tests/test_cases/deps/components/TARGETS b/tests/test_cases/deps/components/TARGETS index edd62db..62a599c 100644 --- a/tests/test_cases/deps/components/TARGETS +++ b/tests/test_cases/deps/components/TARGETS @@ -44,4 +44,12 @@ { "type": ["@", "rules", "CC", "install-with-deps"] , "targets": ["main-shared"] } +, "installed_static": + { "type": ["@", "rules", "CC", "install-with-deps"] + , "targets": ["combined_static_lib"] + } +, "installed_shared": + { "type": ["@", "rules", "CC", "install-with-deps"] + , "targets": ["combined_shared_lib"] + } } diff --git a/tests/test_cases/deps/components/foo.hpp b/tests/test_cases/deps/components/foo.hpp index f919ea3..45c286c 100644 --- a/tests/test_cases/deps/components/foo.hpp +++ b/tests/test_cases/deps/components/foo.hpp @@ -1,6 +1,8 @@ #ifndef FOO_HPP #define FOO_HPP -int foo(int); +#include "foodep.hpp" + +foo_t foo(foo_t); #endif diff --git a/tests/test_cases/deps/components/foodep.cpp b/tests/test_cases/deps/components/foodep.cpp index 70dc491..e26c335 100644 --- a/tests/test_cases/deps/components/foodep.cpp +++ b/tests/test_cases/deps/components/foodep.cpp @@ -3,7 +3,7 @@ #include #include -int foodep(int x) { +foo_t foodep(foo_t x) { std::cout << "foodep(" << x << ")" << std::endl; return x + 2; } diff --git a/tests/test_cases/deps/components/foodep.hpp b/tests/test_cases/deps/components/foodep.hpp index 792c63b..ea16bb0 100644 --- a/tests/test_cases/deps/components/foodep.hpp +++ b/tests/test_cases/deps/components/foodep.hpp @@ -1,6 +1,8 @@ #ifndef FOODEP_HPP #define FOODEP_HPP -int foodep(int); +typedef int foo_t; + +foo_t foodep(foo_t); #endif -- cgit v1.2.3