diff options
author | roboo <robo.karasek@gmail.com> | 2016-07-14 00:29:01 +0200 |
---|---|---|
committer | roboo <robo.karasek@gmail.com> | 2016-07-14 00:29:01 +0200 |
commit | 1656a4c7a2dac25d2dd2e5d2211ce0e7eb000b19 (patch) | |
tree | 6aa4d66409112e10ac40968ec439d3ceddc6e5a6 /test | |
parent | fe79525c26449576322ca5aa736d72d100313be4 (diff) | |
download | luarocks-1656a4c7a2dac25d2dd2e5d2211ce0e7eb000b19.tar.gz luarocks-1656a4c7a2dac25d2dd2e5d2211ce0e7eb000b19.tar.bz2 luarocks-1656a4c7a2dac25d2dd2e5d2211ce0e7eb000b19.zip |
need_rock() added, new flag noreset environment
Diffstat (limited to 'test')
-rw-r--r-- | test/test_environment.lua | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/test/test_environment.lua b/test/test_environment.lua index 6de7a4e2..eb545a47 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
@@ -14,6 +14,7 @@ USAGE | |||
14 | ARGUMENTS | 14 | ARGUMENTS |
15 | env=<type> Set type of environment to use ("minimal" or "full", | 15 | env=<type> Set type of environment to use ("minimal" or "full", |
16 | default: "minimal"). | 16 | default: "minimal"). |
17 | noreset Don't reset environment after each test | ||
17 | clean Remove existing testing environment. | 18 | clean Remove existing testing environment. |
18 | travis Add if running on TravisCI. | 19 | travis Add if running on TravisCI. |
19 | os=<type> Set OS ("linux", "osx", or "windows"). | 20 | os=<type> Set OS ("linux", "osx", or "windows"). |
@@ -96,10 +97,13 @@ end | |||
96 | function test_env.set_args() | 97 | function test_env.set_args() |
97 | -- if at least Lua/LuaJIT version argument was found on input start to parse other arguments to env. variables | 98 | -- if at least Lua/LuaJIT version argument was found on input start to parse other arguments to env. variables |
98 | test_env.TYPE_TEST_ENV = "minimal" | 99 | test_env.TYPE_TEST_ENV = "minimal" |
100 | test_env.RESET_ENV = true | ||
99 | 101 | ||
100 | for _, argument in ipairs(arg) do | 102 | for _, argument in ipairs(arg) do |
101 | if argument:find("^env=") then | 103 | if argument:find("^env=") then |
102 | test_env.TYPE_TEST_ENV = argument:match("^env=(.*)$") | 104 | test_env.TYPE_TEST_ENV = argument:match("^env=(.*)$") |
105 | elseif argument == "noreset" then | ||
106 | test_env.RESET_ENV = false | ||
103 | elseif argument == "clean" then | 107 | elseif argument == "clean" then |
104 | test_env.TEST_ENV_CLEAN = true | 108 | test_env.TEST_ENV_CLEAN = true |
105 | elseif argument == "travis" then | 109 | elseif argument == "travis" then |
@@ -333,6 +337,7 @@ local function reset_environment(testing_paths, md5sums) | |||
333 | test_env.remove_dir(testing_paths.testing_tree) | 337 | test_env.remove_dir(testing_paths.testing_tree) |
334 | execute_bool("cp -a " .. testing_paths.testing_tree_copy .. "/. " .. testing_paths.testing_tree) | 338 | execute_bool("cp -a " .. testing_paths.testing_tree_copy .. "/. " .. testing_paths.testing_tree) |
335 | end | 339 | end |
340 | |||
336 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then | 341 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then |
337 | test_env.remove_dir(testing_paths.testing_sys_tree) | 342 | test_env.remove_dir(testing_paths.testing_sys_tree) |
338 | execute_bool("cp -a " .. testing_paths.testing_sys_tree_copy .. "/. " .. testing_paths.testing_sys_tree) | 343 | execute_bool("cp -a " .. testing_paths.testing_sys_tree_copy .. "/. " .. testing_paths.testing_sys_tree) |
@@ -403,21 +408,17 @@ function test_env.setup_specs(extra_rocks) | |||
403 | end | 408 | end |
404 | end | 409 | end |
405 | 410 | ||
406 | reset_environment(test_env.testing_paths, test_env.md5sums, test_env.env_variables) | 411 | if test_env.RESET_ENV then |
412 | reset_environment(test_env.testing_paths, test_env.md5sums, test_env.env_variables) | ||
413 | end | ||
407 | end | 414 | end |
408 | 415 | ||
409 | --- Helper function for tests which needs luasocket installed | 416 | --- Test if required rock is installed if not, install it |
410 | function test_env.need_luasocket() | 417 | function test_env.need_rock(rock) |
411 | if test_env.run.luarocks_nocov("show luasocket") then | 418 | if test_env.run.luarocks_nocov("show " .. rock) then |
412 | return true | 419 | return true |
413 | else | 420 | else |
414 | local testing_cache = test_env.testing_paths.testing_cache .. "/" | 421 | return test_env.run.luarocks_nocov("install " .. rock) |
415 | local luasocket_rock = "luasocket-3.0rc1-1." .. test_env.platform .. ".rock" | ||
416 | if not exists(testing_cache .. luasocket_rock) then | ||
417 | test_env.run.luarocks_nocov("build --pack-binary-rock luasocket 3.0rc1-1") | ||
418 | os.rename(luasocket_rock, testing_cache .. luasocket_rock) | ||
419 | end | ||
420 | return test_env.run.luarocks_nocov("install " .. testing_cache .. luasocket_rock) | ||
421 | end | 422 | end |
422 | end | 423 | end |
423 | 424 | ||