diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-05-27 14:15:43 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-06-04 13:24:51 +0200 |
commit | 4602b1967533b61a1fc2ea1bef5c16dcc30e84ba (patch) | |
tree | 8ea596fb3447b23f08aba8f17d460f0382fcacdd | |
parent | 5e20b5cf029695be07d791a76a1e21a316ca5a0f (diff) | |
download | rules-cc-4602b1967533b61a1fc2ea1bef5c16dcc30e84ba.tar.gz |
rules-cc: Add regression tests for install-with-deps rule...
...in both release and debug modes.
Co-authored-by: Oliver Reiche <oliver.reiche@huawei.com>
-rw-r--r-- | tests/test_cases/deps/TARGETS | 78 | ||||
-rw-r--r-- | tests/test_cases/deps/install/TARGETS | 69 | ||||
-rw-r--r-- | tests/test_cases/deps/install/bar.cpp | 7 | ||||
-rw-r--r-- | tests/test_cases/deps/install/bar.hpp | 8 | ||||
-rw-r--r-- | tests/test_cases/deps/install/baz.cpp | 7 | ||||
-rw-r--r-- | tests/test_cases/deps/install/baz.hpp | 10 | ||||
-rw-r--r-- | tests/test_cases/deps/install/foo.cpp | 10 | ||||
-rw-r--r-- | tests/test_cases/deps/install/foo.hpp | 8 | ||||
-rw-r--r-- | tests/test_cases/deps/install/main.cpp | 10 | ||||
-rw-r--r-- | tests/test_cases/deps/install/qux.hpp | 8 |
10 files changed, 214 insertions, 1 deletions
diff --git a/tests/test_cases/deps/TARGETS b/tests/test_cases/deps/TARGETS index 2ed2cf4..b1047a8 100644 --- a/tests/test_cases/deps/TARGETS +++ b/tests/test_cases/deps/TARGETS @@ -203,9 +203,85 @@ ] , "data": [["TREE", null, "cmake"]] } +, "install": + { "type": ["test_rules", "test_case"] + , "name": ["deps_install"] + , "targets": + [ "+install_bar_release" + , "+install_main_release" + , "+install_bar_debug" + , "+install_main_debug" + , "+install_bar_debug_slim" + , "+install_main_debug_slim" + ] + , "asserts": + [ "test -f install_bar_release/lib/bar/libbar.a" + , "test -f install_bar_release/lib/foo/libfoo.a" + , "test -f install_bar_release/lib/baz/libbaz.a" + , "test -f install_bar_release/lib/pkgconfig/bar.pc" + , "test -f install_bar_release/include/bar/bar.hpp" + , "test -f install_bar_release/include/foo/foo.hpp" + , "! test -f install_bar_release/include/baz/baz.hpp" + , "! test -d install_bar_release/work" + , "test -f install_main_release/bin/main" + , "! test -f install_main_release/lib/bar/libbar.a" + , "! test -f install_main_release/lib/foo/libfoo.a" + , "! test -f install_main_release/lib/baz/libbaz.a" + , "! test -d install_main_release/lib/pkgconfig" + , "! test -d install_main_release/include" + , "! test -d install_main_release/work" + , "test -f install_bar_debug/lib/bar/libbar.a" + , "test -f install_bar_debug/lib/foo/libfoo.a" + , "test -f install_bar_debug/lib/baz/libbaz.a" + , "test -f install_bar_debug/lib/pkgconfig/bar.pc" + , "test -f install_bar_debug/include/bar/bar.hpp" + , "test -f install_bar_debug/include/foo/foo.hpp" + , "test -f install_bar_debug/include/baz/baz.hpp" + , "test -f install_bar_debug/work/bar/bar.cpp" + , "test -f install_bar_debug/work/bar/bar.hpp" + , "test -f install_bar_debug/work/foo/foo.cpp" + , "test -f install_bar_debug/work/foo/foo.hpp" + , "test -f install_bar_debug/work/foo/qux.hpp" + , "test -f install_bar_debug/work/baz/baz.cpp" + , "test -f install_bar_debug/work/baz/baz.hpp" + , "test -f install_main_debug/bin/main" + , "test -f install_main_debug/include/bar/bar.hpp" + , "test -f install_main_debug/include/foo/foo.hpp" + , "test -f install_main_debug/include/baz/baz.hpp" + , "test -f install_main_debug/work/bar/bar.cpp" + , "test -f install_main_debug/work/bar/bar.hpp" + , "test -f install_main_debug/work/foo/foo.cpp" + , "test -f install_main_debug/work/foo/foo.hpp" + , "test -f install_main_debug/work/foo/qux.hpp" + , "test -f install_main_debug/work/baz/baz.cpp" + , "test -f install_main_debug/work/baz/baz.hpp" + , "test -f install_main_debug/work/main.cpp" + , "! test -f install_main_debug/lib/bar/libbar.a" + , "! test -f install_main_debug/lib/foo/libfoo.a" + , "! test -f install_main_debug/lib/baz/libbaz.a" + , "! test -d install_main_debug/lib/pkgconfig" + , "test -f install_bar_debug_slim/lib/bar/libbar.a" + , "test -f install_bar_debug_slim/lib/foo/libfoo.a" + , "test -f install_bar_debug_slim/lib/baz/libbaz.a" + , "test -f install_bar_debug_slim/lib/pkgconfig/bar.pc" + , "test -f install_bar_debug_slim/include/bar/bar.hpp" + , "test -f install_bar_debug_slim/include/foo/foo.hpp" + , "! test -f install_bar_debug_slim/include/baz/baz.hpp" + , "! test -d install_bar_debug_slim/work" + , "test -f install_main_debug_slim/bin/main" + , "! test -f install_main_debug_slim/lib/bar/libbar.a" + , "! test -f install_main_debug_slim/lib/foo/libfoo.a" + , "! test -f install_main_debug_slim/lib/baz/libbaz.a" + , "! test -d install_main_debug_slim/lib/pkgconfig" + , "! test -d install_main_debug_slim/include" + , "! test -d install_main_debug_slim/work" + ] + , "data": [["TREE", null, "install"]] + } , "ALL": { "type": "install" - , "deps": ["private", "public", "shared", "object", "prebuilt", "cmake"] + , "deps": + ["private", "public", "shared", "object", "prebuilt", "cmake", "install"] , "tainted": ["test"] } } diff --git a/tests/test_cases/deps/install/TARGETS b/tests/test_cases/deps/install/TARGETS new file mode 100644 index 0000000..c2cab52 --- /dev/null +++ b/tests/test_cases/deps/install/TARGETS @@ -0,0 +1,69 @@ +{ "baz": + { "type": ["@", "rules", "CC", "library"] + , "name": ["baz"] + , "hdrs": ["baz.hpp"] + , "srcs": ["baz.cpp"] + , "stage": ["baz"] + } +, "foo": + { "type": ["@", "rules", "CC", "library"] + , "name": ["foo"] + , "hdrs": ["foo.hpp"] + , "private-hdrs": ["qux.hpp"] + , "srcs": ["foo.cpp"] + , "private-deps": ["baz"] + , "stage": ["foo"] + } +, "bar": + { "type": ["@", "rules", "CC", "library"] + , "name": ["bar"] + , "hdrs": ["bar.hpp"] + , "srcs": ["bar.cpp"] + , "deps": ["foo"] + , "stage": ["bar"] + } +, "main": + { "type": ["@", "rules", "CC", "binary"] + , "name": ["main"] + , "srcs": ["main.cpp"] + , "private-deps": ["bar"] + } +, "install_bar_release": + {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["bar"]} +, "install_main_release": + {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["main"]} +, "bar debug": + { "type": "configure" + , "target": "bar" + , "config": + { "type": "let*" + , "bindings": [["DEBUG", true], ["ADD_CXXFLAGS", ["-g"]]] + , "body": {"type": "env", "vars": ["DEBUG", "ADD_CXXFLAGS"]} + } + } +, "main debug": + { "type": "configure" + , "target": "main" + , "config": + { "type": "let*" + , "bindings": [["DEBUG", true], ["ADD_CXXFLAGS", ["-g"]]] + , "body": {"type": "env", "vars": ["DEBUG", "ADD_CXXFLAGS"]} + } + } +, "install_bar_debug": + {"type": ["@", "rules", "CC", "install-with-deps"], "targets": ["bar debug"]} +, "install_main_debug": + { "type": ["@", "rules", "CC", "install-with-deps"] + , "targets": ["main debug"] + } +, "install_bar_debug_slim": + { "type": ["@", "rules", "CC", "install-with-deps"] + , "skip-debug-stage": ["yes"] + , "targets": ["bar debug"] + } +, "install_main_debug_slim": + { "type": ["@", "rules", "CC", "install-with-deps"] + , "skip-debug-stage": ["yes"] + , "targets": ["main debug"] + } +} diff --git a/tests/test_cases/deps/install/bar.cpp b/tests/test_cases/deps/install/bar.cpp new file mode 100644 index 0000000..6cc1260 --- /dev/null +++ b/tests/test_cases/deps/install/bar.cpp @@ -0,0 +1,7 @@ +#include "bar.hpp" +#include <iostream> + +int bar(Foo *foo) { + std::cout << "bar" << std::endl; + return (foo == nullptr) ? -1 : foo->foo(); +} diff --git a/tests/test_cases/deps/install/bar.hpp b/tests/test_cases/deps/install/bar.hpp new file mode 100644 index 0000000..ec9c165 --- /dev/null +++ b/tests/test_cases/deps/install/bar.hpp @@ -0,0 +1,8 @@ +#ifndef BAR_HPP +#define BAR_HPP + +#include "foo/foo.hpp" + +int bar(Foo *foo); + +#endif diff --git a/tests/test_cases/deps/install/baz.cpp b/tests/test_cases/deps/install/baz.cpp new file mode 100644 index 0000000..c2c26f0 --- /dev/null +++ b/tests/test_cases/deps/install/baz.cpp @@ -0,0 +1,7 @@ +#include "baz.hpp" +#include <iostream> + +int baz() { + std::cout << baz_str() << std::endl; + return 0; +} diff --git a/tests/test_cases/deps/install/baz.hpp b/tests/test_cases/deps/install/baz.hpp new file mode 100644 index 0000000..f0f8377 --- /dev/null +++ b/tests/test_cases/deps/install/baz.hpp @@ -0,0 +1,10 @@ +#ifndef BAZ_HPP +#define BAZ_HPP + +int baz(); + +#include <string> + +static inline std::string baz_str() { return "baz"; } + +#endif diff --git a/tests/test_cases/deps/install/foo.cpp b/tests/test_cases/deps/install/foo.cpp new file mode 100644 index 0000000..4a3b17a --- /dev/null +++ b/tests/test_cases/deps/install/foo.cpp @@ -0,0 +1,10 @@ +#include "foo.hpp" +#include "baz/baz.hpp" +#include "qux.hpp" +#include <iostream> + +int Foo::foo() { + std::cout << "foo & inline " << baz_str() << std::endl; + qux(); + return baz(); +} diff --git a/tests/test_cases/deps/install/foo.hpp b/tests/test_cases/deps/install/foo.hpp new file mode 100644 index 0000000..025f3ef --- /dev/null +++ b/tests/test_cases/deps/install/foo.hpp @@ -0,0 +1,8 @@ +#ifndef FOO_HPP +#define FOO_HPP + +struct Foo { + int foo(); +}; + +#endif diff --git a/tests/test_cases/deps/install/main.cpp b/tests/test_cases/deps/install/main.cpp new file mode 100644 index 0000000..2e46d75 --- /dev/null +++ b/tests/test_cases/deps/install/main.cpp @@ -0,0 +1,10 @@ +// test binary consuming libraries + +#include "bar/bar.hpp" +#include <iostream> + +int main() { + std::cout << "main" << std::endl; + Foo foo{}; + return bar(&foo); +} diff --git a/tests/test_cases/deps/install/qux.hpp b/tests/test_cases/deps/install/qux.hpp new file mode 100644 index 0000000..b2f1611 --- /dev/null +++ b/tests/test_cases/deps/install/qux.hpp @@ -0,0 +1,8 @@ +#ifndef QUX_HPP +#define QUX_HPP + +#include <iostream> + +void qux() { std::cout << "qux" << std::endl; } + +#endif
\ No newline at end of file |