diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2017-12-19 12:43:30 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2017-12-19 12:43:30 -0200 |
commit | a070e326aa3d412a62b9ebdc9c22afd1da63843f (patch) | |
tree | 2b1397ad81b866bade1e4aa6fb7d4f13e404df03 | |
parent | eb89bafa29cf63600154d162429c803bb782c428 (diff) | |
download | luarocks-a070e326aa3d412a62b9ebdc9c22afd1da63843f.tar.gz luarocks-a070e326aa3d412a62b9ebdc9c22afd1da63843f.tar.bz2 luarocks-a070e326aa3d412a62b9ebdc9c22afd1da63843f.zip |
Tests: expose `exist` function to specs
-rw-r--r-- | test/test_environment.lua | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/test/test_environment.lua b/test/test_environment.lua index a663c1c3..d347fa59 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
@@ -35,7 +35,7 @@ local function title(str) | |||
35 | print(("-"):rep(#str)) | 35 | print(("-"):rep(#str)) |
36 | end | 36 | end |
37 | 37 | ||
38 | local function exists(path) | 38 | function test_env.exists(path) |
39 | return lfs.attributes(path, "mode") ~= nil | 39 | return lfs.attributes(path, "mode") ~= nil |
40 | end | 40 | end |
41 | 41 | ||
@@ -235,7 +235,7 @@ end | |||
235 | --- Remove directory recursively | 235 | --- Remove directory recursively |
236 | -- @param path string: directory path to delete | 236 | -- @param path string: directory path to delete |
237 | function test_env.remove_dir(path) | 237 | function test_env.remove_dir(path) |
238 | if exists(path) then | 238 | if test_env.exists(path) then |
239 | for file in lfs.dir(path) do | 239 | for file in lfs.dir(path) do |
240 | if file ~= "." and file ~= ".." then | 240 | if file ~= "." and file ~= ".." then |
241 | local full_path = path..'/'..file | 241 | local full_path = path..'/'..file |
@@ -255,7 +255,7 @@ end | |||
255 | -- @param path string: path to directory | 255 | -- @param path string: path to directory |
256 | -- @param pattern string: pattern matching basenames of subdirectories to be removed | 256 | -- @param pattern string: pattern matching basenames of subdirectories to be removed |
257 | function test_env.remove_subdirs(path, pattern) | 257 | function test_env.remove_subdirs(path, pattern) |
258 | if exists(path) then | 258 | if test_env.exists(path) then |
259 | for file in lfs.dir(path) do | 259 | for file in lfs.dir(path) do |
260 | if file ~= "." and file ~= ".." then | 260 | if file ~= "." and file ~= ".." then |
261 | local full_path = path..'/'..file | 261 | local full_path = path..'/'..file |
@@ -274,7 +274,7 @@ end | |||
274 | -- @return result_check boolean: true if one or more files deleted | 274 | -- @return result_check boolean: true if one or more files deleted |
275 | function test_env.remove_files(path, pattern) | 275 | function test_env.remove_files(path, pattern) |
276 | local result_check = false | 276 | local result_check = false |
277 | if exists(path) then | 277 | if test_env.exists(path) then |
278 | for file in lfs.dir(path) do | 278 | for file in lfs.dir(path) do |
279 | if file ~= "." and file ~= ".." then | 279 | if file ~= "." and file ~= ".." then |
280 | if file:find(pattern) then | 280 | if file:find(pattern) then |
@@ -299,7 +299,7 @@ local function download_rocks(urls, save_path) | |||
299 | 299 | ||
300 | for _, url in ipairs(urls) do | 300 | for _, url in ipairs(urls) do |
301 | -- check if already downloaded | 301 | -- check if already downloaded |
302 | if not exists(save_path .. url) then | 302 | if not test_env.exists(save_path .. url) then |
303 | if test_env.TEST_TARGET_OS == "windows" then | 303 | if test_env.TEST_TARGET_OS == "windows" then |
304 | execute_bool(test_env.testing_paths.win_tools .. "/wget -cP " .. save_path .. " " .. luarocks_repo .. url .. " --no-check-certificate") | 304 | execute_bool(test_env.testing_paths.win_tools .. "/wget -cP " .. save_path .. " " .. luarocks_repo .. url .. " --no-check-certificate") |
305 | else | 305 | else |
@@ -514,10 +514,10 @@ end | |||
514 | 514 | ||
515 | --- Function for initially setup of environment, variables, md5sums for spec files | 515 | --- Function for initially setup of environment, variables, md5sums for spec files |
516 | function test_env.setup_specs(extra_rocks) | 516 | function test_env.setup_specs(extra_rocks) |
517 | -- if global variable about successful creation of testing environment doesn't exists, build environment | 517 | -- if global variable about successful creation of testing environment doesn't exist, build environment |
518 | if not test_env.setup_done then | 518 | if not test_env.setup_done then |
519 | if test_env.TRAVIS then | 519 | if test_env.TRAVIS then |
520 | if not exists(os.getenv("HOME") .. "/.ssh/id_rsa.pub") then | 520 | if not test_env.exists(os.getenv("HOME") .. "/.ssh/id_rsa.pub") then |
521 | execute_bool("ssh-keygen -t rsa -P \"\" -f ~/.ssh/id_rsa") | 521 | execute_bool("ssh-keygen -t rsa -P \"\" -f ~/.ssh/id_rsa") |
522 | execute_bool("cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys") | 522 | execute_bool("cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys") |
523 | execute_bool("chmod og-wx ~/.ssh/authorized_keys") | 523 | execute_bool("chmod og-wx ~/.ssh/authorized_keys") |