summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-06-18 19:50:39 +0800
committerOpportunityLiu <[email protected]>2019-06-18 19:50:39 +0800
commit98d4504577b586ef2398346a0db2743081cf03a8 (patch)
tree3aab00679f61eee14a62afb3989ed3d278bdb5a3
parent0c58eac269fda12b1568bc9704237a48aedbc4b3 (diff)
skip some tests
-rw-r--r--tests/modules/path/test.lua4
-rw-r--r--tests/projects/dlang/console/test.lua2
-rw-r--r--tests/projects/dlang/shared_library/test.lua2
-rw-r--r--tests/projects/dlang/static_library/test.lua2
-rw-r--r--tests/projects/go/console/test.lua2
-rw-r--r--tests/projects/go/static_library/test.lua2
-rw-r--r--tests/projects/objc++/console/test.lua2
-rw-r--r--tests/projects/objc/console/test.lua2
-rw-r--r--tests/projects/rust/console/test.lua2
-rw-r--r--tests/projects/rust/static_library/test.lua2
-rw-r--r--tests/projects/swift/console/test.lua2
-rw-r--r--tests/runner.lua20
-rw-r--r--tests/test_utils/context.lua13
-rw-r--r--tests/test_utils/test_assert.lua9
-rw-r--r--tests/test_utils/test_build.lua (renamed from tests/test_utils/build.lua)9
-rw-r--r--tests/test_utils/test_skip.lua13
16 files changed, 66 insertions, 22 deletions
diff --git a/tests/modules/path/test.lua b/tests/modules/path/test.lua
index bba15810c..4217dec16 100644
--- a/tests/modules/path/test.lua
+++ b/tests/modules/path/test.lua
@@ -1,6 +1,6 @@
function test_splitenv_win(t)
if not is_host("windows") then
- return
+ return t:skip("wrong host platform")
end
t:are_equal(path.splitenv(""), {})
t:are_equal(path.splitenv("a"), {'a'})
@@ -14,7 +14,7 @@ end
function test_splitenv_unix(t)
if is_host("windows") then
- return
+ return t:skip("wrong host platform")
end
t:are_equal(path.splitenv(""), {})
t:are_equal(path.splitenv("a"), {'a'})
diff --git a/tests/projects/dlang/console/test.lua b/tests/projects/dlang/console/test.lua
index b423189da..c1bac30ee 100644
--- a/tests/projects/dlang/console/test.lua
+++ b/tests/projects/dlang/console/test.lua
@@ -4,5 +4,7 @@ function main(t)
-- build project
if os.host() == "macosx" then
t:build()
+ else
+ return t:skip("wrong host platform")
end
end
diff --git a/tests/projects/dlang/shared_library/test.lua b/tests/projects/dlang/shared_library/test.lua
index b423189da..c1bac30ee 100644
--- a/tests/projects/dlang/shared_library/test.lua
+++ b/tests/projects/dlang/shared_library/test.lua
@@ -4,5 +4,7 @@ function main(t)
-- build project
if os.host() == "macosx" then
t:build()
+ else
+ return t:skip("wrong host platform")
end
end
diff --git a/tests/projects/dlang/static_library/test.lua b/tests/projects/dlang/static_library/test.lua
index b423189da..c1bac30ee 100644
--- a/tests/projects/dlang/static_library/test.lua
+++ b/tests/projects/dlang/static_library/test.lua
@@ -4,5 +4,7 @@ function main(t)
-- build project
if os.host() == "macosx" then
t:build()
+ else
+ return t:skip("wrong host platform")
end
end
diff --git a/tests/projects/go/console/test.lua b/tests/projects/go/console/test.lua
index b423189da..c1bac30ee 100644
--- a/tests/projects/go/console/test.lua
+++ b/tests/projects/go/console/test.lua
@@ -4,5 +4,7 @@ function main(t)
-- build project
if os.host() == "macosx" then
t:build()
+ else
+ return t:skip("wrong host platform")
end
end
diff --git a/tests/projects/go/static_library/test.lua b/tests/projects/go/static_library/test.lua
index b423189da..c1bac30ee 100644
--- a/tests/projects/go/static_library/test.lua
+++ b/tests/projects/go/static_library/test.lua
@@ -4,5 +4,7 @@ function main(t)
-- build project
if os.host() == "macosx" then
t:build()
+ else
+ return t:skip("wrong host platform")
end
end
diff --git a/tests/projects/objc++/console/test.lua b/tests/projects/objc++/console/test.lua
index f73079781..60277b691 100644
--- a/tests/projects/objc++/console/test.lua
+++ b/tests/projects/objc++/console/test.lua
@@ -4,5 +4,7 @@ function main(t)
-- build project
if os.host() == "macosx" then
t:build({iphoneos = true})
+ else
+ return t:skip("wrong host platform")
end
end
diff --git a/tests/projects/objc/console/test.lua b/tests/projects/objc/console/test.lua
index f73079781..60277b691 100644
--- a/tests/projects/objc/console/test.lua
+++ b/tests/projects/objc/console/test.lua
@@ -4,5 +4,7 @@ function main(t)
-- build project
if os.host() == "macosx" then
t:build({iphoneos = true})
+ else
+ return t:skip("wrong host platform")
end
end
diff --git a/tests/projects/rust/console/test.lua b/tests/projects/rust/console/test.lua
index b423189da..c1bac30ee 100644
--- a/tests/projects/rust/console/test.lua
+++ b/tests/projects/rust/console/test.lua
@@ -4,5 +4,7 @@ function main(t)
-- build project
if os.host() == "macosx" then
t:build()
+ else
+ return t:skip("wrong host platform")
end
end
diff --git a/tests/projects/rust/static_library/test.lua b/tests/projects/rust/static_library/test.lua
index b423189da..c1bac30ee 100644
--- a/tests/projects/rust/static_library/test.lua
+++ b/tests/projects/rust/static_library/test.lua
@@ -4,5 +4,7 @@ function main(t)
-- build project
if os.host() == "macosx" then
t:build()
+ else
+ return t:skip("wrong host platform")
end
end
diff --git a/tests/projects/swift/console/test.lua b/tests/projects/swift/console/test.lua
index f73079781..60277b691 100644
--- a/tests/projects/swift/console/test.lua
+++ b/tests/projects/swift/console/test.lua
@@ -4,5 +4,7 @@ function main(t)
-- build project
if os.host() == "macosx" then
t:build({iphoneos = true})
+ else
+ return t:skip("wrong host platform")
end
end
diff --git a/tests/runner.lua b/tests/runner.lua
index b4325edc2..227e66a7f 100644
--- a/tests/runner.lua
+++ b/tests/runner.lua
@@ -1,7 +1,5 @@
import("core.base.option")
-import("test_utils.test_assert")
-import("test_utils.print_error")
-import("test_utils.build", { alias = "test_build" })
+import("test_utils.context", { alias = "test_context" })
function main(script)
@@ -16,14 +14,7 @@ function main(script)
os.setenv("XMAKE_STATS", "false")
-- init test context
- local context =
- {
- filename = script
- }
- context = test_assert(context)
- function context:build(argv)
- test_build(argv)
- end
+ local context = test_context(script)
local root = path.directory(script)
@@ -50,10 +41,10 @@ function main(script)
if verbose then print(">> running %s ...", k) end
context.func = v
context.funcname = k
- try
+ local result = try
{
function ()
- v(context)
+ return v(context)
end,
catch
{
@@ -66,6 +57,9 @@ function main(script)
end
}
}
+ if context:is_skipped(result) then
+ print(">> skipped %s : %s", k, result.reason)
+ end
succeed_count = succeed_count + 1
end
end
diff --git a/tests/test_utils/context.lua b/tests/test_utils/context.lua
new file mode 100644
index 000000000..50271ac76
--- /dev/null
+++ b/tests/test_utils/context.lua
@@ -0,0 +1,13 @@
+import("test_build")
+import("test_skip")
+import("test_assert")
+
+function main(filename)
+
+ local context = { filename = filename }
+ table.join2(context, test_build())
+ table.join2(context, test_skip())
+ table.join2(context, test_assert())
+
+ return context
+end \ No newline at end of file
diff --git a/tests/test_utils/test_assert.lua b/tests/test_utils/test_assert.lua
index 4a97cb3ac..a964fcfb3 100644
--- a/tests/test_utils/test_assert.lua
+++ b/tests/test_utils/test_assert.lua
@@ -1,8 +1,8 @@
-import("print_error")
+
import("check")
-local test_assert = { print_error = print_error.main }
+local test_assert = { print_error = import("print_error", { anonymous = true }).main }
function test_assert:require(value)
if not value then
@@ -66,7 +66,6 @@ function test_assert:will_raise(func, message_pattern)
table.remove(self._will_raise_stack, 1)
end
-function main(context)
- table.join2(context, test_assert)
- return context
+function main()
+ return test_assert
end
diff --git a/tests/test_utils/build.lua b/tests/test_utils/test_build.lua
index 7725f1ddc..4625a5943 100644
--- a/tests/test_utils/build.lua
+++ b/tests/test_utils/test_build.lua
@@ -1,8 +1,9 @@
-- imports
import("privilege.sudo")
--- main entry
-function main(argv)
+local test_build = {}
+
+function test_build:build(argv)
-- check global config
os.exec("xmake g -c")
@@ -35,3 +36,7 @@ function main(argv)
end
end
end
+
+function main()
+ return test_build
+end
diff --git a/tests/test_utils/test_skip.lua b/tests/test_utils/test_skip.lua
new file mode 100644
index 000000000..c17f2c42c
--- /dev/null
+++ b/tests/test_utils/test_skip.lua
@@ -0,0 +1,13 @@
+local test_skip = { _is_skipped_tag = {true} }
+
+function test_skip:skip(reason)
+ return { is_skipped = self._is_skipped_tag, reason = reason, context = self }
+end
+
+function test_skip:is_skipped(result)
+ return result and result.context and result.context._is_skipped_tag == result.is_skipped
+end
+
+function main()
+ return test_skip
+end \ No newline at end of file