summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-10-07 00:41:01 +0800
committerruki <[email protected]>2023-10-07 00:41:01 +0800
commit621d6df885bc9ee832221f968ffcb07399d791fa (patch)
tree71fe231a7651cb04c616a7c2a1e1484c2ddfcfb6
parent0f9a73c46e1ed57158461d56662db686b42514e1 (diff)
add tests for xmake test
-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.cpp10
-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.lua13
-rw-r--r--xmake/actions/test/main.lua8
13 files changed, 115 insertions, 8 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..f454e99f3
--- /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 << "hello " << 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..f454e99f3
--- /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 0;
+}
diff --git a/tests/actions/test/src/test_8.cpp b/tests/actions/test/src/test_8.cpp
new file mode 100644
index 000000000..f454e99f3
--- /dev/null
+++ b/tests/actions/test/src/test_8.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_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..b9465566f
--- /dev/null
+++ b/tests/actions/test/xmake.lua
@@ -0,0 +1,13 @@
+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")
+ add_files("src/" .. name .. ".cpp")
+ add_tests(name)
+ add_tests(name .. "_arg", "foo")
+ add_tests(name .. "_pass_output", "foo", {pass_output = "hello foo"})
+ add_tests(name .. "_fail_output", {fail_output = {"hello .*", "hello xmake"}})
+end
+
diff --git a/xmake/actions/test/main.lua b/xmake/actions/test/main.lua
index 70a277a86..22748b388 100644
--- a/xmake/actions/test/main.lua
+++ b/xmake/actions/test/main.lua
@@ -208,14 +208,6 @@ function main()
-- load config first
config.load()
- -- Automatically build before running
- if project.policy("run.autobuild") then
- -- we need clear the previous config and reload it
- -- to avoid trigger recheck configs
- config.clear()
- task.run("build")
- end
-
-- load targets
project.load_targets()