summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-09-20 00:35:57 +0800
committerruki <[email protected]>2017-09-19 21:35:43 +0800
commit8edce1f3f7f2e779eb3bf66702d4b5271e82a63b (patch)
treef2bf8b6ed65c40fa7fe282dd183f050cb2224ed7
parent61e826bbf495f139dbeff0bf912e50996fa8df07 (diff)
add action.test
-rw-r--r--xmake/actions/require/action/install.lua4
-rw-r--r--xmake/actions/require/action/test.lua52
-rw-r--r--xmake/modules/devel/package/manager.lua30
-rw-r--r--xmake/packages/git/xmake.lua7
4 files changed, 88 insertions, 5 deletions
diff --git a/xmake/actions/require/action/install.lua b/xmake/actions/require/action/install.lua
index 5ca529ef8..a412820f8 100644
--- a/xmake/actions/require/action/install.lua
+++ b/xmake/actions/require/action/install.lua
@@ -26,6 +26,7 @@
import("core.base.option")
import("core.project.target")
import("build")
+import("test")
-- install for xmake file
function _install_for_xmakefile(package)
@@ -248,6 +249,9 @@ function main(package)
script(package)
end
end
+
+ -- test it
+ test(package)
end
-- install package
diff --git a/xmake/actions/require/action/test.lua b/xmake/actions/require/action/test.lua
new file mode 100644
index 000000000..cc5337370
--- /dev/null
+++ b/xmake/actions/require/action/test.lua
@@ -0,0 +1,52 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2017, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file test.lua
+--
+
+-- imports
+import("core.base.option")
+
+-- test the given package
+function main(package)
+
+ -- the package scripts
+ local scripts =
+ {
+ package:script("test_before")
+ , package:script("test")
+ , package:script("test_after")
+ }
+
+ -- save the current directory
+ local oldir = os.curdir()
+
+ -- build it
+ for i = 1, 3 do
+ local script = scripts[i]
+ if script ~= nil then
+ script(package)
+ end
+ end
+
+ -- restore the current directory
+ os.cd(oldir)
+end
diff --git a/xmake/modules/devel/package/manager.lua b/xmake/modules/devel/package/manager.lua
new file mode 100644
index 000000000..e05ae0c29
--- /dev/null
+++ b/xmake/modules/devel/package/manager.lua
@@ -0,0 +1,30 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2017, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file manager.lua
+--
+
+-- imports
+import("core.base.option")
+
+-- install package using third-party package manager
+function install(name, opt)
+end
diff --git a/xmake/packages/git/xmake.lua b/xmake/packages/git/xmake.lua
index 529de378e..02612a4f8 100644
--- a/xmake/packages/git/xmake.lua
+++ b/xmake/packages/git/xmake.lua
@@ -3,18 +3,15 @@ package("git")
set_kind("binary")
set_homepage("https://git-scm.com/")
set_description("A free and open source distributed version control system")
--- add_imports("devel.package_manager", "lib.detect.find_tool")
+ add_imports("devel.package.manager", "lib.detect.find_tool")
on_build(function (package)
end)
on_install(function (package)
--- package_manager.install("git")
+ manager.install("git")
end)
on_install("windows", function (package)
end)
- on_test(function (package)
- assert(find_tool("git"))
- end)