diff options
| author | Arthur LAURENT <[email protected]> | 2024-02-02 18:27:52 +0100 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2024-02-02 18:27:52 +0100 |
| commit | 22d46b0b3586b535f183a256fee5b198ebb96237 (patch) | |
| tree | b26f79446b9b43cd3bd5e8c3db58c3da2e3af334 /tests/projects/c++/modules | |
| parent | b64836f09b250e1d77773cb9e0c53c33ecaaa9de (diff) | |
add a test for circular dependency detection
Diffstat (limited to 'tests/projects/c++/modules')
7 files changed, 81 insertions, 0 deletions
diff --git a/tests/projects/c++/modules/circular_dependency/src/hello.mpp b/tests/projects/c++/modules/circular_dependency/src/hello.mpp new file mode 100644 index 000000000..50f0f2c8f --- /dev/null +++ b/tests/projects/c++/modules/circular_dependency/src/hello.mpp @@ -0,0 +1,13 @@ +export module hello; + +import hello3; + +export namespace hello { + class say { + public: + say(int data); + void hello(); + private: + int data_; + }; +} diff --git a/tests/projects/c++/modules/circular_dependency/src/hello2.mpp b/tests/projects/c++/modules/circular_dependency/src/hello2.mpp new file mode 100644 index 000000000..1b6258af1 --- /dev/null +++ b/tests/projects/c++/modules/circular_dependency/src/hello2.mpp @@ -0,0 +1,3 @@ +export module hello2; + +import hello; diff --git a/tests/projects/c++/modules/circular_dependency/src/hello3.mpp b/tests/projects/c++/modules/circular_dependency/src/hello3.mpp new file mode 100644 index 000000000..4966cf0c0 --- /dev/null +++ b/tests/projects/c++/modules/circular_dependency/src/hello3.mpp @@ -0,0 +1,3 @@ +export module hello3; + +import hello2; diff --git a/tests/projects/c++/modules/circular_dependency/src/main.cpp b/tests/projects/c++/modules/circular_dependency/src/main.cpp new file mode 100644 index 000000000..6f80b6c7d --- /dev/null +++ b/tests/projects/c++/modules/circular_dependency/src/main.cpp @@ -0,0 +1,7 @@ +import hello; + +int main() { + hello::say s(sizeof(hello::say)); + s.hello(); + return 0; +}
\ No newline at end of file diff --git a/tests/projects/c++/modules/circular_dependency/test.lua b/tests/projects/c++/modules/circular_dependency/test.lua new file mode 100644 index 000000000..c741a2b7c --- /dev/null +++ b/tests/projects/c++/modules/circular_dependency/test.lua @@ -0,0 +1 @@ +inherit(".test_base_failed") diff --git a/tests/projects/c++/modules/circular_dependency/xmake.lua b/tests/projects/c++/modules/circular_dependency/xmake.lua new file mode 100644 index 000000000..73254924e --- /dev/null +++ b/tests/projects/c++/modules/circular_dependency/xmake.lua @@ -0,0 +1,8 @@ +add_rules("mode.release", "mode.debug") +set_languages("c++20") + +target("circular_dependency") + set_kind("binary") + add_files("src/*.cpp", "src/*.mpp") + + diff --git a/tests/projects/c++/modules/test_base_failed.lua b/tests/projects/c++/modules/test_base_failed.lua new file mode 100644 index 000000000..8f33d1fbf --- /dev/null +++ b/tests/projects/c++/modules/test_base_failed.lua @@ -0,0 +1,46 @@ +import("lib.detect.find_tool") +import("core.base.semver") + +function _build() + local ci = (os.getenv("CI") or os.getenv("GITHUB_ACTIONS") or ""):lower() + if ci == "true" then + assert(os.execv("xmake", {"-rvD"}, {try = true})) + else + assert(os.execv("xmake", {"-r"}, {try = true})) + end +end + +function main(t) + if is_subhost("windows") then + local clang = find_tool("clang", {version = true}) + if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then + os.exec("xmake f --toolchain=clang -c --yes") + _build() + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") + _build() + end + + os.exec("xmake clean -a") + os.exec("xmake f -c --yes") + _build() + elseif is_subhost("msys") then + os.exec("xmake f -c -p mingw --yes") + _build() + elseif is_host("linux") then + local gcc = find_tool("gcc", {version = true}) + if gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then + os.exec("xmake f -c --yes") + _build() + end + local clang = find_tool("clang", {version = true}) + if clang and clang.version and semver.compare(clang.version, "14.0") >= 0 then + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang -c --yes") + _build() + os.exec("xmake clean -a") + os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") + _build() + end + end +end |
