summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorruki <[email protected]>2023-10-07 16:57:13 +0800
committerGitHub <[email protected]>2023-10-07 16:57:13 +0800
commit720f0eb9c5ba51a5a76ef31e7285b6ea1b08b400 (patch)
tree4b324d9ecf8c561712cc6531a3d28ded21ac2045 /tests
parentbceea4e7fe7553b90ac7d14e4ea854bbb2d3e04a (diff)
parent2bfdd8a805baa9753ffed3dac771b6f3dce077bf (diff)
Merge pull request #4259 from xmake-io/tests
Add `xmake test` support
Diffstat (limited to 'tests')
-rw-r--r--tests/actions/test/.gitignore8
-rw-r--r--tests/actions/test/src/test_1.cpp10
-rw-r--r--tests/actions/test/src/test_2.cpp10
-rw-r--r--tests/actions/test/src/test_3.cpp10
-rw-r--r--tests/actions/test/src/test_4.cpp10
-rw-r--r--tests/actions/test/src/test_5.cpp10
-rw-r--r--tests/actions/test/src/test_6.cpp10
-rw-r--r--tests/actions/test/src/test_7.cpp10
-rw-r--r--tests/actions/test/src/test_8.cpp9
-rw-r--r--tests/actions/test/src/test_9.cpp10
-rw-r--r--tests/actions/test/test.lua4
-rw-r--r--tests/actions/test/xmake.lua14
12 files changed, 115 insertions, 0 deletions
diff --git a/tests/actions/test/.gitignore b/tests/actions/test/.gitignore
new file mode 100644
index 000000000..152105761
--- /dev/null
+++ b/tests/actions/test/.gitignore
@@ -0,0 +1,8 @@
+# Xmake cache
+.xmake/
+build/
+
+# MacOS Cache
+.DS_Store
+
+
diff --git a/tests/actions/test/src/test_1.cpp b/tests/actions/test/src/test_1.cpp
new file mode 100644
index 000000000..f454e99f3
--- /dev/null
+++ b/tests/actions/test/src/test_1.cpp
@@ -0,0 +1,10 @@
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ char const* arg = argc > 1? argv[1] : "xmake";
+ cout << "hello " << arg << endl;
+ return 0;
+}
diff --git a/tests/actions/test/src/test_2.cpp b/tests/actions/test/src/test_2.cpp
new file mode 100644
index 000000000..f454e99f3
--- /dev/null
+++ b/tests/actions/test/src/test_2.cpp
@@ -0,0 +1,10 @@
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ char const* arg = argc > 1? argv[1] : "xmake";
+ cout << "hello " << arg << endl;
+ return 0;
+}
diff --git a/tests/actions/test/src/test_3.cpp b/tests/actions/test/src/test_3.cpp
new file mode 100644
index 000000000..f454e99f3
--- /dev/null
+++ b/tests/actions/test/src/test_3.cpp
@@ -0,0 +1,10 @@
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ char const* arg = argc > 1? argv[1] : "xmake";
+ cout << "hello " << arg << endl;
+ return 0;
+}
diff --git a/tests/actions/test/src/test_4.cpp b/tests/actions/test/src/test_4.cpp
new file mode 100644
index 000000000..f454e99f3
--- /dev/null
+++ b/tests/actions/test/src/test_4.cpp
@@ -0,0 +1,10 @@
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ char const* arg = argc > 1? argv[1] : "xmake";
+ cout << "hello " << arg << endl;
+ return 0;
+}
diff --git a/tests/actions/test/src/test_5.cpp b/tests/actions/test/src/test_5.cpp
new file mode 100644
index 000000000..dad841287
--- /dev/null
+++ b/tests/actions/test/src/test_5.cpp
@@ -0,0 +1,10 @@
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ char const* arg = argc > 1? argv[1] : "xmake";
+ cout << "hello2 " << arg << endl;
+ return 0;
+}
diff --git a/tests/actions/test/src/test_6.cpp b/tests/actions/test/src/test_6.cpp
new file mode 100644
index 000000000..f454e99f3
--- /dev/null
+++ b/tests/actions/test/src/test_6.cpp
@@ -0,0 +1,10 @@
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ char const* arg = argc > 1? argv[1] : "xmake";
+ cout << "hello " << arg << endl;
+ return 0;
+}
diff --git a/tests/actions/test/src/test_7.cpp b/tests/actions/test/src/test_7.cpp
new file mode 100644
index 000000000..dae685668
--- /dev/null
+++ b/tests/actions/test/src/test_7.cpp
@@ -0,0 +1,10 @@
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ char const* arg = argc > 1? argv[1] : "xmake";
+ cout << "hello " << arg << endl;
+ return -1;
+}
diff --git a/tests/actions/test/src/test_8.cpp b/tests/actions/test/src/test_8.cpp
new file mode 100644
index 000000000..8669ff781
--- /dev/null
+++ b/tests/actions/test/src/test_8.cpp
@@ -0,0 +1,9 @@
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ cout << "hello xmake" << endl;
+ return 0;
+}
diff --git a/tests/actions/test/src/test_9.cpp b/tests/actions/test/src/test_9.cpp
new file mode 100644
index 000000000..f454e99f3
--- /dev/null
+++ b/tests/actions/test/src/test_9.cpp
@@ -0,0 +1,10 @@
+#include <iostream>
+
+using namespace std;
+
+int main(int argc, char** argv)
+{
+ char const* arg = argc > 1? argv[1] : "xmake";
+ cout << "hello " << arg << endl;
+ return 0;
+}
diff --git a/tests/actions/test/test.lua b/tests/actions/test/test.lua
new file mode 100644
index 000000000..45ce0b914
--- /dev/null
+++ b/tests/actions/test/test.lua
@@ -0,0 +1,4 @@
+function main(t)
+ os.exec("xmake test")
+end
+
diff --git a/tests/actions/test/xmake.lua b/tests/actions/test/xmake.lua
new file mode 100644
index 000000000..086734631
--- /dev/null
+++ b/tests/actions/test/xmake.lua
@@ -0,0 +1,14 @@
+add_rules("mode.debug", "mode.release")
+
+for _, file in ipairs(os.files("src/test_*.cpp")) do
+ local name = path.basename(file)
+ target(name)
+ set_kind("binary")
+ set_default(false)
+ add_files("src/" .. name .. ".cpp")
+ add_tests("default")
+ add_tests("args", {runargs = {"foo", "bar"}})
+ add_tests("pass_output", {trim_output = true, runargs = "foo", pass_outputs = "hello foo"})
+ add_tests("fail_output", {fail_outputs = {"hello2 .*", "hello xmake"}})
+end
+