diff options
| author | roboo <robo.karasek@gmail.com> | 2016-07-19 21:37:51 +0200 |
|---|---|---|
| committer | roboo <robo.karasek@gmail.com> | 2016-07-19 21:37:51 +0200 |
| commit | 2af8f114097b2e79d7f92f9b0cea4cacdc2ff853 (patch) | |
| tree | 3edb91cd19aa6d8ba4f1cc29f6b3fa846228b9d7 /test/test_environment.lua | |
| parent | a90a2066b08b4cc047be84c673024f7f5e9fa054 (diff) | |
| download | luarocks-2af8f114097b2e79d7f92f9b0cea4cacdc2ff853.tar.gz luarocks-2af8f114097b2e79d7f92f9b0cea4cacdc2ff853.tar.bz2 luarocks-2af8f114097b2e79d7f92f9b0cea4cacdc2ff853.zip | |
Verbose mode added
Diffstat (limited to 'test/test_environment.lua')
| -rw-r--r-- | test/test_environment.lua | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/test/test_environment.lua b/test/test_environment.lua index dcad92cf..5d1e8198 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
| @@ -36,6 +36,18 @@ local function exists(path) | |||
| 36 | return lfs.attributes(path, "mode") ~= nil | 36 | return lfs.attributes(path, "mode") ~= nil |
| 37 | end | 37 | end |
| 38 | 38 | ||
| 39 | function test_env.quiet(commad) | ||
| 40 | if not test_env.VERBOSE then | ||
| 41 | if test_env.TEST_TARGET_OS == "linux" or test_env.TEST_TARGET_OS == "osx" then | ||
| 42 | return commad .. " 1> /dev/null 2> /dev/null" | ||
| 43 | elseif test_env.TEST_TARGET_OS == "windows" then | ||
| 44 | return commad .. " 2> NUL 1> NUL" | ||
| 45 | end | ||
| 46 | else | ||
| 47 | return command | ||
| 48 | end | ||
| 49 | end | ||
| 50 | |||
| 39 | --- Helper function for execute_bool and execute_output | 51 | --- Helper function for execute_bool and execute_output |
| 40 | -- @param command string: command to execute | 52 | -- @param command string: command to execute |
| 41 | -- @param print_command boolean: print command if 'true' | 53 | -- @param print_command boolean: print command if 'true' |
| @@ -106,6 +118,8 @@ function test_env.set_args() | |||
| 106 | test_env.RESET_ENV = false | 118 | test_env.RESET_ENV = false |
| 107 | elseif argument == "clean" then | 119 | elseif argument == "clean" then |
| 108 | test_env.TEST_ENV_CLEAN = true | 120 | test_env.TEST_ENV_CLEAN = true |
| 121 | elseif argument == "verbose" then | ||
| 122 | test_env.VERBOSE = true | ||
| 109 | elseif argument == "travis" then | 123 | elseif argument == "travis" then |
| 110 | test_env.TRAVIS = true | 124 | test_env.TRAVIS = true |
| 111 | elseif argument:find("^os=") then | 125 | elseif argument:find("^os=") then |
| @@ -415,10 +429,11 @@ end | |||
| 415 | 429 | ||
| 416 | --- Test if required rock is installed if not, install it | 430 | --- Test if required rock is installed if not, install it |
| 417 | function test_env.need_rock(rock) | 431 | function test_env.need_rock(rock) |
| 418 | if test_env.run.luarocks_nocov("show " .. rock) then | 432 | print("Check if " .. rock .. " is installed") |
| 433 | if test_env.run.luarocks_noprint_nocov(test_env.quiet("show " .. rock)) then | ||
| 419 | return true | 434 | return true |
| 420 | else | 435 | else |
| 421 | return test_env.run.luarocks_nocov("install " .. rock) | 436 | return test_env.run.luarocks_noprint_nocov(test_env.quiet("install " .. rock)) |
| 422 | end | 437 | end |
| 423 | end | 438 | end |
| 424 | 439 | ||
| @@ -525,18 +540,20 @@ local function clean() | |||
| 525 | test_env.remove_subdirs(test_env.testing_paths.testing_dir, "testing[_%-]") | 540 | test_env.remove_subdirs(test_env.testing_paths.testing_dir, "testing[_%-]") |
| 526 | test_env.remove_files(test_env.testing_paths.testing_dir, "testing_") | 541 | test_env.remove_files(test_env.testing_paths.testing_dir, "testing_") |
| 527 | test_env.remove_files(test_env.testing_paths.testing_dir, "luacov") | 542 | test_env.remove_files(test_env.testing_paths.testing_dir, "luacov") |
| 543 | test_env.remove_files(test_env.testing_paths.testing_dir, "upload_config") | ||
| 528 | print("Cleaning done!") | 544 | print("Cleaning done!") |
| 529 | end | 545 | end |
| 530 | 546 | ||
| 531 | --- Install luarocks into testing prefix. | 547 | --- Install luarocks into testing prefix. |
| 532 | local function install_luarocks(install_env_vars) | 548 | local function install_luarocks(install_env_vars) |
| 533 | -- Configure LuaRocks testing environment | 549 | -- Configure LuaRocks testing environment |
| 534 | local configure_cmd = "./configure --with-lua=" .. test_env.testing_paths.luadir .. | 550 | title("Installing LuaRocks") |
| 535 | " --prefix=" .. test_env.testing_paths.testing_lrprefix .. | 551 | local configure_cmd = "./configure --with-lua=" .. test_env.testing_paths.luadir .. " --prefix=" .. test_env.testing_paths.testing_lrprefix |
| 536 | " && make clean" | 552 | assert(execute_bool(test_env.quiet(configure_cmd)), false, install_env_vars) |
| 537 | 553 | assert(execute_bool(test_env.quiet("make clean")), false, install_env_vars) | |
| 538 | assert(execute_bool(configure_cmd, false, install_env_vars)) | 554 | assert(execute_bool(test_env.quiet("make src/luarocks/site_config.lua")), false, install_env_vars) |
| 539 | assert(execute_bool("make src/luarocks/site_config.lua && make dev", false, install_env_vars)) | 555 | assert(execute_bool(test_env.quiet("make dev")), false, install_env_vars) |
| 556 | print("LuaRocks installed correctly!") | ||
| 540 | end | 557 | end |
| 541 | 558 | ||
| 542 | --- | 559 | --- |
