diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-03-30 15:22:09 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-03-30 19:52:17 -0300 |
| commit | 2dc0a68c941d883753b2d6715921a8952f95204b (patch) | |
| tree | 57c45b68dfd9041ad6484aac1f3be0b11ac706ce /spec/util/test_env.lua | |
| parent | 43adf5df7465c39a9f6fc735654aabac991cabb5 (diff) | |
| download | luarocks-2dc0a68c941d883753b2d6715921a8952f95204b.tar.gz luarocks-2dc0a68c941d883753b2d6715921a8952f95204b.tar.bz2 luarocks-2dc0a68c941d883753b2d6715921a8952f95204b.zip | |
Tests: run our own local git-daemon repository for git tests
Diffstat (limited to 'spec/util/test_env.lua')
| -rw-r--r-- | spec/util/test_env.lua | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua index 2232de87..e318128e 100644 --- a/spec/util/test_env.lua +++ b/spec/util/test_env.lua | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | local lfs = require("lfs") | ||
| 2 | local test_env = {} | 1 | local test_env = {} |
| 3 | 2 | ||
| 3 | local lfs = require("lfs") | ||
| 4 | |||
| 4 | local help_message = [[ | 5 | local help_message = [[ |
| 5 | LuaRocks test-suite | 6 | LuaRocks test-suite |
| 6 | 7 | ||
| @@ -135,6 +136,11 @@ function test_env.execute_helper(command, print_command, env_variables) | |||
| 135 | return final_command | 136 | return final_command |
| 136 | end | 137 | end |
| 137 | 138 | ||
| 139 | function test_env.execute(cmd) | ||
| 140 | local ok = os.execute(cmd) | ||
| 141 | return (ok == true or ok == 0) -- normalize Lua 5.1 output to boolean | ||
| 142 | end | ||
| 143 | |||
| 138 | --- Execute command and returns true/false | 144 | --- Execute command and returns true/false |
| 139 | -- @return true/false boolean: status of the command execution | 145 | -- @return true/false boolean: status of the command execution |
| 140 | local function execute_bool(command, print_command, env_variables) | 146 | local function execute_bool(command, print_command, env_variables) |
| @@ -147,8 +153,7 @@ local function execute_bool(command, print_command, env_variables) | |||
| 147 | redirect = " > "..redirect_filename | 153 | redirect = " > "..redirect_filename |
| 148 | os.remove(redirect_filename) | 154 | os.remove(redirect_filename) |
| 149 | end | 155 | end |
| 150 | local ok = os.execute(command .. redirect) | 156 | local ok = test_env.execute(command .. redirect) |
| 151 | ok = (ok == true or ok == 0) -- normalize Lua 5.1 output to boolean | ||
| 152 | if redirect ~= "" then | 157 | if redirect ~= "" then |
| 153 | if not ok then | 158 | if not ok then |
| 154 | local fd = io.open(redirect_filename, "r") | 159 | local fd = io.open(redirect_filename, "r") |
| @@ -530,9 +535,13 @@ function test_env.unload_luarocks() | |||
| 530 | package.loaded[modname] = nil | 535 | package.loaded[modname] = nil |
| 531 | end | 536 | end |
| 532 | end | 537 | end |
| 538 | local src_pattern = test_env.testing_paths.src_dir .. "/?.lua" | ||
| 539 | if not package.path:find(src_pattern, 1, true) then | ||
| 540 | package.path = src_pattern .. ";" .. package.path | ||
| 541 | end | ||
| 533 | end | 542 | end |
| 534 | 543 | ||
| 535 | --- Function for initially setup of environment, variables, md5sums for spec files | 544 | --- Function for initial setup of environment, variables, md5sums for spec files |
| 536 | function test_env.setup_specs(extra_rocks) | 545 | function test_env.setup_specs(extra_rocks) |
| 537 | -- if global variable about successful creation of testing environment doesn't exist, build environment | 546 | -- if global variable about successful creation of testing environment doesn't exist, build environment |
| 538 | if not test_env.setup_done then | 547 | if not test_env.setup_done then |
| @@ -546,6 +555,10 @@ function test_env.setup_specs(extra_rocks) | |||
| 546 | end | 555 | end |
| 547 | 556 | ||
| 548 | test_env.main() | 557 | test_env.main() |
| 558 | |||
| 559 | -- preload before meddling with package.path | ||
| 560 | require("spec.util.git_repo") | ||
| 561 | |||
| 549 | package.path = test_env.env_variables.LUA_PATH | 562 | package.path = test_env.env_variables.LUA_PATH |
| 550 | 563 | ||
| 551 | test_env.platform = execute_output(test_env.testing_paths.lua .. " -e \"print(require('luarocks.core.cfg').arch)\"", false, test_env.env_variables) | 564 | test_env.platform = execute_output(test_env.testing_paths.lua .. " -e \"print(require('luarocks.core.cfg').arch)\"", false, test_env.env_variables) |
| @@ -744,9 +757,8 @@ function test_env.mock_server_extra_rocks(more) | |||
| 744 | end | 757 | end |
| 745 | 758 | ||
| 746 | function test_env.mock_server_init() | 759 | function test_env.mock_server_init() |
| 747 | local assert = require("luassert") | ||
| 748 | local testing_paths = test_env.testing_paths | 760 | local testing_paths = test_env.testing_paths |
| 749 | assert.is_true(test_env.need_rock("restserver-xavante")) | 761 | assert(test_env.need_rock("restserver-xavante")) |
| 750 | local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.util_dir .. "/mock-server.lua &", true, test_env.env_variables) | 762 | local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.util_dir .. "/mock-server.lua &", true, test_env.env_variables) |
| 751 | os.execute(final_command) | 763 | os.execute(final_command) |
| 752 | end | 764 | end |
