summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-08-09 15:32:40 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-08-09 16:49:40 +0200
commit2e8f03a66a8690dcd137834e0a3479e20b560b78 (patch)
tree8ce7ec9b0a368e4939359d7451662f3b9344eb6b
parent8a6e4182cbac4bd6afd88e1dc222303b0df57001 (diff)
downloadrules-cc-2e8f03a66a8690dcd137834e0a3479e20b560b78.tar.gz
Add a test for components having components
-rw-r--r--tests/test_cases/deps/TARGETS34
-rw-r--r--tests/test_cases/deps/transitive-components/TARGETS64
-rw-r--r--tests/test_cases/deps/transitive-components/bar.cpp10
-rw-r--r--tests/test_cases/deps/transitive-components/bar.hpp8
-rw-r--r--tests/test_cases/deps/transitive-components/bardep.cpp9
-rw-r--r--tests/test_cases/deps/transitive-components/bardep.hpp8
-rw-r--r--tests/test_cases/deps/transitive-components/baz.cpp10
-rw-r--r--tests/test_cases/deps/transitive-components/baz.hpp8
-rw-r--r--tests/test_cases/deps/transitive-components/bazdep.cpp9
-rw-r--r--tests/test_cases/deps/transitive-components/bazdep.hpp8
-rw-r--r--tests/test_cases/deps/transitive-components/foo.cpp10
-rw-r--r--tests/test_cases/deps/transitive-components/foo.hpp8
-rw-r--r--tests/test_cases/deps/transitive-components/foodep.cpp9
-rw-r--r--tests/test_cases/deps/transitive-components/foodep.hpp8
-rw-r--r--tests/test_cases/deps/transitive-components/main.cpp11
15 files changed, 214 insertions, 0 deletions
diff --git a/tests/test_cases/deps/TARGETS b/tests/test_cases/deps/TARGETS
index b9b1344..fb3060a 100644
--- a/tests/test_cases/deps/TARGETS
+++ b/tests/test_cases/deps/TARGETS
@@ -344,6 +344,39 @@
]
, "data": [["TREE", null, "components"]]
}
+, "transitive-components":
+ { "type": ["test_rules", "test_case"]
+ , "name": ["deps_transitive_components"]
+ , "targets":
+ ["+baz", "+bar", "+foo", "+main", "+shared-foo", "+installed-shared-main"]
+ , "asserts":
+ [ "test -f foo/libfoo.a"
+ , "test -f foo/foo.hpp"
+ , "test -f foo/bar.hpp"
+ , "test -f foo/baz.hpp"
+ , "! test -f foo/foodep.hpp"
+ , "! test -f foo/bardep.hpp"
+ , "! test -f foo/bazdep.hpp"
+ , "./main/main"
+ , "./main/main | grep main"
+ , "./main/main | grep foodep"
+ , "./main/main | grep bardep"
+ , "./main/main | grep bazdep"
+ , "test -f shared-foo/libfoo.so"
+ , "test -f shared-foo/foo.hpp"
+ , "test -f shared-foo/bar.hpp"
+ , "test -f shared-foo/baz.hpp"
+ , "! test -f shared-foo/foodep.hpp"
+ , "! test -f shared-foo/bardep.hpp"
+ , "! test -f shared-foo/bazdep.hpp"
+ , "./installed-shared-main/bin/main"
+ , "./installed-shared-main/bin/main | grep main"
+ , "./installed-shared-main/bin/main | grep foodep"
+ , "./installed-shared-main/bin/main | grep bardep"
+ , "./installed-shared-main/bin/main | grep bazdep"
+ ]
+ , "data": [["TREE", null, "transitive-components"]]
+ }
, "ALL":
{ "type": "install"
, "deps":
@@ -355,6 +388,7 @@
, "cmake"
, "install"
, "components"
+ , "transitive-components"
]
, "tainted": ["test"]
}
diff --git a/tests/test_cases/deps/transitive-components/TARGETS b/tests/test_cases/deps/transitive-components/TARGETS
new file mode 100644
index 0000000..969fbe0
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/TARGETS
@@ -0,0 +1,64 @@
+{ "foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "hdrs": ["foo.hpp"]
+ , "srcs": ["foo.cpp"]
+ , "deps": ["foodep"]
+ , "components": ["bar"]
+ }
+, "foodep":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foodep"]
+ , "hdrs": ["foodep.hpp"]
+ , "srcs": ["foodep.cpp"]
+ }
+, "bar":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bar"]
+ , "hdrs": ["bar.hpp"]
+ , "srcs": ["bar.cpp"]
+ , "deps": ["bardep"]
+ , "components": ["baz"]
+ }
+, "bardep":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bardep"]
+ , "hdrs": ["bardep.hpp"]
+ , "srcs": ["bardep.cpp"]
+ }
+, "baz":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["baz"]
+ , "hdrs": ["baz.hpp"]
+ , "srcs": ["baz.cpp"]
+ , "deps": ["bazdep"]
+ }
+, "bazdep":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["bazdep"]
+ , "hdrs": ["bazdep.hpp"]
+ , "srcs": ["bazdep.cpp"]
+ }
+, "main":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main.cpp"]
+ , "private-deps": ["foo"]
+ }
+, "shared-foo":
+ { "type": ["@", "rules", "CC", "library"]
+ , "name": ["foo"]
+ , "shared": [""]
+ , "components": ["foo"]
+ }
+, "shared-main":
+ { "type": ["@", "rules", "CC", "binary"]
+ , "name": ["main"]
+ , "srcs": ["main.cpp"]
+ , "private-deps": ["foo"]
+ }
+, "installed-shared-main":
+ { "type": ["@", "rules", "CC", "install-with-deps"]
+ , "targets": ["shared-main"]
+ }
+}
diff --git a/tests/test_cases/deps/transitive-components/bar.cpp b/tests/test_cases/deps/transitive-components/bar.cpp
new file mode 100644
index 0000000..437619c
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/bar.cpp
@@ -0,0 +1,10 @@
+#include "bar.hpp"
+
+#include "bardep.hpp"
+#include <iostream>
+#include <ostream>
+
+int bar(int x) {
+ std::cout << "bar(" << x << ")" << std::endl;
+ return bardep(x) * 7;
+}
diff --git a/tests/test_cases/deps/transitive-components/bar.hpp b/tests/test_cases/deps/transitive-components/bar.hpp
new file mode 100644
index 0000000..e29bfd7
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/bar.hpp
@@ -0,0 +1,8 @@
+#ifndef BAR_HPP
+#define BAR_HPP
+
+#include "bardep.hpp"
+
+bar_t bar(bar_t);
+
+#endif
diff --git a/tests/test_cases/deps/transitive-components/bardep.cpp b/tests/test_cases/deps/transitive-components/bardep.cpp
new file mode 100644
index 0000000..33931da
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/bardep.cpp
@@ -0,0 +1,9 @@
+#include "bardep.hpp"
+
+#include <iostream>
+#include <ostream>
+
+bar_t bardep(bar_t x) {
+ std::cout << "bardep(" << x << ")" << std::endl;
+ return x + 5;
+}
diff --git a/tests/test_cases/deps/transitive-components/bardep.hpp b/tests/test_cases/deps/transitive-components/bardep.hpp
new file mode 100644
index 0000000..ebfaef4
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/bardep.hpp
@@ -0,0 +1,8 @@
+#ifndef BARDEP_HPP
+#define BARDEP_HPP
+
+typedef int bar_t;
+
+bar_t bardep(bar_t);
+
+#endif
diff --git a/tests/test_cases/deps/transitive-components/baz.cpp b/tests/test_cases/deps/transitive-components/baz.cpp
new file mode 100644
index 0000000..0354d55
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/baz.cpp
@@ -0,0 +1,10 @@
+#include "baz.hpp"
+
+#include "bazdep.hpp"
+#include <iostream>
+#include <ostream>
+
+int baz(int x) {
+ std::cout << "baz(" << x << ")" << std::endl;
+ return bazdep(x) * 13;
+}
diff --git a/tests/test_cases/deps/transitive-components/baz.hpp b/tests/test_cases/deps/transitive-components/baz.hpp
new file mode 100644
index 0000000..926dd6d
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/baz.hpp
@@ -0,0 +1,8 @@
+#ifndef BAZ_HPP
+#define BAZ_HPP
+
+#include "bazdep.hpp"
+
+baz_t baz(baz_t);
+
+#endif
diff --git a/tests/test_cases/deps/transitive-components/bazdep.cpp b/tests/test_cases/deps/transitive-components/bazdep.cpp
new file mode 100644
index 0000000..c097661
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/bazdep.cpp
@@ -0,0 +1,9 @@
+#include "bazdep.hpp"
+
+#include <iostream>
+#include <ostream>
+
+baz_t bazdep(baz_t x) {
+ std::cout << "bazdep(" << x << ")" << std::endl;
+ return x + 11;
+}
diff --git a/tests/test_cases/deps/transitive-components/bazdep.hpp b/tests/test_cases/deps/transitive-components/bazdep.hpp
new file mode 100644
index 0000000..d2add97
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/bazdep.hpp
@@ -0,0 +1,8 @@
+#ifndef BAZDEP_HPP
+#define BAZDEP_HPP
+
+typedef int baz_t;
+
+baz_t bazdep(baz_t);
+
+#endif
diff --git a/tests/test_cases/deps/transitive-components/foo.cpp b/tests/test_cases/deps/transitive-components/foo.cpp
new file mode 100644
index 0000000..197e1fb
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/foo.cpp
@@ -0,0 +1,10 @@
+#include "foo.hpp"
+
+#include "foodep.hpp"
+#include <iostream>
+#include <ostream>
+
+int foo(int x) {
+ std::cout << "foo(" << x << ")" << std::endl;
+ return foodep(x) * 3;
+}
diff --git a/tests/test_cases/deps/transitive-components/foo.hpp b/tests/test_cases/deps/transitive-components/foo.hpp
new file mode 100644
index 0000000..45c286c
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/foo.hpp
@@ -0,0 +1,8 @@
+#ifndef FOO_HPP
+#define FOO_HPP
+
+#include "foodep.hpp"
+
+foo_t foo(foo_t);
+
+#endif
diff --git a/tests/test_cases/deps/transitive-components/foodep.cpp b/tests/test_cases/deps/transitive-components/foodep.cpp
new file mode 100644
index 0000000..e26c335
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/foodep.cpp
@@ -0,0 +1,9 @@
+#include "foodep.hpp"
+
+#include <iostream>
+#include <ostream>
+
+foo_t foodep(foo_t x) {
+ std::cout << "foodep(" << x << ")" << std::endl;
+ return x + 2;
+}
diff --git a/tests/test_cases/deps/transitive-components/foodep.hpp b/tests/test_cases/deps/transitive-components/foodep.hpp
new file mode 100644
index 0000000..ea16bb0
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/foodep.hpp
@@ -0,0 +1,8 @@
+#ifndef FOODEP_HPP
+#define FOODEP_HPP
+
+typedef int foo_t;
+
+foo_t foodep(foo_t);
+
+#endif
diff --git a/tests/test_cases/deps/transitive-components/main.cpp b/tests/test_cases/deps/transitive-components/main.cpp
new file mode 100644
index 0000000..3e2ae1c
--- /dev/null
+++ b/tests/test_cases/deps/transitive-components/main.cpp
@@ -0,0 +1,11 @@
+#include "foo.hpp"
+#include "bar.hpp"
+#include "baz.hpp"
+
+#include <iostream>
+#include <ostream>
+
+int main(int argc, char **argv) {
+ std::cout << "Hello-from-main" << std::endl;
+ std::cout << foo(bar(baz(13))) << std::endl;
+}