summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorshmuz <shmuz>2007-12-27 10:06:36 +0000
committershmuz <shmuz>2007-12-27 10:06:36 +0000
commitf12c619df243809a1bca719811c3c5d418673aa7 (patch)
tree0bfa814f69b9abf20da5ed6075ea60ae36d9238e /test
parentbacf46c90f1b023f96ccd41445e9c62fc43ab219 (diff)
downloadlrexlib-f12c619df243809a1bca719811c3c5d418673aa7.tar.gz
add new command-line switch -d<directory> that will prepend <directory> to package.cpath
Diffstat (limited to 'test')
-rwxr-xr-xtest/runtest.lua28
1 files changed, 26 insertions, 2 deletions
diff --git a/test/runtest.lua b/test/runtest.lua
index 283b4df..a23c47f 100755
--- a/test/runtest.lua
+++ b/test/runtest.lua
@@ -1,5 +1,11 @@
-- See Copyright Notice in the file LICENSE
+do
+ local path = "./?.lua;"
+ if package.path:sub(1, #path) ~= path then
+ package.path = path .. package.path
+ end
+end
local luatest = require "luatest"
-- returns: number of failures
@@ -45,11 +51,16 @@ local avail_tests = {
do
local verbose, tests, nerr = false, {}, 0
+ local dir
-- check arguments
for i = 1, select ("#", ...) do
local arg = select (i, ...)
- if arg == "-v" then
- verbose = true
+ if arg:sub(1,1) == "-" then
+ if arg == "-v" then
+ verbose = true
+ else
+ dir = arg:match("^%-d(.+)")
+ end
else
if avail_tests[arg] then
tests[#tests+1] = avail_tests[arg]
@@ -59,6 +70,19 @@ do
end
end
assert (#tests > 0, "no library specified")
+ -- give priority to libraries located in the specified directory
+ if dir then
+ dir = dir:gsub("[/\\]+$", "")
+ for _, ext in ipairs {"dll", "so", "dylib"} do
+ if package.cpath:match ("%?%." .. ext) then
+ local cpath = dir .. "/?." .. ext .. ";"
+ if package.cpath:sub(1, #cpath) ~= cpath then
+ package.cpath = cpath .. package.cpath
+ end
+ break
+ end
+ end
+ end
-- do tests
for _, test in ipairs (tests) do
for _, setfile in ipairs (test) do