diff options
| author | robooo <robo.karasek@gmail.com> | 2016-07-07 21:58:19 +0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2016-07-07 16:58:19 -0300 |
| commit | 5af7e0d7c2dcf65e41ae8523f3771e9528be32a7 (patch) | |
| tree | bcd14624e0566a23da2e708675197d212cecf35d | |
| parent | b5b285a678fe78b80d452cc9eb7565b8bf087b81 (diff) | |
| download | luarocks-5af7e0d7c2dcf65e41ae8523f3771e9528be32a7.tar.gz luarocks-5af7e0d7c2dcf65e41ae8523f3771e9528be32a7.tar.bz2 luarocks-5af7e0d7c2dcf65e41ae8523f3771e9528be32a7.zip | |
New test-suite for LuaRocks (#581)
First version of new test-suite, using Busted framework based on Google Summer of Code project:
https://summerofcode.withgoogle.com/projects/#5695811874717696
* Rewritten from Bash to Lua
* Tests now check if they did what they were supposed to, beyond only checking success or failure of the `luarocks` command
* Support for black-box (launching `luarocks` as an external command) and white-box (testing functions in modules directly) testing
| -rw-r--r-- | .travis.yml | 74 | ||||
| -rw-r--r-- | spec/add_spec.lua | 46 | ||||
| -rw-r--r-- | spec/build_spec.lua | 182 | ||||
| -rw-r--r-- | spec/config_spec.lua | 90 | ||||
| -rw-r--r-- | spec/deps_spec.lua | 115 | ||||
| -rw-r--r-- | spec/doc_spec.lua | 57 | ||||
| -rw-r--r-- | spec/download_spec.lua | 37 | ||||
| -rw-r--r-- | spec/fetch_spec.lua | 16 | ||||
| -rw-r--r-- | spec/help_spec.lua | 29 | ||||
| -rw-r--r-- | spec/install_spec.lua | 130 | ||||
| -rw-r--r-- | spec/lint_spec.lua | 51 | ||||
| -rw-r--r-- | spec/list_spec.lua | 41 | ||||
| -rw-r--r-- | spec/make_manifest_spec.lua | 19 | ||||
| -rw-r--r-- | spec/make_spec.lua | 99 | ||||
| -rw-r--r-- | spec/new_version_spec.lua | 53 | ||||
| -rw-r--r-- | spec/pack_spec.lua | 35 | ||||
| -rw-r--r-- | spec/path_spec.lua | 28 | ||||
| -rw-r--r-- | spec/purge_spec.lua | 30 | ||||
| -rw-r--r-- | spec/refresh_cache_spec.lua | 19 | ||||
| -rw-r--r-- | spec/remove_spec.lua | 85 | ||||
| -rw-r--r-- | spec/search_spec.lua | 42 | ||||
| -rw-r--r-- | spec/show_spec.lua | 56 | ||||
| -rw-r--r-- | spec/unpack_spec.lua | 61 | ||||
| -rw-r--r-- | spec/upload_spec.lua | 41 | ||||
| -rw-r--r-- | spec/util_spec.lua | 96 | ||||
| -rw-r--r-- | spec/write_rockspec_spec.lua | 74 | ||||
| -rw-r--r-- | test/README.md | 59 | ||||
| -rw-r--r-- | test/test_environment.lua | 625 | ||||
| -rw-r--r-- | test/testing.lua | 483 | ||||
| -rwxr-xr-x | test/testing.sh | 651 |
30 files changed, 2281 insertions, 1143 deletions
diff --git a/.travis.yml b/.travis.yml index 69ec28f3..c8755e7f 100644 --- a/.travis.yml +++ b/.travis.yml | |||
| @@ -1,13 +1,69 @@ | |||
| 1 | language: c | 1 | language: python |
| 2 | 2 | ||
| 3 | compiler: gcc | 3 | matrix: |
| 4 | include: | ||
| 5 | - os: linux | ||
| 6 | env: | ||
| 7 | - LUA="lua=5.1" | ||
| 8 | - os: linux | ||
| 9 | env: | ||
| 10 | - LUA="lua=5.2" | ||
| 11 | - os: linux | ||
| 12 | env: | ||
| 13 | - LUA="lua=5.3" | ||
| 14 | - os: linux | ||
| 15 | env: | ||
| 16 | - LUA="luajit=2.0" | ||
| 17 | - os: linux | ||
| 18 | env: | ||
| 19 | - LUA="luajit=2.1" | ||
| 20 | - os: osx | ||
| 21 | language: generic | ||
| 22 | env: | ||
| 23 | - LUA="lua=5.1" | ||
| 24 | - os: osx | ||
| 25 | language: generic | ||
| 26 | env: | ||
| 27 | - LUA="lua=5.2" | ||
| 28 | - os: osx | ||
| 29 | language: generic | ||
| 30 | env: | ||
| 31 | - LUA="lua=5.3" | ||
| 32 | - os: osx | ||
| 33 | language: generic | ||
| 34 | env: | ||
| 35 | - LUA="luajit=2.0" | ||
| 36 | - os: osx | ||
| 37 | language: generic | ||
| 38 | env: | ||
| 39 | - LUA="luajit=2.1" | ||
| 4 | 40 | ||
| 5 | sudo: false | ||
| 6 | 41 | ||
| 7 | env: | 42 | before_install: |
| 8 | matrix: | 43 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi |
| 9 | - LUA_VER=5.1.5 | 44 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install python3; fi |
| 10 | - LUA_VER=5.2.4 | 45 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then virtualenv venv -p python3; fi |
| 11 | - LUA_VER=5.3.1 | 46 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source venv/bin/activate; fi |
| 12 | 47 | ||
| 13 | script: cd test && ./testing.sh --travis --lua $LUA_VER | 48 | - pip install hererocks |
| 49 | - hererocks lua_install -r^ --$LUA | ||
| 50 | - export PATH=$PATH:$PWD/lua_install/bin # Add directory with all installed binaries to PATH | ||
| 51 | |||
| 52 | install: | ||
| 53 | - luarocks install busted | ||
| 54 | - luarocks install luacov | ||
| 55 | - luarocks install luacov-coveralls | ||
| 56 | |||
| 57 | script: | ||
| 58 | - busted -Xhelper travis,$LUA --verbose | ||
| 59 | - busted -Xhelper travis,$LUA,env=full --verbose | ||
| 60 | |||
| 61 | after_success: | ||
| 62 | - luacov-coveralls -c $TRAVIS_BUILD_DIR/test/luacov.config --exclude $TRAVIS_BUILD_DIR/test/ | ||
| 63 | - $PWD/lua_install/bin/luacov -c $TRAVIS_BUILD_DIR/test/luacov.config | ||
| 64 | - grep "Summary" -B1 -A1000 $TRAVIS_BUILD_DIR/test/luacov.report.out | ||
| 65 | |||
| 66 | notifications: | ||
| 67 | email: | ||
| 68 | on_success: change | ||
| 69 | on_failure: change \ No newline at end of file | ||
diff --git a/spec/add_spec.lua b/spec/add_spec.lua new file mode 100644 index 00000000..e417f974 --- /dev/null +++ b/spec/add_spec.lua | |||
| @@ -0,0 +1,46 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local add = require("luarocks.add") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/luasocket-3.0rc1-1.src.rock", | ||
| 9 | "/luasocket-3.0rc1-1.rockspec" | ||
| 10 | } | ||
| 11 | |||
| 12 | expose("LuaRocks add tests #blackbox #b_add", function() | ||
| 13 | |||
| 14 | before_each(function() | ||
| 15 | test_env.setup_specs(extra_rocks) | ||
| 16 | testing_paths = test_env.testing_paths | ||
| 17 | run = test_env.run | ||
| 18 | end) | ||
| 19 | |||
| 20 | describe("LuaRocks-admin add tests", function() | ||
| 21 | it("LuaRocks-admin add invalid rock #ssh", function() | ||
| 22 | assert.is_false(run.luarocks_admin_bool("--server=testing add invalid")) | ||
| 23 | end) | ||
| 24 | |||
| 25 | it("LuaRocks-admin add missing argument", function() | ||
| 26 | assert.is_false(run.luarocks_admin_bool("--server=testing add")) | ||
| 27 | end) | ||
| 28 | |||
| 29 | it("LuaRocks-admin add invalid server", function() | ||
| 30 | assert.is_false(run.luarocks_admin_bool("--server=invalid add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-1.src.rock")) | ||
| 31 | end) | ||
| 32 | |||
| 33 | it("LuaRocks-admin add invalid server #ssh", function() | ||
| 34 | assert.is_true(run.luarocks_admin_bool("--server=testing add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-1.src.rock")) | ||
| 35 | end) | ||
| 36 | |||
| 37 | --TODO This test fails, sftp not implemented | ||
| 38 | it("LuaRocks-admin add invalid server", function() --? | ||
| 39 | assert.is_false(run.luarocks_admin_bool("--server=testing add luasocket-3.0rc1-1.src.rock", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_sftp.lua" } )) | ||
| 40 | end) | ||
| 41 | |||
| 42 | it("LuaRocks-admin add, split server url", function() | ||
| 43 | assert.is_false(run.luarocks_admin_bool("--server=\"localhost@/tmp/luarocks_testing\" add " .. testing_paths.testing_server .. "luasocket-3.0rc1-1.src.rock")) | ||
| 44 | end) | ||
| 45 | end) | ||
| 46 | end) \ No newline at end of file | ||
diff --git a/spec/build_spec.lua b/spec/build_spec.lua new file mode 100644 index 00000000..6665de0b --- /dev/null +++ b/spec/build_spec.lua | |||
| @@ -0,0 +1,182 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local build = require("luarocks.build") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/lmathx-20120430.51-1.src.rock", | ||
| 9 | "/lmathx-20120430.51-1.rockspec", | ||
| 10 | "/lmathx-20120430.52-1.src.rock", | ||
| 11 | "/lmathx-20120430.52-1.rockspec", | ||
| 12 | "/lmathx-20150505-1.src.rock", | ||
| 13 | "/lmathx-20150505-1.rockspec", | ||
| 14 | "/lpeg-0.12-1.src.rock", | ||
| 15 | "/lpty-1.0.1-1.src.rock", | ||
| 16 | "/luadoc-3.0.1-1.src.rock", | ||
| 17 | "/luafilesystem-1.6.3-1.src.rock", | ||
| 18 | "/lualogging-1.3.0-1.src.rock", | ||
| 19 | "/luarepl-0.4-1.src.rock", | ||
| 20 | "/luasec-0.6-1.rockspec", | ||
| 21 | "/luasocket-3.0rc1-1.src.rock", | ||
| 22 | "/luasocket-3.0rc1-1.rockspec", | ||
| 23 | "/lxsh-0.8.6-2.src.rock", | ||
| 24 | "/lxsh-0.8.6-2.rockspec", | ||
| 25 | "/stdlib-41.0.0-1.src.rock", | ||
| 26 | "/validate-args-1.5.4-1.rockspec" | ||
| 27 | } | ||
| 28 | |||
| 29 | expose("LuaRocks build tests #blackbox #b_build", function() | ||
| 30 | |||
| 31 | before_each(function() | ||
| 32 | test_env.setup_specs(extra_rocks) | ||
| 33 | testing_paths = test_env.testing_paths | ||
| 34 | run = test_env.run | ||
| 35 | end) | ||
| 36 | |||
| 37 | describe("LuaRocks build - basic testing set", function() | ||
| 38 | it("LuaRocks build with no flags/arguments", function() | ||
| 39 | assert.is_false(run.luarocks_bool("build")) | ||
| 40 | end) | ||
| 41 | |||
| 42 | it("LuaRocks build invalid", function() | ||
| 43 | assert.is_false(run.luarocks_bool("build invalid")) | ||
| 44 | end) | ||
| 45 | end) | ||
| 46 | |||
| 47 | describe("LuaRocks build - building lpeg with flags", function() | ||
| 48 | it("LuaRocks build fail build permissions", function() | ||
| 49 | if test_env.TEST_TARGET_OS == "osx" or test_env.TEST_TARGET_OS == "linux" then | ||
| 50 | assert.is_false(run.luarocks_bool("build --tree=/usr lpeg")) | ||
| 51 | end | ||
| 52 | end) | ||
| 53 | |||
| 54 | it("LuaRocks build fail build permissions parent", function() | ||
| 55 | if test_env.TEST_TARGET_OS == "osx" or test_env.TEST_TARGET_OS == "linux" then | ||
| 56 | assert.is_false(run.luarocks_bool("build --tree=/usr/invalid lpeg")) | ||
| 57 | end | ||
| 58 | end) | ||
| 59 | |||
| 60 | it("LuaRocks build lpeg verbose", function() | ||
| 61 | assert.is_true(run.luarocks_bool("build --verbose lpeg")) | ||
| 62 | end) | ||
| 63 | |||
| 64 | it("LuaRocks build lpeg branch=master", function() | ||
| 65 | assert.is_true(run.luarocks_bool("build --branch=master lpeg")) | ||
| 66 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 67 | end) | ||
| 68 | |||
| 69 | it("LuaRocks build lpeg deps-mode=123", function() | ||
| 70 | assert.is_false(run.luarocks_bool("build --deps-mode=123 lpeg")) | ||
| 71 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 72 | end) | ||
| 73 | |||
| 74 | it("LuaRocks build lpeg only-sources example", function() | ||
| 75 | assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg")) | ||
| 76 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 77 | end) | ||
| 78 | |||
| 79 | it("LuaRocks build lpeg with empty tree", function() | ||
| 80 | assert.is_false(run.luarocks_bool("build --tree=\"\" lpeg")) | ||
| 81 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 82 | end) | ||
| 83 | end) | ||
| 84 | |||
| 85 | describe("LuaRocks build - basic builds", function() | ||
| 86 | |||
| 87 | it("LuaRocks build luadoc", function() | ||
| 88 | assert.is_true(run.luarocks_bool("build luadoc")) | ||
| 89 | end) | ||
| 90 | |||
| 91 | it("LuaRocks build luacov diff version", function() | ||
| 92 | assert.is_true(run.luarocks_bool("build luacov 0.11.0-1")) | ||
| 93 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luacov")) | ||
| 94 | end) | ||
| 95 | |||
| 96 | it("LuaRocks build command stdlib", function() | ||
| 97 | assert.is_true(run.luarocks_bool("build stdlib")) | ||
| 98 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/stdlib")) | ||
| 99 | end) | ||
| 100 | |||
| 101 | it("LuaRocks build install bin luarepl", function() | ||
| 102 | assert.is_true(run.luarocks_bool("build luarepl")) | ||
| 103 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl")) | ||
| 104 | end) | ||
| 105 | |||
| 106 | it("LuaRocks build supported platforms lpty", function() | ||
| 107 | assert.is_true(run.luarocks_bool("build lpty")) | ||
| 108 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty")) | ||
| 109 | end) | ||
| 110 | |||
| 111 | it("LuaRocks build luasec with skipping dependency checks", function() | ||
| 112 | assert.is_true(run.luarocks_bool("build luasec --nodeps")) | ||
| 113 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) | ||
| 114 | end) | ||
| 115 | |||
| 116 | it("LuaRocks build lmathx deps partial match", function() | ||
| 117 | assert.is_true(run.luarocks_bool("build lmathx")) | ||
| 118 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx")) | ||
| 119 | end) | ||
| 120 | end) | ||
| 121 | |||
| 122 | describe("LuaRocks build - more complex tests", function() | ||
| 123 | |||
| 124 | it("LuaRocks build luacheck show downloads test_config", function() | ||
| 125 | local out = run.luarocks("build luacheck", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_show_downloads.lua"} ) | ||
| 126 | print(out) | ||
| 127 | end) | ||
| 128 | |||
| 129 | it("LuaRocks build luasec only deps", function() | ||
| 130 | assert.is_true(run.luarocks_bool("build luasec --only-deps")) | ||
| 131 | assert.is_false(run.luarocks_bool("show luasec")) | ||
| 132 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) | ||
| 133 | end) | ||
| 134 | |||
| 135 | it("LuaRocks build only deps of downloaded rockspec of lxsh", function() | ||
| 136 | assert.is_true(run.luarocks_bool("download --rockspec lxsh 0.8.6-2")) | ||
| 137 | assert.is_true(run.luarocks_bool("build lxsh-0.8.6-2.rockspec --only-deps")) | ||
| 138 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
| 139 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 140 | assert.is_true(os.remove("lxsh-0.8.6-2.rockspec")) | ||
| 141 | end) | ||
| 142 | |||
| 143 | it("LuaRocks build only deps of downloaded rock of lxsh", function() | ||
| 144 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) | ||
| 145 | assert.is_true(run.luarocks_bool("build lxsh-0.8.6-2.src.rock --only-deps")) | ||
| 146 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
| 147 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 148 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | ||
| 149 | end) | ||
| 150 | |||
| 151 | it("LuaRocks build no https", function() | ||
| 152 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | ||
| 153 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) | ||
| 154 | |||
| 155 | assert.is_true(run.luarocks_bool("show validate-args")) | ||
| 156 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) | ||
| 157 | |||
| 158 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | ||
| 159 | end) | ||
| 160 | |||
| 161 | it("LuaRocks build with https", function() | ||
| 162 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | ||
| 163 | assert.is_true(run.luarocks_bool("install luasec")) | ||
| 164 | assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) | ||
| 165 | |||
| 166 | assert.is_true(run.luarocks_bool("show validate-args")) | ||
| 167 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) | ||
| 168 | |||
| 169 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | ||
| 170 | end) | ||
| 171 | |||
| 172 | it("LuaRocks build missing external", function() | ||
| 173 | assert.is_true(test_env.need_luasocket()) | ||
| 174 | assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/missing_external-0.1-1.rockspec INEXISTENT_INCDIR=\"/invalid/dir\"")) | ||
| 175 | end) | ||
| 176 | |||
| 177 | it("LuaRocks build invalid patch", function() | ||
| 178 | assert.is_true(test_env.need_luasocket()) | ||
| 179 | assert.is_false(run.luarocks_bool("build " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) | ||
| 180 | end) | ||
| 181 | end) | ||
| 182 | end) | ||
diff --git a/spec/config_spec.lua b/spec/config_spec.lua new file mode 100644 index 00000000..f6cabd8c --- /dev/null +++ b/spec/config_spec.lua | |||
| @@ -0,0 +1,90 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local cfg = require("luarocks.cfg") | ||
| 6 | |||
| 7 | expose("LuaRocks config tests #blackbox #b_config", function() | ||
| 8 | |||
| 9 | before_each(function() | ||
| 10 | test_env.setup_specs(extra_rocks) | ||
| 11 | test_env.unload_luarocks() -- need to be required here, because site_config is created after first loading of specs | ||
| 12 | site_config = require("luarocks.site_config") | ||
| 13 | testing_paths = test_env.testing_paths | ||
| 14 | run = test_env.run | ||
| 15 | end) | ||
| 16 | |||
| 17 | describe("LuaRocks config - basic tests", function() | ||
| 18 | it("LuaRocks config with no flags/arguments", function() | ||
| 19 | assert.is_false(run.luarocks_bool("config")) | ||
| 20 | end) | ||
| 21 | |||
| 22 | it("LuaRocks config include dir", function() | ||
| 23 | local output = run.luarocks("config --lua-incdir") | ||
| 24 | assert.are.same(output, site_config.LUA_INCDIR) | ||
| 25 | end) | ||
| 26 | |||
| 27 | it("LuaRocks config library dir", function() | ||
| 28 | local output = run.luarocks("config --lua-libdir") | ||
| 29 | assert.are.same(output, site_config.LUA_LIBDIR) | ||
| 30 | end) | ||
| 31 | |||
| 32 | it("LuaRocks config lua version", function() | ||
| 33 | local output = run.luarocks("config --lua-ver") | ||
| 34 | local lua_version = _VERSION:gsub("Lua ", "") | ||
| 35 | if test_env.LUAJIT_V then | ||
| 36 | lua_version = "5.1" | ||
| 37 | end | ||
| 38 | assert.are.same(output, lua_version) | ||
| 39 | end) | ||
| 40 | |||
| 41 | it("LuaRocks config rock trees", function() | ||
| 42 | assert.is_true(run.luarocks_bool("config --rock-trees")) | ||
| 43 | end) | ||
| 44 | |||
| 45 | it("LuaRocks config user config", function() | ||
| 46 | local user_config_path = run.luarocks("config --user-config") | ||
| 47 | assert.is.truthy(lfs.attributes(user_config_path)) | ||
| 48 | end) | ||
| 49 | |||
| 50 | it("LuaRocks config missing user config", function() | ||
| 51 | assert.is_false(run.luarocks_bool("config --user-config", {LUAROCKS_CONFIG = "missing_file.lua"})) | ||
| 52 | end) | ||
| 53 | end) | ||
| 54 | |||
| 55 | describe("LuaRocks config - more complex tests", function() | ||
| 56 | it("LuaRocks fail system config", function() | ||
| 57 | os.remove(testing_paths.testing_lrprefix .. "/etc/luarocks/config.lua") | ||
| 58 | assert.is_false(run.luarocks_bool("config --system-config;")) | ||
| 59 | end) | ||
| 60 | |||
| 61 | it("LuaRocks system config", function() | ||
| 62 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | ||
| 63 | lfs.mkdir(testing_paths.testing_lrprefix) | ||
| 64 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | ||
| 65 | lfs.mkdir(scdir) | ||
| 66 | |||
| 67 | local sysconfig = io.open(scdir .. "/config.lua", "w+") | ||
| 68 | sysconfig:write(" ") | ||
| 69 | sysconfig:close() | ||
| 70 | |||
| 71 | local output = run.luarocks("config --system-config;") | ||
| 72 | assert.are.same(output, scdir .. "/config.lua") | ||
| 73 | test_env.remove_dir(testing_paths.testing_lrprefix) | ||
| 74 | end) | ||
| 75 | |||
| 76 | it("LuaRocks fail system config invalid", function() | ||
| 77 | local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" | ||
| 78 | lfs.mkdir(testing_paths.testing_lrprefix) | ||
| 79 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | ||
| 80 | lfs.mkdir(scdir) | ||
| 81 | |||
| 82 | local sysconfig = io.open(scdir .. "/config.lua", "w+") | ||
| 83 | sysconfig:write("if if if") | ||
| 84 | sysconfig:close() | ||
| 85 | |||
| 86 | assert.is_false(run.luarocks_bool("config --system-config;")) | ||
| 87 | test_env.remove_dir(testing_paths.testing_lrprefix) | ||
| 88 | end) | ||
| 89 | end) | ||
| 90 | end) \ No newline at end of file | ||
diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua new file mode 100644 index 00000000..ce784080 --- /dev/null +++ b/spec/deps_spec.lua | |||
| @@ -0,0 +1,115 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local deps = require("luarocks.deps") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/lxsh-0.8.6-2.src.rock", | ||
| 9 | "/lxsh-0.8.6-2.rockspec", | ||
| 10 | "/luasocket-3.0rc1-1.src.rock", | ||
| 11 | "/luasocket-3.0rc1-1.rockspec", | ||
| 12 | "/lpeg-0.12-1.src.rock" | ||
| 13 | } | ||
| 14 | |||
| 15 | expose("LuaRocks deps tests #blackbox #b_deps", function() | ||
| 16 | |||
| 17 | before_each(function() | ||
| 18 | test_env.setup_specs(extra_rocks) | ||
| 19 | testing_paths = test_env.testing_paths | ||
| 20 | run = test_env.run | ||
| 21 | end) | ||
| 22 | |||
| 23 | it("LuaRocks deps mode one", function() | ||
| 24 | assert.is_true(run.luarocks_bool("build --tree=system lpeg")) | ||
| 25 | assert.is_true(run.luarocks_bool("build --deps-mode=one --tree=" .. testing_paths.testing_tree .. " lxsh")) | ||
| 26 | |||
| 27 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 28 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 29 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 30 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 31 | end) | ||
| 32 | |||
| 33 | it("LuaRocks deps mode order", function() | ||
| 34 | assert.is_true(run.luarocks_bool("build --tree=system lpeg")) | ||
| 35 | assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_tree .. " lxsh")) | ||
| 36 | |||
| 37 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 38 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 39 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 40 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 41 | end) | ||
| 42 | |||
| 43 | it("LuaRocks deps mode order sys", function() | ||
| 44 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) | ||
| 45 | assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) | ||
| 46 | |||
| 47 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 48 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 49 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 50 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 51 | end) | ||
| 52 | |||
| 53 | it("LuaRocks deps mode all sys", function() | ||
| 54 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) | ||
| 55 | assert.is_true(run.luarocks_bool("build --deps-mode=all --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) | ||
| 56 | |||
| 57 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 58 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 59 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 60 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 61 | end) | ||
| 62 | |||
| 63 | it("LuaRocks deps mode none", function() | ||
| 64 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) | ||
| 65 | assert.is_true(run.luarocks_bool("build --deps-mode=none lxsh")) | ||
| 66 | |||
| 67 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 68 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 69 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 70 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 71 | end) | ||
| 72 | |||
| 73 | it("LuaRocks nodeps alias", function() | ||
| 74 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " --nodeps lxsh")) | ||
| 75 | |||
| 76 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 77 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 78 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 79 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 80 | end) | ||
| 81 | |||
| 82 | it("LuaRocks deps mode make order", function() | ||
| 83 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_sys_tree .. " lpeg")) | ||
| 84 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6")) | ||
| 85 | assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock")) | ||
| 86 | lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/") | ||
| 87 | assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_tree .. " --deps-mode=order")) | ||
| 88 | |||
| 89 | lfs.chdir(testing_paths.luarocks_dir) | ||
| 90 | test_env.remove_dir("lxsh-0.8.6-2") | ||
| 91 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | ||
| 92 | |||
| 93 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 94 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 95 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 96 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 97 | end) | ||
| 98 | |||
| 99 | it("LuaRocks deps mode make order sys", function() | ||
| 100 | assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) | ||
| 101 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6")) | ||
| 102 | assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock")) | ||
| 103 | lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/") | ||
| 104 | assert.is_true(run.luarocks_bool("make --tree=" .. testing_paths.testing_sys_tree .. " --deps-mode=order")) | ||
| 105 | |||
| 106 | lfs.chdir(testing_paths.luarocks_dir) | ||
| 107 | test_env.remove_dir("lxsh-0.8.6-2") | ||
| 108 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | ||
| 109 | |||
| 110 | assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 111 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) | ||
| 112 | assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 113 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 114 | end) | ||
| 115 | end) \ No newline at end of file | ||
diff --git a/spec/doc_spec.lua b/spec/doc_spec.lua new file mode 100644 index 00000000..476b8ea8 --- /dev/null +++ b/spec/doc_spec.lua | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local doc = require("luarocks.doc") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/luarepl-0.4-1.src.rock" | ||
| 9 | } | ||
| 10 | |||
| 11 | expose("LuaRocks doc tests #blackbox #b_doc", function() | ||
| 12 | |||
| 13 | before_each(function() | ||
| 14 | test_env.setup_specs(extra_rocks) | ||
| 15 | testing_paths = test_env.testing_paths | ||
| 16 | run = test_env.run | ||
| 17 | end) | ||
| 18 | |||
| 19 | describe("LuaRocks doc basic tests", function() | ||
| 20 | it("LuaRocks doc with no flags/arguments", function() | ||
| 21 | assert.is_false(run.luarocks_bool("doc")) | ||
| 22 | end) | ||
| 23 | it("LuaRocks doc with invalid argument", function() | ||
| 24 | assert.is_false(run.luarocks_bool("doc invalid")) | ||
| 25 | end) | ||
| 26 | end) | ||
| 27 | |||
| 28 | describe("LuaRocks doc tests with flags", function() | ||
| 29 | it("LuaRocks doc of installed luarepl", function() | ||
| 30 | assert.is_true(run.luarocks_bool("install luarepl")) | ||
| 31 | assert.is_true(run.luarocks_bool("doc luarepl")) | ||
| 32 | end) | ||
| 33 | |||
| 34 | it("LuaRocks doc of luacov and access its home page", function() | ||
| 35 | assert.is_true(run.luarocks_bool("install luacov")) | ||
| 36 | assert.is_true(run.luarocks_bool("doc luacov --home")) | ||
| 37 | end) | ||
| 38 | |||
| 39 | it("LuaRocks doc of luacov and list doc folder", function() | ||
| 40 | assert.is_true(run.luarocks_bool("install luacov")) | ||
| 41 | local output = assert.is.truthy(run.luarocks("doc luacov --list")) | ||
| 42 | assert.is.truthy(output:find("/lib/luarocks/rocks/luacov/0.11.0--1/doc/")) | ||
| 43 | end) | ||
| 44 | |||
| 45 | it("LuaRocks doc of luacov local", function() | ||
| 46 | assert.is_true(run.luarocks_bool("install luacov")) | ||
| 47 | assert.is_true(run.luarocks_bool("doc luacov --local")) | ||
| 48 | end) | ||
| 49 | |||
| 50 | it("LuaRocks doc of luacov porcelain", function() | ||
| 51 | assert.is_true(run.luarocks_bool("install luacov")) | ||
| 52 | assert.is_true(run.luarocks_bool("doc luacov --porcelain")) | ||
| 53 | end) | ||
| 54 | end) | ||
| 55 | end) | ||
| 56 | |||
| 57 | |||
diff --git a/spec/download_spec.lua b/spec/download_spec.lua new file mode 100644 index 00000000..9b5d9e2e --- /dev/null +++ b/spec/download_spec.lua | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local download = require("luarocks.download") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/validate-args-1.5.4-1.rockspec" | ||
| 9 | } | ||
| 10 | |||
| 11 | expose("LuaRocks download tests #blackbox #b_download", function() | ||
| 12 | |||
| 13 | before_each(function() | ||
| 14 | test_env.setup_specs(extra_rocks) | ||
| 15 | run = test_env.run | ||
| 16 | end) | ||
| 17 | |||
| 18 | it("LuaRocks download with no flags/arguments", function() | ||
| 19 | assert.is_false(run.luarocks_bool("download")) | ||
| 20 | end) | ||
| 21 | |||
| 22 | it("LuaRocks download invalid", function() | ||
| 23 | assert.is_false(run.luarocks_bool("download invalid")) | ||
| 24 | end) | ||
| 25 | |||
| 26 | it("LuaRocks download all with delete downloaded files", function() --TODO maybe download --all more rocks | ||
| 27 | assert.is_true(run.luarocks_bool("download --all validate-args")) | ||
| 28 | assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec")) | ||
| 29 | test_env.remove_files(lfs.currentdir(), "validate--args--") | ||
| 30 | end) | ||
| 31 | |||
| 32 | it("LuaRocks download rockspec version", function() | ||
| 33 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | ||
| 34 | assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec")) | ||
| 35 | test_env.remove_files(lfs.currentdir(), "validate--args--") | ||
| 36 | end) | ||
| 37 | end) | ||
diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua new file mode 100644 index 00000000..1f298733 --- /dev/null +++ b/spec/fetch_spec.lua | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local fetch = require("luarocks.fetch") | ||
| 6 | |||
| 7 | describe("Luarocks fetch test #whitebox #w_fetch", function() | ||
| 8 | it("Fetch url to base dir", function() | ||
| 9 | assert.are.same("v0.3", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3.zip")) | ||
| 10 | assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.zip")) | ||
| 11 | assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.gz")) | ||
| 12 | assert.are.same("lua-compat-5.2", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.bz2")) | ||
| 13 | assert.are.same("parser.moon", fetch.url_to_base_dir("git://github.com/Cirru/parser.moon")) | ||
| 14 | assert.are.same("v0.3", fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3")) | ||
| 15 | end) | ||
| 16 | end) \ No newline at end of file | ||
diff --git a/spec/help_spec.lua b/spec/help_spec.lua new file mode 100644 index 00000000..0f40dd38 --- /dev/null +++ b/spec/help_spec.lua | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local help = require("luarocks.help") | ||
| 6 | |||
| 7 | expose("LuaRocks help tests #blackbox #b_help", function() | ||
| 8 | |||
| 9 | before_each(function() | ||
| 10 | test_env.setup_specs(extra_rocks) | ||
| 11 | run = test_env.run | ||
| 12 | end) | ||
| 13 | |||
| 14 | it("LuaRocks help with no flags/arguments", function() | ||
| 15 | assert.is_true(run.luarocks_bool("help")) | ||
| 16 | end) | ||
| 17 | |||
| 18 | it("LuaRocks help invalid argument", function() | ||
| 19 | assert.is_false(run.luarocks_bool("help invalid")) | ||
| 20 | end) | ||
| 21 | |||
| 22 | it("LuaRocks help config", function() | ||
| 23 | assert.is_true(run.luarocks_bool("help config")) | ||
| 24 | end) | ||
| 25 | |||
| 26 | it("LuaRocks-admin help with no flags/arguments", function() | ||
| 27 | assert.is_true(run.luarocks_admin_bool("help")) | ||
| 28 | end) | ||
| 29 | end) \ No newline at end of file | ||
diff --git a/spec/install_spec.lua b/spec/install_spec.lua new file mode 100644 index 00000000..306bbbc1 --- /dev/null +++ b/spec/install_spec.lua | |||
| @@ -0,0 +1,130 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local install = require("luarocks.install") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/cprint-0.1-2.src.rock", | ||
| 9 | "/cprint-0.1-2.rockspec", | ||
| 10 | "/lpeg-0.12-1.src.rock", | ||
| 11 | "/luasec-0.6-1.rockspec", | ||
| 12 | "/luassert-1.7.0-1.src.rock", | ||
| 13 | "/luasocket-3.0rc1-1.src.rock", | ||
| 14 | "/luasocket-3.0rc1-1.rockspec", | ||
| 15 | "/lxsh-0.8.6-2.src.rock", | ||
| 16 | "/lxsh-0.8.6-2.rockspec", | ||
| 17 | "/say-1.2-1.src.rock", | ||
| 18 | "/say-1.0-1.src.rock", | ||
| 19 | "/wsapi-1.6-1.src.rock" | ||
| 20 | } | ||
| 21 | |||
| 22 | expose("LuaRocks install tests #blackbox #b_install", function() | ||
| 23 | |||
| 24 | before_each(function() | ||
| 25 | test_env.setup_specs(extra_rocks) | ||
| 26 | testing_paths = test_env.testing_paths | ||
| 27 | env_variables = test_env.env_variables | ||
| 28 | run = test_env.run | ||
| 29 | platform = test_env.platform | ||
| 30 | end) | ||
| 31 | |||
| 32 | describe("LuaRocks install - basic tests", function() | ||
| 33 | it("LuaRocks install with no flags/arguments", function() | ||
| 34 | assert.is_false(run.luarocks_bool("install")) | ||
| 35 | end) | ||
| 36 | |||
| 37 | it("LuaRocks install with invalid argument", function() | ||
| 38 | assert.is_false(run.luarocks_bool("install invalid")) | ||
| 39 | end) | ||
| 40 | |||
| 41 | it("LuaRocks install invalid patch", function() | ||
| 42 | assert.is_false(run.luarocks_bool("install " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) | ||
| 43 | end) | ||
| 44 | |||
| 45 | it("LuaRocks install invalid rock", function() | ||
| 46 | assert.is_false(run.luarocks_bool("install \"invalid.rock\" ")) | ||
| 47 | end) | ||
| 48 | |||
| 49 | it("LuaRocks install with local flag as root", function() | ||
| 50 | assert.is_false(run.luarocks_bool("install --local luasocket", { USER = "root" } )) | ||
| 51 | end) | ||
| 52 | |||
| 53 | it("LuaRocks install not a zip file", function() | ||
| 54 | assert.is_false(run.luarocks_bool("install " .. testing_paths.testing_dir .. "/testfiles/not_a_zipfile-1.0-1.src.rock")) | ||
| 55 | end) | ||
| 56 | |||
| 57 | it("LuaRocks install only-deps of lxsh show there is no lxsh", function() | ||
| 58 | assert.is_true(run.luarocks_bool("install lxsh 0.8.6-2 --only-deps")) | ||
| 59 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
| 60 | end) | ||
| 61 | |||
| 62 | it("LuaRocks install incompatible architecture", function() | ||
| 63 | assert.is_false(run.luarocks_bool("install \"foo-1.0-1.impossible-x86.rock\" ")) | ||
| 64 | end) | ||
| 65 | |||
| 66 | it("LuaRocks install wsapi with bin", function() | ||
| 67 | run.luarocks_bool("install wsapi") | ||
| 68 | end) | ||
| 69 | |||
| 70 | it("LuaRocks install luasec and show luasocket (dependency)", function() | ||
| 71 | assert.is_true(run.luarocks_bool("install luasec")) | ||
| 72 | assert.is_true(run.luarocks_bool("show luasocket")) | ||
| 73 | end) | ||
| 74 | end) | ||
| 75 | |||
| 76 | describe("LuaRocks install - more complex tests", function() | ||
| 77 | it('LuaRocks install luasec with skipping dependency checks', function() | ||
| 78 | run.luarocks(" install luasec --nodeps") | ||
| 79 | assert.is_true(run.luarocks_bool("show luasec")) | ||
| 80 | if env_variables.TYPE_TEST_ENV == "minimal" then | ||
| 81 | assert.is_false(run.luarocks_bool("show luasocket")) | ||
| 82 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
| 83 | end | ||
| 84 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) | ||
| 85 | end) | ||
| 86 | |||
| 87 | it("LuaRocks install only-deps of luasocket packed rock", function() | ||
| 88 | assert.is_true(test_env.need_luasocket()) | ||
| 89 | local output = run.luarocks("install --only-deps " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. platform .. ".rock") | ||
| 90 | assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-1") | ||
| 91 | end) | ||
| 92 | |||
| 93 | it("LuaRocks install binary rock of cprint", function() | ||
| 94 | assert.is_true(test_env.need_luasocket()) | ||
| 95 | assert.is_true(run.luarocks_bool("build --pack-binary-rock cprint")) | ||
| 96 | assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. platform .. ".rock")) | ||
| 97 | assert.is_true(os.remove("cprint-0.1-2." .. platform .. ".rock")) | ||
| 98 | end) | ||
| 99 | |||
| 100 | it("LuaRocks install reinstall", function() | ||
| 101 | assert.is_true(test_env.need_luasocket()) | ||
| 102 | assert.is_true(run.luarocks_bool("install " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. platform .. ".rock")) | ||
| 103 | assert.is_true(run.luarocks_bool("install --deps-mode=none " .. testing_paths.testing_cache .. "/luasocket-3.0rc1-1." .. platform .. ".rock")) | ||
| 104 | end) | ||
| 105 | end) | ||
| 106 | |||
| 107 | describe("New install functionality based on pull request 552", function() | ||
| 108 | it("LuaRocks install break dependencies warning", function() | ||
| 109 | assert.is_true(run.luarocks_bool("install say 1.2")) | ||
| 110 | assert.is_true(run.luarocks_bool("install luassert")) | ||
| 111 | assert.is_true(run.luarocks_bool("install say 1.0")) | ||
| 112 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1")) | ||
| 113 | end) | ||
| 114 | it("LuaRocks install break dependencies force", function() | ||
| 115 | assert.is_true(run.luarocks_bool("install say 1.2")) | ||
| 116 | assert.is_true(run.luarocks_bool("install luassert")) | ||
| 117 | local output = run.luarocks("install --force say 1.0") | ||
| 118 | assert.is.truthy(output:find("Checking stability of dependencies")) | ||
| 119 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1")) | ||
| 120 | end) | ||
| 121 | it("LuaRocks install break dependencies force fast", function() | ||
| 122 | assert.is_true(run.luarocks_bool("install say 1.2")) | ||
| 123 | assert.is_true(run.luarocks_bool("install luassert")) | ||
| 124 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.2-1")) | ||
| 125 | local output = run.luarocks("install --force-fast say 1.0") | ||
| 126 | assert.is.falsy(output:find("Checking stability of dependencies")) | ||
| 127 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/say/1.0-1")) | ||
| 128 | end) | ||
| 129 | end) | ||
| 130 | end) \ No newline at end of file | ||
diff --git a/spec/lint_spec.lua b/spec/lint_spec.lua new file mode 100644 index 00000000..cba80a3e --- /dev/null +++ b/spec/lint_spec.lua | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local lint = require("luarocks.lint") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/validate-args-1.5.4-1.rockspec" | ||
| 9 | } | ||
| 10 | |||
| 11 | expose("LuaRocks lint tests #blackbox #b_lint", function() | ||
| 12 | |||
| 13 | before_each(function() | ||
| 14 | test_env.setup_specs(extra_rocks) | ||
| 15 | testing_paths = test_env.testing_paths | ||
| 16 | run = test_env.run | ||
| 17 | end) | ||
| 18 | |||
| 19 | it("LuaRocks lint with no flags/arguments", function() | ||
| 20 | assert.is_false(run.luarocks_bool("lint")) | ||
| 21 | end) | ||
| 22 | |||
| 23 | it("LuaRocks lint invalid argument", function() | ||
| 24 | assert.is_false(run.luarocks_bool("lint invalid")) | ||
| 25 | end) | ||
| 26 | |||
| 27 | it("LuaRocks lint OK", function() | ||
| 28 | assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) | ||
| 29 | local output = run.luarocks("lint validate-args-1.5.4-1.rockspec") | ||
| 30 | assert.are.same(output, "") | ||
| 31 | assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) | ||
| 32 | end) | ||
| 33 | |||
| 34 | describe("LuaRocks lint mismatch set", function() | ||
| 35 | it("LuaRocks lint mismatch string", function() | ||
| 36 | assert.is_false(run.luarocks_bool("lint " .. testing_paths.testing_dir .. "/testfiles/type_mismatch_string-1.0-1.rockspec")) | ||
| 37 | end) | ||
| 38 | |||
| 39 | it("LuaRocks lint mismatch version", function() | ||
| 40 | assert.is_false(run.luarocks_bool("lint " .. testing_paths.testing_dir .. "/testfiles/type_mismatch_version-1.0-1.rockspec")) | ||
| 41 | end) | ||
| 42 | |||
| 43 | it("LuaRocks lint mismatch table", function() | ||
| 44 | assert.is_false(run.luarocks_bool("lint " .. testing_paths.testing_dir .. "/testfiles/type_mismatch_table-1.0-1.rockspec")) | ||
| 45 | end) | ||
| 46 | |||
| 47 | it("LuaRocks lint mismatch no build table", function() | ||
| 48 | assert.is_false(run.luarocks_bool("lint " .. testing_paths.testing_dir .. "/testfiles/no_build_table-1.0-1.rockspec")) | ||
| 49 | end) | ||
| 50 | end) | ||
| 51 | end) \ No newline at end of file | ||
diff --git a/spec/list_spec.lua b/spec/list_spec.lua new file mode 100644 index 00000000..545483df --- /dev/null +++ b/spec/list_spec.lua | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local list = require("luarocks.list") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/say-1.0-1.src.rock", | ||
| 9 | "/say-1.2-1.src.rock" | ||
| 10 | } | ||
| 11 | |||
| 12 | expose("LuaRocks list tests #blackbox #b_list", function() | ||
| 13 | |||
| 14 | before_each(function() | ||
| 15 | test_env.setup_specs(extra_rocks) | ||
| 16 | run = test_env.run | ||
| 17 | testing_paths = test_env.testing_paths | ||
| 18 | end) | ||
| 19 | |||
| 20 | it("LuaRocks list with no flags/arguments", function() | ||
| 21 | local output = run.luarocks("list") | ||
| 22 | assert.is.truthy(output:find("luacov")) | ||
| 23 | end) | ||
| 24 | |||
| 25 | it("LuaRocks list porcelain", function() | ||
| 26 | local output = run.luarocks("list --porcelain") | ||
| 27 | local path = testing_paths.testing_sys_tree:gsub("-", "--") -- !not sure! why this is good | ||
| 28 | assert.is.truthy(output:find("luacov\t0.11.0--1\tinstalled\t" .. path .. "/lib/luarocks/rocks" )) | ||
| 29 | end) | ||
| 30 | |||
| 31 | it("LuaRocks install outdated and list it", function() | ||
| 32 | assert.is_true(run.luarocks_bool("install say 1.0-1")) | ||
| 33 | local output = run.luarocks("list --outdated") | ||
| 34 | assert.is.truthy(output:find("say")) | ||
| 35 | end) | ||
| 36 | |||
| 37 | it("LuaRocks list invalid tree", function() | ||
| 38 | local output = run.luarocks("--tree=/some/invalid/tree list") | ||
| 39 | assert.are.same(output, "Installed rocks:----------------") | ||
| 40 | end) | ||
| 41 | end) | ||
diff --git a/spec/make_manifest_spec.lua b/spec/make_manifest_spec.lua new file mode 100644 index 00000000..c6cb1328 --- /dev/null +++ b/spec/make_manifest_spec.lua | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local make_manifest = require("luarocks.make_manifest") | ||
| 6 | |||
| 7 | expose("LuaRocks make_manifest tests #blackbox #b_make_manifest", function() | ||
| 8 | |||
| 9 | before_each(function() | ||
| 10 | test_env.setup_specs(extra_rocks) | ||
| 11 | run = test_env.run | ||
| 12 | end) | ||
| 13 | |||
| 14 | describe("LuaRocks-admin make manifest tests", function() | ||
| 15 | it("LuaRocks-admin make manifest", function() | ||
| 16 | assert.is_true(run.luarocks_admin_bool("make_manifest")) | ||
| 17 | end) | ||
| 18 | end) | ||
| 19 | end) \ No newline at end of file | ||
diff --git a/spec/make_spec.lua b/spec/make_spec.lua new file mode 100644 index 00000000..f70bb7e9 --- /dev/null +++ b/spec/make_spec.lua | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local make = require("luarocks.make") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/lpeg-0.12-1.src.rock", | ||
| 9 | "/luasocket-3.0rc1-1.src.rock", | ||
| 10 | "/luasocket-3.0rc1-1.rockspec", | ||
| 11 | "/lxsh-0.8.6-2.src.rock", | ||
| 12 | "/lxsh-0.8.6-2.rockspec" | ||
| 13 | } | ||
| 14 | |||
| 15 | expose("LuaRocks make tests #blackbox #b_make", function() | ||
| 16 | |||
| 17 | before_each(function() | ||
| 18 | test_env.setup_specs(extra_rocks) | ||
| 19 | run = test_env.run | ||
| 20 | testing_paths = test_env.testing_paths | ||
| 21 | end) | ||
| 22 | |||
| 23 | it("LuaRocks make with no flags/arguments", function() | ||
| 24 | lfs.chdir("test") | ||
| 25 | assert.is_false(run.luarocks_bool("make")) | ||
| 26 | lfs.chdir(testing_paths.luarocks_dir) | ||
| 27 | end) | ||
| 28 | |||
| 29 | it("LuaRocks make with rockspec", function() | ||
| 30 | -- make luasocket | ||
| 31 | assert.is_true(run.luarocks_bool("download --source luasocket")) | ||
| 32 | assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-1.src.rock")) | ||
| 33 | lfs.chdir("luasocket-3.0rc1-1/luasocket-3.0-rc1/") | ||
| 34 | assert.is_true(run.luarocks_bool("make luasocket-3.0rc1-1.rockspec")) | ||
| 35 | |||
| 36 | -- test it | ||
| 37 | assert.is_true(run.luarocks_bool("show luasocket")) | ||
| 38 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
| 39 | |||
| 40 | -- delete downloaded and unpacked files | ||
| 41 | lfs.chdir(testing_paths.luarocks_dir) | ||
| 42 | test_env.remove_dir("luasocket-3.0rc1-1") | ||
| 43 | assert.is_true(os.remove("luasocket-3.0rc1-1.src.rock")) | ||
| 44 | end) | ||
| 45 | |||
| 46 | describe("LuaRocks making rockspecs (using lxsh)", function() | ||
| 47 | --download lxsh and unpack it | ||
| 48 | before_each(function() | ||
| 49 | assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) | ||
| 50 | assert.is_true(run.luarocks_bool("unpack lxsh-0.8.6-2.src.rock")) | ||
| 51 | assert.is_true(lfs.chdir("lxsh-0.8.6-2/lxsh-0.8.6-1/")) | ||
| 52 | end) | ||
| 53 | |||
| 54 | -- delete downloaded and unpacked files | ||
| 55 | after_each(function() | ||
| 56 | assert.is_true(lfs.chdir(testing_paths.luarocks_dir)) | ||
| 57 | test_env.remove_dir("lxsh-0.8.6-2") | ||
| 58 | assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) | ||
| 59 | end) | ||
| 60 | |||
| 61 | it("LuaRocks make default rockspec", function() | ||
| 62 | assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec")) | ||
| 63 | assert.is_true(run.luarocks_bool("make")) | ||
| 64 | |||
| 65 | assert.is_true(run.luarocks_bool("show lxsh")) | ||
| 66 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 67 | end) | ||
| 68 | |||
| 69 | it("LuaRocks make unnamed rockspec", function() | ||
| 70 | os.execute("cp lxsh-0.8.6-2.rockspec rockspec") --rewrite with lfs | ||
| 71 | assert.is_true(run.luarocks_bool("make")) | ||
| 72 | |||
| 73 | assert.is_true(run.luarocks_bool("show lxsh")) | ||
| 74 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 75 | end) | ||
| 76 | |||
| 77 | it("LuaRocks make ambiguous rockspec", function() | ||
| 78 | assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec")) | ||
| 79 | assert.is_false(run.luarocks_bool("make")) | ||
| 80 | |||
| 81 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
| 82 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 83 | end) | ||
| 84 | |||
| 85 | it("LuaRocks make ambiguous unnamed rockspec", function() | ||
| 86 | assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "1_rockspec")) | ||
| 87 | os.execute("cp 1_rockspec 2_rockspec") --rewrite with lfs | ||
| 88 | assert.is_false(run.luarocks_bool("make")) | ||
| 89 | |||
| 90 | assert.is_false(run.luarocks_bool("show lxsh")) | ||
| 91 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) | ||
| 92 | end) | ||
| 93 | |||
| 94 | it("LuaRocks make pack binary rock", function() | ||
| 95 | assert.is_true(run.luarocks_bool("make --deps-mode=none --pack-binary-rock")) | ||
| 96 | assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) | ||
| 97 | end) | ||
| 98 | end) | ||
| 99 | end) \ No newline at end of file | ||
diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua new file mode 100644 index 00000000..57014226 --- /dev/null +++ b/spec/new_version_spec.lua | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local new_version = require("luarocks.new_version") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/abelhas-1.0-1.rockspec" | ||
| 9 | } | ||
| 10 | |||
| 11 | expose("LuaRocks new_version tests #blackbox #b_new_version", function() | ||
| 12 | |||
| 13 | before_each(function() | ||
| 14 | test_env.setup_specs(extra_rocks) | ||
| 15 | testing_paths = test_env.testing_paths | ||
| 16 | run = test_env.run | ||
| 17 | end) | ||
| 18 | |||
| 19 | describe("LuaRocks new_version basic tests", function() | ||
| 20 | it("LuaRocks new version with no flags/arguments", function() | ||
| 21 | lfs.chdir("test") | ||
| 22 | assert.is_false(run.luarocks_bool("new_version")) | ||
| 23 | lfs.chdir(testing_paths.luarocks_dir) | ||
| 24 | end) | ||
| 25 | |||
| 26 | it("LuaRocks new version invalid", function() | ||
| 27 | assert.is_false(run.luarocks_bool("new_version invalid")) | ||
| 28 | end) | ||
| 29 | end) | ||
| 30 | |||
| 31 | describe("LuaRocks new_version more complex tests", function() | ||
| 32 | it("LuaRocks new_version of luacov", function() | ||
| 33 | assert.is_true(run.luarocks_bool("download --rockspec luacov 0.11.0")) | ||
| 34 | assert.is_true(run.luarocks_bool("new_version luacov-0.11.0-1.rockspec 0.2")) | ||
| 35 | assert.is.truthy(lfs.attributes("luacov-0.2-1.rockspec")) | ||
| 36 | test_env.remove_files(lfs.currentdir(), "luacov--") | ||
| 37 | end) | ||
| 38 | |||
| 39 | it("LuaRocks new_version url of abelhas", function() | ||
| 40 | assert.is_true(run.luarocks_bool("download --rockspec abelhas 1.0")) | ||
| 41 | assert.is_true(run.luarocks_bool("new_version abelhas-1.0-1.rockspec 1.1 http://luaforge.net/frs/download.php/2658/abelhas-1.0.tar.gz")) | ||
| 42 | assert.is.truthy(lfs.attributes("abelhas-1.1-1.rockspec")) | ||
| 43 | test_env.remove_files(lfs.currentdir(), "abelhas--") | ||
| 44 | end) | ||
| 45 | |||
| 46 | it("LuaRocks new_version of luacov with tag", function() | ||
| 47 | assert.is_true(run.luarocks_bool("download --rockspec luacov 0.11.0")) | ||
| 48 | assert.is_true(run.luarocks_bool("new_version luacov-0.11.0-1.rockspec --tag v0.3")) | ||
| 49 | assert.is.truthy(lfs.attributes("luacov-0.3-1.rockspec")) | ||
| 50 | test_env.remove_files(lfs.currentdir(), "luacov--") | ||
| 51 | end) | ||
| 52 | end) | ||
| 53 | end) \ No newline at end of file | ||
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua new file mode 100644 index 00000000..a07e7ed2 --- /dev/null +++ b/spec/pack_spec.lua | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local pack = require("luarocks.pack") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/luasec-0.6-1.rockspec", | ||
| 9 | "/luasocket-3.0rc1-1.src.rock", | ||
| 10 | "/luasocket-3.0rc1-1.rockspec" | ||
| 11 | } | ||
| 12 | |||
| 13 | expose("LuaRocks pack tests #blackbox #b_pack", function() | ||
| 14 | |||
| 15 | before_each(function() | ||
| 16 | test_env.setup_specs(extra_rocks) | ||
| 17 | testing_paths = test_env.testing_paths | ||
| 18 | run = test_env.run | ||
| 19 | end) | ||
| 20 | |||
| 21 | it("LuaRocks pack basic", function() | ||
| 22 | assert.is_true(run.luarocks_bool("list")) | ||
| 23 | assert.is_true(run.luarocks_bool("pack luacov")) | ||
| 24 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov-")) | ||
| 25 | end) | ||
| 26 | |||
| 27 | it("LuaRocks pack src", function() | ||
| 28 | assert.is_true(run.luarocks_bool("install luasec")) | ||
| 29 | assert.is_true(run.luarocks_bool("download --rockspec luasocket")) | ||
| 30 | assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-1.rockspec")) | ||
| 31 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-")) | ||
| 32 | end) | ||
| 33 | end) | ||
| 34 | |||
| 35 | |||
diff --git a/spec/path_spec.lua b/spec/path_spec.lua new file mode 100644 index 00000000..266ada89 --- /dev/null +++ b/spec/path_spec.lua | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local path = require("luarocks.path") | ||
| 6 | |||
| 7 | expose("LuaRocks path tests #blackbox #b_path", function() | ||
| 8 | before_each(function() | ||
| 9 | test_env.setup_specs(extra_rocks) | ||
| 10 | run = test_env.run | ||
| 11 | end) | ||
| 12 | |||
| 13 | it("LuaRocks path bin", function() | ||
| 14 | assert.is_true(run.luarocks_bool("path --bin")) | ||
| 15 | end) | ||
| 16 | |||
| 17 | it("LuaRocks path lr-path", function() | ||
| 18 | assert.is_true(run.luarocks_bool("path --lr-path")) | ||
| 19 | end) | ||
| 20 | |||
| 21 | it("LuaRocks path lr-cpath", function() | ||
| 22 | assert.is_true(run.luarocks_bool("path --lr-cpath")) | ||
| 23 | end) | ||
| 24 | |||
| 25 | it("LuaRocks path with tree", function() | ||
| 26 | assert.is_true(run.luarocks_bool("path --tree=lua_modules")) | ||
| 27 | end) | ||
| 28 | end) | ||
diff --git a/spec/purge_spec.lua b/spec/purge_spec.lua new file mode 100644 index 00000000..639f96f3 --- /dev/null +++ b/spec/purge_spec.lua | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local purge = require("luarocks.purge") | ||
| 6 | |||
| 7 | expose("LuaRocks purge tests #blackbox #b_purge", function() | ||
| 8 | before_each(function() | ||
| 9 | test_env.setup_specs(extra_rocks) | ||
| 10 | testing_paths = test_env.testing_paths | ||
| 11 | run = test_env.run | ||
| 12 | end) | ||
| 13 | |||
| 14 | describe("LuaRocks purge basic tests", function() | ||
| 15 | it("LuaRocks purge missing tree", function() | ||
| 16 | assert.is_false(run.luarocks_bool("purge --tree=" .. testing_paths.testing_tree)) | ||
| 17 | end) | ||
| 18 | it("LuaRocks purge tree with no string", function() | ||
| 19 | assert.is_false(run.luarocks_bool("purge --tree=1")) | ||
| 20 | end) | ||
| 21 | it("LuaRocks purge tree with no string", function() | ||
| 22 | assert.is_true(run.luarocks_bool("purge --tree=" .. testing_paths.testing_sys_tree)) | ||
| 23 | end) | ||
| 24 | it("LuaRocks purge old versions tree", function() | ||
| 25 | assert.is_true(run.luarocks_bool("purge --old-versions --tree=" .. testing_paths.testing_sys_tree)) | ||
| 26 | end) | ||
| 27 | end) | ||
| 28 | end) | ||
| 29 | |||
| 30 | |||
diff --git a/spec/refresh_cache_spec.lua b/spec/refresh_cache_spec.lua new file mode 100644 index 00000000..27a95e5c --- /dev/null +++ b/spec/refresh_cache_spec.lua | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local refresh_cache = require("luarocks.refresh_cache") | ||
| 6 | |||
| 7 | expose("LuaRocks refresh_cache tests #blackbox #b_refresh_cache", function() | ||
| 8 | |||
| 9 | before_each(function() | ||
| 10 | test_env.setup_specs(extra_rocks) | ||
| 11 | run = test_env.run | ||
| 12 | end) | ||
| 13 | |||
| 14 | describe("LuaRocks-admin refresh cache tests #ssh", function() | ||
| 15 | it("LuaRocks-admin refresh cache", function() | ||
| 16 | assert.is_true(run.luarocks_admin_bool("--server=testing refresh_cache")) | ||
| 17 | end) | ||
| 18 | end) | ||
| 19 | end) \ No newline at end of file | ||
diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua new file mode 100644 index 00000000..a94673a8 --- /dev/null +++ b/spec/remove_spec.lua | |||
| @@ -0,0 +1,85 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local remove = require("luarocks.remove") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/abelhas-1.0-1.rockspec", | ||
| 9 | "/lualogging-1.3.0-1.src.rock", | ||
| 10 | "/luasocket-3.0rc1-1.src.rock", | ||
| 11 | "/luasocket-3.0rc1-1.rockspec" | ||
| 12 | } | ||
| 13 | |||
| 14 | expose("LuaRocks remove tests #blackbox #b_remove", function() | ||
| 15 | |||
| 16 | before_each(function() | ||
| 17 | test_env.setup_specs(extra_rocks) | ||
| 18 | testing_paths = test_env.testing_paths | ||
| 19 | run = test_env.run | ||
| 20 | end) | ||
| 21 | |||
| 22 | describe("LuaRocks remove basic tests", function() | ||
| 23 | it("LuaRocks remove with no flags/arguments", function() | ||
| 24 | assert.is_false(run.luarocks_bool("remove")) | ||
| 25 | end) | ||
| 26 | |||
| 27 | it("LuaRocks remove invalid rock", function() | ||
| 28 | assert.is_false(run.luarocks_bool("remove invalid.rock")) | ||
| 29 | end) | ||
| 30 | |||
| 31 | it("LuaRocks remove missing rock", function() | ||
| 32 | assert.is_false(run.luarocks_bool("remove missing_rock")) | ||
| 33 | end) | ||
| 34 | |||
| 35 | it("LuaRocks remove invalid argument", function() | ||
| 36 | assert.is_false(run.luarocks_bool("remove luacov --deps-mode")) | ||
| 37 | end) | ||
| 38 | |||
| 39 | it("LuaRocks remove builded abelhas", function() | ||
| 40 | assert.is_true(run.luarocks_bool("build abelhas 1.0")) | ||
| 41 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/abelhas")) | ||
| 42 | assert.is_true(run.luarocks_bool("remove abelhas 1.0")) | ||
| 43 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/abelhas")) | ||
| 44 | end) | ||
| 45 | end) | ||
| 46 | |||
| 47 | describe("LuaRocks remove more complex tests", function() | ||
| 48 | it("LuaRocks remove fail, break dependencies", function() | ||
| 49 | assert.is_true(test_env.need_luasocket()) | ||
| 50 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
| 51 | assert.is_true(run.luarocks_bool("build lualogging")) | ||
| 52 | |||
| 53 | assert.is_false(run.luarocks_bool("remove luasocket")) | ||
| 54 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
| 55 | end) | ||
| 56 | |||
| 57 | it("LuaRocks remove force", function() | ||
| 58 | assert.is_true(test_env.need_luasocket()) | ||
| 59 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
| 60 | assert.is_true(run.luarocks_bool("build lualogging")) | ||
| 61 | |||
| 62 | local output = run.luarocks("remove --force luasocket") | ||
| 63 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
| 64 | assert.is.truthy(output:find("Checking stability of dependencies")) | ||
| 65 | end) | ||
| 66 | |||
| 67 | it("LuaRocks remove force fast", function() | ||
| 68 | assert.is_true(test_env.need_luasocket()) | ||
| 69 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
| 70 | assert.is_true(run.luarocks_bool("build lualogging")) | ||
| 71 | |||
| 72 | local output = run.luarocks("remove --force-fast luasocket") | ||
| 73 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) | ||
| 74 | assert.is.falsy(output:find("Checking stability of dependencies")) | ||
| 75 | end) | ||
| 76 | end) | ||
| 77 | |||
| 78 | it("LuaRocks-admin remove #ssh", function() | ||
| 79 | assert.is_true(run.luarocks_admin_bool("--server=testing remove luasocket-3.0rc1-1.src.rock")) | ||
| 80 | end) | ||
| 81 | |||
| 82 | it("LuaRocks-admin remove missing", function() | ||
| 83 | assert.is_false(run.luarocks_admin_bool("--server=testing remove")) | ||
| 84 | end) | ||
| 85 | end) \ No newline at end of file | ||
diff --git a/spec/search_spec.lua b/spec/search_spec.lua new file mode 100644 index 00000000..a0258942 --- /dev/null +++ b/spec/search_spec.lua | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local search = require("luarocks.search") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/lzlib-0.4.1.53-1.src.rock" | ||
| 9 | } | ||
| 10 | |||
| 11 | expose("LuaRocks search tests #blackbox #b_search", function() | ||
| 12 | |||
| 13 | before_each(function() | ||
| 14 | test_env.setup_specs(extra_rocks) | ||
| 15 | run = test_env.run | ||
| 16 | end) | ||
| 17 | |||
| 18 | it("LuaRocks search with no flags/arguments", function() | ||
| 19 | assert.is_false(run.luarocks_bool("search")) | ||
| 20 | end) | ||
| 21 | |||
| 22 | it("LuaRocks search zlib", function() | ||
| 23 | assert.is_true(run.luarocks_bool("search zlib")) | ||
| 24 | end) | ||
| 25 | |||
| 26 | it("LuaRocks search zlib 1.1", function() | ||
| 27 | assert.is_true(run.luarocks_bool("search zlib 1.1")) | ||
| 28 | end) | ||
| 29 | |||
| 30 | it("LuaRocks search missing rock", function() | ||
| 31 | assert.is_true(run.luarocks_bool("search missing_rock")) | ||
| 32 | end) | ||
| 33 | |||
| 34 | it("LuaRocks search with flag all", function() | ||
| 35 | assert.is_true(run.luarocks_bool("search --all")) | ||
| 36 | end) | ||
| 37 | |||
| 38 | it("LuaRocks search zlib", function() | ||
| 39 | local num = 123 | ||
| 40 | assert.is_true(run.luarocks_bool("search " .. num)) | ||
| 41 | end) | ||
| 42 | end) \ No newline at end of file | ||
diff --git a/spec/show_spec.lua b/spec/show_spec.lua new file mode 100644 index 00000000..85797eb6 --- /dev/null +++ b/spec/show_spec.lua | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local show = require("luarocks.show") | ||
| 6 | |||
| 7 | expose("LuaRocks show tests #blackbox #b_show", function() | ||
| 8 | |||
| 9 | before_each(function() | ||
| 10 | test_env.setup_specs(extra_rocks) | ||
| 11 | run = test_env.run | ||
| 12 | end) | ||
| 13 | |||
| 14 | it("LuaRocks show with no flags/arguments", function() | ||
| 15 | assert.is_false(run.luarocks_bool("show")) | ||
| 16 | end) | ||
| 17 | |||
| 18 | describe("LuaRocks show basic tests with flags", function() | ||
| 19 | it("LuaRocks show invalid", function() | ||
| 20 | assert.is_false(run.luarocks_bool("show invalid")) | ||
| 21 | end) | ||
| 22 | |||
| 23 | it("LuaRocks show luacov", function() | ||
| 24 | local output = run.luarocks("show luacov") | ||
| 25 | end) | ||
| 26 | |||
| 27 | it("LuaRocks show modules of luacov", function() | ||
| 28 | local output = run.luarocks("show --modules luacov") | ||
| 29 | end) | ||
| 30 | |||
| 31 | it("LuaRocks show dependencies of luacov", function() | ||
| 32 | local output = run.luarocks("show --deps luacov") | ||
| 33 | end) | ||
| 34 | |||
| 35 | it("LuaRocks show rockspec of luacov", function() | ||
| 36 | local output = run.luarocks("show --rockspec luacov") | ||
| 37 | end) | ||
| 38 | |||
| 39 | it("LuaRocks show mversion of luacov", function() | ||
| 40 | local output = run.luarocks("show --mversion luacov") | ||
| 41 | end) | ||
| 42 | |||
| 43 | it("LuaRocks show rock tree of luacov", function() | ||
| 44 | local output = run.luarocks("show --rock-tree luacov") | ||
| 45 | end) | ||
| 46 | |||
| 47 | it("LuaRocks show rock directory of luacov", function() | ||
| 48 | local output = run.luarocks("show --rock-dir luacov") | ||
| 49 | end) | ||
| 50 | end) | ||
| 51 | |||
| 52 | it("LuaRocks show old version of luacov", function() | ||
| 53 | run.luarocks("install luacov 0.11.0") | ||
| 54 | run.luarocks("show luacov 0.11.0") | ||
| 55 | end) | ||
| 56 | end) | ||
diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua new file mode 100644 index 00000000..efe902f5 --- /dev/null +++ b/spec/unpack_spec.lua | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local unpack = require("luarocks.unpack") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/cprint-0.1-2.src.rock", | ||
| 9 | "/cprint-0.1-2.rockspec" | ||
| 10 | } | ||
| 11 | |||
| 12 | expose("LuaRocks unpack tests #blackbox #b_unpack", function() | ||
| 13 | |||
| 14 | before_each(function() | ||
| 15 | test_env.setup_specs(extra_rocks) | ||
| 16 | testing_paths = test_env.testing_paths | ||
| 17 | run = test_env.run | ||
| 18 | platform = test_env.platform | ||
| 19 | end) | ||
| 20 | |||
| 21 | describe("LuaRocks unpack basic fail tests", function() | ||
| 22 | it("LuaRocks unpack with no flags/arguments", function() | ||
| 23 | assert.is_false(run.luarocks_bool("unpack")) | ||
| 24 | end) | ||
| 25 | it("LuaRocks unpack with invalid rockspec", function() | ||
| 26 | assert.is_false(run.luarocks_bool("unpack invalid.rockspec")) | ||
| 27 | end) | ||
| 28 | it("LuaRocks unpack with invalid patch", function() | ||
| 29 | assert.is_false(run.luarocks_bool("unpack " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) | ||
| 30 | end) | ||
| 31 | end) | ||
| 32 | |||
| 33 | describe("LuaRocks unpack more complex tests", function() | ||
| 34 | it("LuaRocks unpack download", function() | ||
| 35 | assert.is_true(run.luarocks_bool("unpack cprint")) | ||
| 36 | test_env.remove_dir("cprint-0.1-2") | ||
| 37 | end) | ||
| 38 | it("LuaRocks unpack src", function() | ||
| 39 | assert.is_true(run.luarocks_bool("download --source cprint")) | ||
| 40 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock")) | ||
| 41 | os.remove("cprint-0.1-2.src.rock") | ||
| 42 | test_env.remove_dir("cprint-0.1-2") | ||
| 43 | end) | ||
| 44 | it("LuaRocks unpack src", function() | ||
| 45 | assert.is_true(run.luarocks_bool("download --rockspec cprint")) | ||
| 46 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec")) | ||
| 47 | os.remove("cprint-0.1-2.rockspec") | ||
| 48 | os.remove("lua-cprint") | ||
| 49 | test_env.remove_dir("cprint-0.1-2") | ||
| 50 | end) | ||
| 51 | it("LuaRocks unpack binary", function() | ||
| 52 | assert.is_true(run.luarocks_bool("build cprint")) | ||
| 53 | assert.is_true(run.luarocks_bool("pack cprint")) | ||
| 54 | assert.is_true(run.luarocks_bool("unpack cprint-0.1-2." .. platform .. ".rock")) | ||
| 55 | test_env.remove_dir("cprint-0.1-2") | ||
| 56 | os.remove("cprint-0.1-2." .. platform .. ".rock") | ||
| 57 | end) | ||
| 58 | end) | ||
| 59 | end) | ||
| 60 | |||
| 61 | |||
diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua new file mode 100644 index 00000000..daf40d61 --- /dev/null +++ b/spec/upload_spec.lua | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local upload = require("luarocks.upload") | ||
| 6 | |||
| 7 | local extra_rocks = { | ||
| 8 | "/lua-cjson-2.1.0-1.src.rock" | ||
| 9 | } | ||
| 10 | |||
| 11 | expose("LuaRocks upload tests #blackbox #b_upload", function() | ||
| 12 | |||
| 13 | before_each(function() | ||
| 14 | test_env.setup_specs(extra_rocks) | ||
| 15 | run = test_env.run | ||
| 16 | end) | ||
| 17 | |||
| 18 | it("LuaRocks upload with no flags/arguments", function() | ||
| 19 | assert.is_false(run.luarocks_bool("upload")) | ||
| 20 | end) | ||
| 21 | |||
| 22 | it("LuaRocks upload invalid rockspec", function() | ||
| 23 | assert.is_false(run.luarocks_bool("upload invalid.rockspec")) | ||
| 24 | end) | ||
| 25 | |||
| 26 | it("LuaRocks upload api key invalid", function() | ||
| 27 | assert.is_false(run.luarocks_bool("upload --api-key=invalid invalid.rockspec")) | ||
| 28 | end) | ||
| 29 | |||
| 30 | it("LuaRocks upload api key invalid and skip-pack", function() | ||
| 31 | assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack luacov-0.11.0-1.rockspec")) | ||
| 32 | end) | ||
| 33 | |||
| 34 | it("LuaRocks upload force", function() | ||
| 35 | assert.is_true(run.luarocks_bool("install lua-cjson")) | ||
| 36 | assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force luacov-0.11.0-1.rockspec")) | ||
| 37 | assert.is_true(run.luarocks_bool("install lua-cjson")) | ||
| 38 | end) | ||
| 39 | end) | ||
| 40 | |||
| 41 | |||
diff --git a/spec/util_spec.lua b/spec/util_spec.lua new file mode 100644 index 00000000..7c22d1cb --- /dev/null +++ b/spec/util_spec.lua | |||
| @@ -0,0 +1,96 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | expose("Basic tests #blackbox #b_util", function() | ||
| 5 | |||
| 6 | before_each(function() | ||
| 7 | test_env.setup_specs(extra_rocks) | ||
| 8 | testing_paths = test_env.testing_paths | ||
| 9 | env_variables = test_env.env_variables | ||
| 10 | run = test_env.run | ||
| 11 | end) | ||
| 12 | |||
| 13 | it("LuaRocks version", function() | ||
| 14 | assert.is_true(run.luarocks_bool("--version")) | ||
| 15 | end) | ||
| 16 | |||
| 17 | it("LuaRocks unknown command", function() | ||
| 18 | assert.is_false(run.luarocks_bool("unknown_command")) | ||
| 19 | end) | ||
| 20 | |||
| 21 | it("LuaRocks arguments fail", function() | ||
| 22 | assert.is_false(run.luarocks_bool("--porcelain=invalid")) | ||
| 23 | assert.is_false(run.luarocks_bool("--invalid-flag")) | ||
| 24 | assert.is_false(run.luarocks_bool("--server")) | ||
| 25 | assert.is_false(run.luarocks_bool("--server --porcelain")) | ||
| 26 | assert.is_false(run.luarocks_bool("--invalid-flag=abc")) | ||
| 27 | assert.is_false(run.luarocks_bool("invalid=5")) | ||
| 28 | end) | ||
| 29 | |||
| 30 | it("LuaRocks execute from not existing directory", function() | ||
| 31 | local main_path = lfs.currentdir() | ||
| 32 | assert.is_true(lfs.mkdir("idontexist")) | ||
| 33 | assert.is_true(lfs.chdir("idontexist")) | ||
| 34 | local delete_path = lfs.currentdir() | ||
| 35 | assert.is_true(os.remove(delete_path)) | ||
| 36 | |||
| 37 | assert.is_false(run.luarocks_bool(" ")) | ||
| 38 | assert.is_true(lfs.chdir(main_path)) | ||
| 39 | assert.is_true(run.luarocks_bool(" ")) | ||
| 40 | end) | ||
| 41 | |||
| 42 | it("LuaRocks timeout", function() | ||
| 43 | assert.is_true(run.luarocks_bool("--timeout=10")) | ||
| 44 | end) | ||
| 45 | |||
| 46 | it("LuaRocks timeout invalid", function() | ||
| 47 | assert.is_false(run.luarocks_bool("--timeout=abc")) | ||
| 48 | end) | ||
| 49 | |||
| 50 | it("LuaRocks only server=testing", function() | ||
| 51 | assert.is_true(run.luarocks_bool("--only-server=testing")) | ||
| 52 | end) | ||
| 53 | |||
| 54 | it("LuaRocks test site config", function() | ||
| 55 | assert.is.truthy(os.rename("src/luarocks/site_config.lua", "src/luarocks/site_config.lua.tmp")) | ||
| 56 | assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua")) | ||
| 57 | assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua.tmp")) | ||
| 58 | |||
| 59 | assert.is_true(run.luarocks_bool("")) | ||
| 60 | |||
| 61 | assert.is.truthy(os.rename("src/luarocks/site_config.lua.tmp", "src/luarocks/site_config.lua")) | ||
| 62 | assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua.tmp")) | ||
| 63 | assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua")) | ||
| 64 | end) | ||
| 65 | |||
| 66 | describe("LuaRocks sysconfig fails", function() | ||
| 67 | local scdir = "" | ||
| 68 | |||
| 69 | before_each(function() | ||
| 70 | scdir = testing_paths.testing_lrprefix .. "/etc/luarocks/" | ||
| 71 | lfs.mkdir(testing_paths.testing_lrprefix) | ||
| 72 | lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") | ||
| 73 | lfs.mkdir(scdir) | ||
| 74 | end) | ||
| 75 | |||
| 76 | after_each(function() | ||
| 77 | test_env.remove_dir(testing_paths.testing_lrprefix) | ||
| 78 | end) | ||
| 79 | |||
| 80 | it("LuaRocks sysconfig fail", function() | ||
| 81 | local sysconfig = io.open(scdir .. "/config.lua", "w+") | ||
| 82 | sysconfig:write("aoeui") | ||
| 83 | sysconfig:close() | ||
| 84 | |||
| 85 | assert.is_false(run.luarocks_bool("list")) | ||
| 86 | end) | ||
| 87 | |||
| 88 | it("LuaRocks sysconfig fail", function() | ||
| 89 | local sysconfig = io.open(scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua", "w+") | ||
| 90 | sysconfig:write("aoeui") | ||
| 91 | sysconfig:close() | ||
| 92 | |||
| 93 | assert.is_false(run.luarocks_bool("list")) | ||
| 94 | end) | ||
| 95 | end) | ||
| 96 | end) | ||
diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua new file mode 100644 index 00000000..d6e32f15 --- /dev/null +++ b/spec/write_rockspec_spec.lua | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | local test_env = require("test/test_environment") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | |||
| 4 | test_env.unload_luarocks() | ||
| 5 | local write_rockspec = require("luarocks.write_rockspec") | ||
| 6 | |||
| 7 | expose("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() | ||
| 8 | |||
| 9 | before_each(function() | ||
| 10 | test_env.setup_specs(extra_rocks) | ||
| 11 | run = test_env.run | ||
| 12 | end) | ||
| 13 | |||
| 14 | describe("LuaRocks write_rockspec basic tests", function() | ||
| 15 | it("LuaRocks write_rockspec with no flags/arguments", function() | ||
| 16 | assert.is_true(run.luarocks_bool("write_rockspec")) | ||
| 17 | os.remove("luarocks-scm-1.rockspec") | ||
| 18 | end) | ||
| 19 | |||
| 20 | it("LuaRocks write_rockspec with invalid argument", function() | ||
| 21 | assert.is_false(run.luarocks_bool("write_rockspec invalid")) | ||
| 22 | end) | ||
| 23 | |||
| 24 | it("LuaRocks write_rockspec invalid zip", function() | ||
| 25 | assert.is_false(run.luarocks_bool("write_rockspec http://example.com/invalid.zip")) | ||
| 26 | end) | ||
| 27 | end) | ||
| 28 | |||
| 29 | describe("LuaRocks write_rockspec more complex tests", function() | ||
| 30 | it("LuaRocks write_rockspec git luarocks", function() | ||
| 31 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/keplerproject/luarocks")) | ||
| 32 | assert.is.truthy(lfs.attributes("luarocks-scm-1.rockspec")) | ||
| 33 | assert.is_true(os.remove("luarocks-scm-1.rockspec")) | ||
| 34 | end) | ||
| 35 | |||
| 36 | it("LuaRocks write_rockspec git luarocks --tag=v2.3.0", function() | ||
| 37 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/keplerproject/luarocks --tag=v2.3.0")) | ||
| 38 | assert.is.truthy(lfs.attributes("luarocks-2.3.0-1.rockspec")) | ||
| 39 | assert.is_true(os.remove("luarocks-2.3.0-1.rockspec")) | ||
| 40 | end) | ||
| 41 | |||
| 42 | it("LuaRocks write_rockspec git luarocks with format flag", function() | ||
| 43 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luarocks --rockspec-format=1.1 --lua-version=5.1,5.2")) | ||
| 44 | assert.is.truthy(lfs.attributes("luarocks-scm-1.rockspec")) | ||
| 45 | assert.is_true(os.remove("luarocks-scm-1.rockspec")) | ||
| 46 | end) | ||
| 47 | |||
| 48 | it("LuaRocks write_rockspec git luarocks with full flags", function() | ||
| 49 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luarocks --lua-version=5.1,5.2 --license=\"MIT/X11\" " | ||
| 50 | .. " --homepage=\"http://www.luarocks.org\" --summary=\"A package manager for Lua modules\" ")) | ||
| 51 | assert.is.truthy(lfs.attributes("luarocks-scm-1.rockspec")) | ||
| 52 | assert.is_true(os.remove("luarocks-scm-1.rockspec")) | ||
| 53 | end) | ||
| 54 | |||
| 55 | it("LuaRocks write_rockspec rockspec via http", function() | ||
| 56 | assert.is_true(run.luarocks_bool("write_rockspec http://luarocks.org/releases/luarocks-2.1.0.tar.gz --lua-version=5.1")) | ||
| 57 | assert.is.truthy(lfs.attributes("luarocks-2.1.0-1.rockspec")) | ||
| 58 | assert.is_true(os.remove("luarocks-2.1.0-1.rockspec")) | ||
| 59 | end) | ||
| 60 | |||
| 61 | it("LuaRocks write_rockspec base dir, luassert.tar.gz via https", function() | ||
| 62 | assert.is_true(run.luarocks_bool("write_rockspec https://github.com/downloads/Olivine-Labs/luassert/luassert-1.2.tar.gz --lua-version=5.1")) | ||
| 63 | assert.is.truthy(lfs.attributes("luassert-1.2-1.rockspec")) | ||
| 64 | assert.is_true(os.remove("luassert-1.2-1.rockspec")) | ||
| 65 | end) | ||
| 66 | |||
| 67 | it("LuaRocks write_rockspec git luafcgi with many flags", function() | ||
| 68 | assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license=\"3-clause BSD\" " | ||
| 69 | .. "--lua-version=5.1,5.2")) | ||
| 70 | assert.is.truthy(lfs.attributes("luafcgi-scm-1.rockspec")) -- TODO maybe read it content and find arguments from flags? | ||
| 71 | assert.is_true(os.remove("luafcgi-scm-1.rockspec")) | ||
| 72 | end) | ||
| 73 | end) | ||
| 74 | end) \ No newline at end of file | ||
diff --git a/test/README.md b/test/README.md new file mode 100644 index 00000000..c374438f --- /dev/null +++ b/test/README.md | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | #LuaRocks testsuite | ||
| 2 | ##Overview | ||
| 3 | Test suite for LuaRocks project with Busted unit testing framework(http://olivinelabs.com/busted/). | ||
| 4 | |||
| 5 | * Contains white-box & black-box tests | ||
| 6 | * Easy setup for your purpose on command line or from configuration file | ||
| 7 | |||
| 8 | |||
| 9 | ## Dependencies | ||
| 10 | * Lua >= 5.1 | ||
| 11 | * Busted with dependencies | ||
| 12 | |||
| 13 | |||
| 14 | ##Usage | ||
| 15 | Running of tests is based on basic Busted usage. *-Xhelper* flag is mandatory for inserting arguments into testing (primary black-box). Flag *--tags=* or *-t* is mandatory for specifying which tests will run. Mandatory *-Xhelper* flag always needs version of Lua or LuaJIT (e.g. *lua=5.2.4* or *luajit=2.0.3*). Start tests inside LuaRocks folder or specify with *-C* flag. | ||
| 16 | |||
| 17 | **Arguments for Busted helper script** | ||
| 18 | |||
| 19 | ``` | ||
| 20 | lua=<version>, !mandatory! type your full version of Lua (e.g. lua=5.2.4) | ||
| 21 | OR | ||
| 22 | luajit=<version>, !mandatory! type your full version of LuaJIT (e.g. luajit=5.2.4) | ||
| 23 | |||
| 24 | env=<type>, (default:"minimal") type what kind of environment to use ["minimal", "full"] | ||
| 25 | clean, remove existing testing environment | ||
| 26 | travis, add just if running on TravisCI | ||
| 27 | os=<version>, type your OS ["linux", "os x", "windows"] | ||
| 28 | ``` | ||
| 29 | --------------------------------------------------------------------------------------------- | ||
| 30 | ####_**Tags** of tests are required and are in this format:_ | ||
| 31 | |||
| 32 | **whitebox** - run all whitebox tests | ||
| 33 | |||
| 34 | **blackbox** - run all blackbox tests | ||
| 35 | |||
| 36 | **ssh** - run all tests which require ssh | ||
| 37 | |||
| 38 | **w**\_*name-of-command* - whitebox testing of command | ||
| 39 | |||
| 40 | **b**\_*name-of-command* - blackbox testing of command | ||
| 41 | |||
| 42 | for example: `b_install` or `w_help` | ||
| 43 | |||
| 44 | ###Examples | ||
| 45 | To run white-box tests in LuaRocks directory type : | ||
| 46 | |||
| 47 | `busted -t "whitebox"` | ||
| 48 | |||
| 49 | To run black-box tests just of *install* command (we defined our OS, so OS check is skipped.): | ||
| 50 | |||
| 51 | `busted -Xhelper lua=5.2.4,os=linux -t "b_install"` | ||
| 52 | |||
| 53 | To run black-box tests of *install* command, whitebox of *help* command (using *full* type of environment): | ||
| 54 | |||
| 55 | `busted -Xhelper lua=5.2.4,env=full -t "b_install", "w_help"` | ||
| 56 | |||
| 57 | To run black-box tests without tests, which use ssh: | ||
| 58 | |||
| 59 | `busted -Xhelper lua=5.2.4 -t "blackbox" --exclude-tags=ssh` \ No newline at end of file | ||
diff --git a/test/test_environment.lua b/test/test_environment.lua new file mode 100644 index 00000000..6de501fb --- /dev/null +++ b/test/test_environment.lua | |||
| @@ -0,0 +1,625 @@ | |||
| 1 | local lfs = require("lfs") | ||
| 2 | local test_env = {} | ||
| 3 | local arg = arg or { ... } | ||
| 4 | |||
| 5 | local function help() | ||
| 6 | print("LuaRocks test-suite\n\n".. | ||
| 7 | [[ | ||
| 8 | INFORMATION | ||
| 9 | New test-suite for LuaRocks project, using unit testing framework Busted. | ||
| 10 | REQUIREMENTS | ||
| 11 | Tests require to have Lua installed and added to PATH. Be sure sshd is runnig on your system, or | ||
| 12 | use '--exclude-tags=ssh', to not execute tests which require sshd. | ||
| 13 | USAGE -Xhelper <arguments> | ||
| 14 | lua=<version> (mandatory) type your full version of Lua (e.g. --lua 5.2.4) | ||
| 15 | OR | ||
| 16 | luajit=<version> (mandatory) type your full version of LuaJIT (e.g. --luajit 2.0.3) | ||
| 17 | |||
| 18 | env=<type> (default:"minimal") type what kind of environment to use ["minimal", "full"] | ||
| 19 | clean remove existing testing environment | ||
| 20 | travis add just if running on TravisCI | ||
| 21 | os=<version> type your OS ["linux", "osx", "windows"] | ||
| 22 | ]]); | ||
| 23 | os.exit(1) | ||
| 24 | end | ||
| 25 | |||
| 26 | --- Helper function for execute_bool and execute_output | ||
| 27 | -- @param command string: command to execute | ||
| 28 | -- @param print_command boolean: print command if 'true' | ||
| 29 | -- @param env_variables table: table of environment variables to export {FOO="bar", BAR="foo"} | ||
| 30 | -- @return final_command string: concatenated command to execution | ||
| 31 | local function execute_helper(command, print_command, env_variables) | ||
| 32 | local final_command = "" | ||
| 33 | |||
| 34 | if print_command then | ||
| 35 | print("\n[EXECUTING]: " .. command) | ||
| 36 | end | ||
| 37 | |||
| 38 | if env_variables then | ||
| 39 | final_command = "export " | ||
| 40 | for k,v in pairs(env_variables) do | ||
| 41 | final_command = final_command .. k .. "='" .. v .. "' " | ||
| 42 | end | ||
| 43 | -- remove last space and add ';' to separate exporting variables from command | ||
| 44 | final_command = final_command:sub(1, -2) .. "; " | ||
| 45 | end | ||
| 46 | |||
| 47 | final_command = final_command .. command | ||
| 48 | |||
| 49 | return final_command | ||
| 50 | end | ||
| 51 | |||
| 52 | --- Execute command and returns true/false | ||
| 53 | -- In Lua5.1 os.execute returns numeric value, but in Lua5.2+ returns boolean | ||
| 54 | -- @return true/false boolean: status of the command execution | ||
| 55 | local function execute_bool(command, print_command, env_variables) | ||
| 56 | command = execute_helper(command, print_command, env_variables) | ||
| 57 | |||
| 58 | local ok = os.execute(command) | ||
| 59 | return ok == true or ok == 0 | ||
| 60 | end | ||
| 61 | |||
| 62 | --- Execute command and returns output of command | ||
| 63 | -- @return output string: output the command execution | ||
| 64 | local function execute_output(command, print_command, env_variables) | ||
| 65 | command = execute_helper(command, print_command, env_variables) | ||
| 66 | |||
| 67 | local file = assert(io.popen(command)) | ||
| 68 | local output = file:read('*all') | ||
| 69 | file:close() | ||
| 70 | return output:gsub("\n","") -- output adding new line, need to be removed | ||
| 71 | end | ||
| 72 | |||
| 73 | --- Set all arguments from input into global variables | ||
| 74 | function test_env.set_args() | ||
| 75 | if arg[1] == nil then | ||
| 76 | help() | ||
| 77 | end | ||
| 78 | |||
| 79 | local args_position | ||
| 80 | |||
| 81 | for i=1, #arg do | ||
| 82 | if arg[i]:find("-Xhelper") and arg[i+1]:find("lua=") and not arg[i+1]:find("luajit=") then | ||
| 83 | args_position = i+1 | ||
| 84 | test_env.LUA_V = arg[args_position]:gsub("(.*)lua=([^%,]+)(.*)","%2") | ||
| 85 | break | ||
| 86 | elseif arg[i]:find("-Xhelper") and not arg[i+1]:find("lua=") and arg[i+1]:find("luajit=") then | ||
| 87 | args_position = i+1 | ||
| 88 | test_env.LUAJIT_V = arg[args_position]:gsub("(.*)luajit=([^%,]+)(.*)","%2") | ||
| 89 | break | ||
| 90 | elseif arg[i]:find("-Xhelper") and arg[i+1]:find("lua=") and arg[i+1]:find("luajit=") then | ||
| 91 | print("Please specify just Lua or LuaJIT version for testing in format 'lua=X.X.X' or 'luajit=X.X.X', for -Xhelper flag") | ||
| 92 | os.exit(1) | ||
| 93 | elseif arg[i]:find("-Xhelper") and not arg[i+1]:find("lua=") and not arg[i+1]:find("luajit=") then | ||
| 94 | print("Please add mandatory argument - version of Lua or LuaJIT in format 'lua=X.X.X' or 'luajit=X.X.X', for -Xhelper flag") | ||
| 95 | os.exit(1) | ||
| 96 | end | ||
| 97 | end | ||
| 98 | |||
| 99 | if not args_position then | ||
| 100 | help() | ||
| 101 | end | ||
| 102 | |||
| 103 | -- if at least Lua/LuaJIT version argument was found on input start to parse other arguments to env. variables | ||
| 104 | test_env.TYPE_TEST_ENV = "minimal" | ||
| 105 | |||
| 106 | if arg[args_position]:find("env=") then | ||
| 107 | test_env.TYPE_TEST_ENV = arg[args_position]:gsub("(.*)env=([^%,]+)(.*)","%2") | ||
| 108 | end | ||
| 109 | if arg[args_position]:find("clean") then | ||
| 110 | test_env.TEST_ENV_CLEAN = true | ||
| 111 | end | ||
| 112 | if arg[args_position]:find("travis") then | ||
| 113 | test_env.TRAVIS = true | ||
| 114 | end | ||
| 115 | if arg[args_position]:find("os=") then | ||
| 116 | test_env.TEST_TARGET_OS = arg[args_position]:gsub("(.*)os=([^%,]+)(.*)","%2") | ||
| 117 | end | ||
| 118 | |||
| 119 | if not test_env.TEST_TARGET_OS then | ||
| 120 | print("[OS CHECK]") | ||
| 121 | if execute_bool("sw_vers") then | ||
| 122 | test_env.TEST_TARGET_OS = "osx" | ||
| 123 | elseif execute_bool("uname -s") then | ||
| 124 | test_env.TEST_TARGET_OS = "linux" | ||
| 125 | else | ||
| 126 | test_env.TEST_TARGET_OS = "windows" | ||
| 127 | end | ||
| 128 | print("--------------") | ||
| 129 | end | ||
| 130 | return true | ||
| 131 | end | ||
| 132 | |||
| 133 | --- Remove directory recursively | ||
| 134 | -- @param path string: directory path to delete | ||
| 135 | function test_env.remove_dir(path) | ||
| 136 | if lfs.attributes(path) then | ||
| 137 | for file in lfs.dir(path) do | ||
| 138 | if file ~= "." and file ~= ".." then | ||
| 139 | local full_path = path..'/'..file | ||
| 140 | local attr = lfs.attributes(full_path) | ||
| 141 | |||
| 142 | if attr.mode == "directory" then | ||
| 143 | test_env.remove_dir(full_path) | ||
| 144 | os.remove(full_path) | ||
| 145 | else | ||
| 146 | os.remove(full_path) | ||
| 147 | end | ||
| 148 | end | ||
| 149 | end | ||
| 150 | end | ||
| 151 | os.remove(path) | ||
| 152 | end | ||
| 153 | |||
| 154 | --- Remove directory recursively | ||
| 155 | -- @param path string: directory path to delete | ||
| 156 | -- @param pattern string: pattern in directories | ||
| 157 | function test_env.remove_dir_pattern(path, pattern) | ||
| 158 | if lfs.attributes(path) then | ||
| 159 | for file in lfs.dir(path) do | ||
| 160 | if file ~= "." and file ~= ".." then | ||
| 161 | local full_path = path..'/'..file | ||
| 162 | local attr = lfs.attributes(full_path) | ||
| 163 | |||
| 164 | if attr.mode == "directory" and file:find(pattern) then | ||
| 165 | test_env.remove_dir(full_path) | ||
| 166 | os.remove(full_path) | ||
| 167 | end | ||
| 168 | end | ||
| 169 | end | ||
| 170 | end | ||
| 171 | end | ||
| 172 | |||
| 173 | --- Remove files based on filename | ||
| 174 | -- @param path string: directory where to delete files | ||
| 175 | -- @param pattern string: pattern in filenames | ||
| 176 | -- @return result_check boolean: true if one or more files deleted | ||
| 177 | function test_env.remove_files(path, pattern) | ||
| 178 | local result_check = false | ||
| 179 | if lfs.attributes(path) then | ||
| 180 | for file in lfs.dir(path) do | ||
| 181 | if file ~= "." and file ~= ".." then | ||
| 182 | if file:find(pattern) then | ||
| 183 | if os.remove(path .. "/" .. file) then | ||
| 184 | result_check = true | ||
| 185 | end | ||
| 186 | end | ||
| 187 | end | ||
| 188 | end | ||
| 189 | end | ||
| 190 | return result_check | ||
| 191 | end | ||
| 192 | |||
| 193 | |||
| 194 | --- Function for downloading rocks and rockspecs | ||
| 195 | -- @param rocks table: table with full name of rocks/rockspecs to download | ||
| 196 | -- @param save_path string: path to directory, where to download rocks/rockspecs | ||
| 197 | -- @return make_manifest boolean: true if new rocks downloaded | ||
| 198 | local function download_rocks(rocks, save_path) | ||
| 199 | local luarocks_repo = "https://luarocks.org" | ||
| 200 | local make_manifest = false | ||
| 201 | |||
| 202 | for _,rock in ipairs(rocks) do | ||
| 203 | -- check if already downloaded | ||
| 204 | if not os.rename( save_path .. rock, save_path .. rock) then | ||
| 205 | execute_bool("wget -cP " .. save_path .. " " .. luarocks_repo .. rock) | ||
| 206 | make_manifest = true | ||
| 207 | end | ||
| 208 | end | ||
| 209 | return make_manifest | ||
| 210 | end | ||
| 211 | |||
| 212 | --- Create config files for testing | ||
| 213 | -- @param config_path string: path where to save config file | ||
| 214 | -- @param config_content string: content of this config file | ||
| 215 | local function create_config(config_path, config_content) | ||
| 216 | local file, err = io.open(config_path, "w+") | ||
| 217 | if not file then return nil, err end | ||
| 218 | file:write(config_content) | ||
| 219 | file:close() | ||
| 220 | end | ||
| 221 | |||
| 222 | --- Create md5sum of directory structure recursively, based on filename and size | ||
| 223 | -- @param path string: path to directory for generate md5sum | ||
| 224 | -- @param testing_os string(optional): version of PC OS | ||
| 225 | -- @return md5sum string: md5sum of directory | ||
| 226 | local function hash_environment(path, testing_os) | ||
| 227 | local md5sum = "" | ||
| 228 | testing_os = testing_os or test_env.TEST_TARGET_OS | ||
| 229 | |||
| 230 | if testing_os == "linux" then | ||
| 231 | md5sum = execute_output("find " .. path .. " -printf \"%s %p\n\" | md5sum") | ||
| 232 | end | ||
| 233 | if testing_os == "osx" then | ||
| 234 | md5sum = execute_output("find " .. path .. " -type f -exec stat -f \"%z %N\" {} \\; | md5") | ||
| 235 | end | ||
| 236 | --TODO if testing_os == "windows" then | ||
| 237 | -- md5sum = execute_output("find . -printf \"%s %p\n\" | md5sum") | ||
| 238 | -- end | ||
| 239 | return md5sum | ||
| 240 | end | ||
| 241 | |||
| 242 | --- Create environment variables needed for tests | ||
| 243 | -- @param testing_paths table: table with paths to testing directory | ||
| 244 | -- @return env_variables table: table with created environment variables | ||
| 245 | local function create_env(testing_paths) | ||
| 246 | local luaversion_short = _VERSION:gsub("Lua ", "") | ||
| 247 | |||
| 248 | if test_env.LUAJIT_V then | ||
| 249 | luaversion_short="5.1" | ||
| 250 | end | ||
| 251 | |||
| 252 | local env_variables = {} | ||
| 253 | env_variables.LUA_VERSION = luaversion_short | ||
| 254 | env_variables.LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config.lua" | ||
| 255 | env_variables.LUA_PATH = testing_paths.testing_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" | ||
| 256 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" | ||
| 257 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" | ||
| 258 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" | ||
| 259 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;" | ||
| 260 | env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" | ||
| 261 | .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" | ||
| 262 | env_variables.PATH = os.getenv("PATH") .. ":" .. testing_paths.testing_tree .. "/bin:" .. testing_paths.testing_sys_tree .. "/bin" | ||
| 263 | |||
| 264 | return env_variables | ||
| 265 | end | ||
| 266 | |||
| 267 | --- Create md5sums of origin system and system-copy testing directory | ||
| 268 | -- @param testing_paths table: table with paths to testing directory | ||
| 269 | -- @return md5sums table: table of md5sums of system and system-copy testing directory | ||
| 270 | local function create_md5sums(testing_paths) | ||
| 271 | local md5sums = {} | ||
| 272 | md5sums.testing_tree_copy_md5 = hash_environment(testing_paths.testing_tree_copy) | ||
| 273 | md5sums.testing_sys_tree_copy_md5 = hash_environment(testing_paths.testing_sys_tree_copy) | ||
| 274 | |||
| 275 | return md5sums | ||
| 276 | end | ||
| 277 | |||
| 278 | local function run_luarocks(testing_paths, env_variables) | ||
| 279 | |||
| 280 | local function make_command_function(exec_function, lua_cmd, do_print) | ||
| 281 | return function(cmd, new_vars) | ||
| 282 | local temp_vars = {} | ||
| 283 | for k, v in pairs(env_variables) do | ||
| 284 | temp_vars[k] = v | ||
| 285 | end | ||
| 286 | if new_vars then | ||
| 287 | for k, v in pairs(new_vars) do | ||
| 288 | temp_vars[k] = v | ||
| 289 | end | ||
| 290 | end | ||
| 291 | return exec_function(lua_cmd .. cmd, do_print, temp_vars) | ||
| 292 | end | ||
| 293 | end | ||
| 294 | |||
| 295 | local run = {} | ||
| 296 | |||
| 297 | local cov_str = testing_paths.lua .. " -e\"require('luacov.runner')('" .. testing_paths.testing_dir .. "/luacov.config')\" " | ||
| 298 | |||
| 299 | local luarocks_cmd = cov_str .. testing_paths.src_dir .. "/bin/luarocks " | ||
| 300 | run.luarocks = make_command_function(execute_output, luarocks_cmd, true) | ||
| 301 | run.luarocks_bool = make_command_function(execute_bool, luarocks_cmd, true) | ||
| 302 | run.luarocks_noprint = make_command_function(execute_bool, luarocks_cmd, false) | ||
| 303 | |||
| 304 | local luarocks_nocov_cmd = testing_paths.lua .. " " .. testing_paths.src_dir .. "/bin/luarocks " | ||
| 305 | run.luarocks_nocov = make_command_function(execute_bool, luarocks_nocov_cmd, true) | ||
| 306 | run.luarocks_noprint_nocov = make_command_function(execute_bool, luarocks_nocov_cmd, false) | ||
| 307 | |||
| 308 | local luarocks_admin_cmd = cov_str .. testing_paths.src_dir .. "/bin/luarocks-admin " | ||
| 309 | run.luarocks_admin = make_command_function(execute_output, luarocks_admin_cmd, true) | ||
| 310 | run.luarocks_admin_bool = make_command_function(execute_bool, luarocks_admin_cmd, true) | ||
| 311 | |||
| 312 | local luarocks_admin_nocov_cmd = testing_paths.lua .. " " .. testing_paths.src_dir .. "/bin/luarocks-admin " | ||
| 313 | run.luarocks_admin_nocov = make_command_function(execute_bool, luarocks_admin_nocov_cmd, false) | ||
| 314 | |||
| 315 | return run | ||
| 316 | end | ||
| 317 | |||
| 318 | --- Build environment for testing | ||
| 319 | local function build_environment(env_rocks, testing_paths, env_variables) | ||
| 320 | print("\n--------------------") | ||
| 321 | print("BUILDING ENVIRONMENT") | ||
| 322 | print("--------------------") | ||
| 323 | test_env.remove_dir(testing_paths.testing_tree) | ||
| 324 | test_env.remove_dir(testing_paths.testing_sys_tree) | ||
| 325 | test_env.remove_dir(testing_paths.testing_tree_copy) | ||
| 326 | test_env.remove_dir(testing_paths.testing_sys_tree_copy) | ||
| 327 | |||
| 328 | lfs.mkdir(testing_paths.testing_tree) | ||
| 329 | lfs.mkdir(testing_paths.testing_sys_tree) | ||
| 330 | |||
| 331 | local run = run_luarocks(testing_paths, env_variables) | ||
| 332 | run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_server) | ||
| 333 | run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_cache) | ||
| 334 | |||
| 335 | for _,package in ipairs(env_rocks) do | ||
| 336 | if not run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. package, env_variables) then | ||
| 337 | run.luarocks_nocov("build --tree=" .. testing_paths.testing_sys_tree .. " " .. package, env_variables) | ||
| 338 | run.luarocks_nocov("pack --tree=" .. testing_paths.testing_sys_tree .. " " .. package .. "; mv " .. package .. "-*.rock " .. testing_paths.testing_cache, env_variables) | ||
| 339 | end | ||
| 340 | end | ||
| 341 | |||
| 342 | execute_bool("cp -a " .. testing_paths.testing_tree .. "/. " .. testing_paths.testing_tree_copy) | ||
| 343 | execute_bool("cp -a " .. testing_paths.testing_sys_tree .. "/. " .. testing_paths.testing_sys_tree_copy) | ||
| 344 | end | ||
| 345 | |||
| 346 | --- Reset testing environment | ||
| 347 | local function reset_environment(testing_paths, md5sums) | ||
| 348 | local testing_tree_md5 = hash_environment(testing_paths.testing_tree) | ||
| 349 | local testing_sys_tree_md5 = hash_environment(testing_paths.testing_sys_tree) | ||
| 350 | |||
| 351 | if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then | ||
| 352 | test_env.remove_dir(testing_paths.testing_tree) | ||
| 353 | execute_bool("cp -a " .. testing_paths.testing_tree_copy .. "/. " .. testing_paths.testing_tree) | ||
| 354 | end | ||
| 355 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then | ||
| 356 | test_env.remove_dir(testing_paths.testing_sys_tree) | ||
| 357 | execute_bool("cp -a " .. testing_paths.testing_sys_tree_copy .. "/. " .. testing_paths.testing_sys_tree) | ||
| 358 | end | ||
| 359 | |||
| 360 | print("\n[ENVIRONMENT RESET]") | ||
| 361 | end | ||
| 362 | |||
| 363 | local function create_paths(luaversion_full) | ||
| 364 | local testing_paths = {} | ||
| 365 | |||
| 366 | testing_paths.luadir = "" | ||
| 367 | |||
| 368 | if test_env.TRAVIS then | ||
| 369 | testing_paths.luadir = lfs.currentdir() .. "/lua_install" | ||
| 370 | testing_paths.lua = testing_paths.luadir .. "/bin/lua" | ||
| 371 | end | ||
| 372 | |||
| 373 | if test_env.LUA_V and not test_env.TRAVIS then | ||
| 374 | if lfs.attributes("/usr/bin/lua") then | ||
| 375 | testing_paths.luadir = "/usr" | ||
| 376 | testing_paths.lua = testing_paths.luadir .. "/bin/lua" | ||
| 377 | elseif lfs.attributes("/usr/local/bin/lua") then | ||
| 378 | testing_paths.luadir = "/usr/local" | ||
| 379 | testing_paths.lua = testing_paths.luadir .. "/bin/lua" | ||
| 380 | end | ||
| 381 | elseif test_env.LUAJIT_V and not test_env.TRAVIS then | ||
| 382 | if lfs.attributes("/usr/bin/luajit") then | ||
| 383 | testing_paths.luadir = "/usr" | ||
| 384 | testing_paths.lua = testing_paths.luadir .. "/bin/luajit" | ||
| 385 | elseif lfs.attributes("/usr/local/bin/luajit") then | ||
| 386 | testing_paths.luadir = "/usr/local" | ||
| 387 | testing_paths.lua = testing_paths.luadir .. "/bin/luajit" | ||
| 388 | end | ||
| 389 | end | ||
| 390 | |||
| 391 | testing_paths.luarocks_tmp = "/tmp/luarocks_testing" --windows? | ||
| 392 | |||
| 393 | testing_paths.luarocks_dir = lfs.currentdir() | ||
| 394 | testing_paths.testing_dir = testing_paths.luarocks_dir .. "/test" | ||
| 395 | testing_paths.src_dir = testing_paths.luarocks_dir .. "/src" | ||
| 396 | testing_paths.testing_lrprefix = testing_paths.testing_dir .. "/testing_lrprefix-" .. luaversion_full | ||
| 397 | testing_paths.testing_tree = testing_paths.testing_dir .. "/testing-" .. luaversion_full | ||
| 398 | testing_paths.testing_tree_copy = testing_paths.testing_dir .. "/testing_copy-" .. luaversion_full | ||
| 399 | testing_paths.testing_sys_tree = testing_paths.testing_dir .. "/testing_sys-" .. luaversion_full | ||
| 400 | testing_paths.testing_sys_tree_copy = testing_paths.testing_dir .. "/testing_sys_copy-" .. luaversion_full | ||
| 401 | testing_paths.testing_cache = testing_paths.testing_dir .. "/testing_cache-" .. luaversion_full | ||
| 402 | testing_paths.testing_server = testing_paths.testing_dir .. "/testing_server-" .. luaversion_full | ||
| 403 | |||
| 404 | return testing_paths | ||
| 405 | end | ||
| 406 | |||
| 407 | --- Helper function to unload luarocks modules from global table package.loaded | ||
| 408 | -- Needed to load our local (testing) version of LuaRocks | ||
| 409 | function test_env.unload_luarocks() | ||
| 410 | for modname, _ in pairs(package.loaded) do | ||
| 411 | if modname:match("^luarocks%.") then | ||
| 412 | package.loaded[modname] = nil | ||
| 413 | end | ||
| 414 | end | ||
| 415 | end | ||
| 416 | |||
| 417 | --- Function for initially setup of environment, variables, md5sums for spec files | ||
| 418 | function test_env.setup_specs(extra_rocks, luaversion_full) | ||
| 419 | -- if global variable about successful creation of testing environment doesn't exists, build environment | ||
| 420 | if not test_env.setup_done then | ||
| 421 | test_env.set_args() | ||
| 422 | |||
| 423 | if test_env.TRAVIS then | ||
| 424 | if not os.rename(os.getenv("HOME") .. "/.ssh/id_rsa.pub", os.getenv("HOME") .. "/.ssh/id_rsa.pub") then | ||
| 425 | execute_bool("ssh-keygen -t rsa -P \"\" -f ~/.ssh/id_rsa") | ||
| 426 | execute_bool("cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys") | ||
| 427 | execute_bool("chmod og-wx ~/.ssh/authorized_keys") | ||
| 428 | execute_bool("ssh-keyscan localhost >> ~/.ssh/known_hosts") | ||
| 429 | end | ||
| 430 | end | ||
| 431 | |||
| 432 | luaversion_full = luaversion_full or test_env.LUA_V or test_env.LUAJIT_V | ||
| 433 | |||
| 434 | test_env.main() | ||
| 435 | |||
| 436 | -- Set paths, env_vars and functions for specs | ||
| 437 | test_env.testing_paths = create_paths(luaversion_full) | ||
| 438 | test_env.env_variables = create_env(test_env.testing_paths) | ||
| 439 | package.path = test_env.env_variables.LUA_PATH | ||
| 440 | |||
| 441 | test_env.run = run_luarocks(test_env.testing_paths, test_env.env_variables) | ||
| 442 | test_env.platform = execute_output(test_env.testing_paths.lua .. " -e 'print(require(\"luarocks.cfg\").arch)'", false, test_env.env_variables) | ||
| 443 | test_env.md5sums = create_md5sums(test_env.testing_paths) | ||
| 444 | test_env.setup_done = true | ||
| 445 | end | ||
| 446 | |||
| 447 | if extra_rocks then | ||
| 448 | local make_manifest = download_rocks(extra_rocks, test_env.testing_paths.testing_server) | ||
| 449 | if make_manifest then | ||
| 450 | local run = run_luarocks(test_env.testing_paths, test_env.env_variables) | ||
| 451 | run.luarocks_admin_nocov("make_manifest " .. test_env.testing_paths.testing_server) | ||
| 452 | end | ||
| 453 | end | ||
| 454 | |||
| 455 | reset_environment(test_env.testing_paths, test_env.md5sums, test_env.env_variables) | ||
| 456 | |||
| 457 | return true | ||
| 458 | end | ||
| 459 | |||
| 460 | --- Helper function for tests which needs luasocket installed | ||
| 461 | function test_env.need_luasocket(luarocks_nocov, testing_cache, platform) | ||
| 462 | luarocks_nocov = luarocks_nocov or test_env.run.luarocks_nocov | ||
| 463 | testing_cache = testing_cache or test_env.testing_paths.testing_cache | ||
| 464 | platform = platform or test_env.platform | ||
| 465 | |||
| 466 | if luarocks_nocov("show luasocket") then | ||
| 467 | return true | ||
| 468 | else | ||
| 469 | testing_cache = testing_cache .. "/" | ||
| 470 | local luasocket_rock = "luasocket-3.0rc1-1." .. platform .. ".rock" | ||
| 471 | if not os.rename( testing_cache .. luasocket_rock, testing_cache .. luasocket_rock) then | ||
| 472 | luarocks_nocov("build --pack-binary-rock luasocket 3.0rc1-1") | ||
| 473 | os.rename(luasocket_rock, testing_cache .. luasocket_rock) | ||
| 474 | end | ||
| 475 | luarocks_nocov("install " .. testing_cache .. luasocket_rock) | ||
| 476 | end | ||
| 477 | return true | ||
| 478 | end | ||
| 479 | |||
| 480 | --- | ||
| 481 | -- Main function to create config files and testing environment | ||
| 482 | function test_env.main(luaversion_full, env_type, env_clean) | ||
| 483 | luaversion_full = luaversion_full or test_env.LUA_V or test_env.LUAJIT_V | ||
| 484 | local testing_paths = create_paths(luaversion_full) | ||
| 485 | |||
| 486 | env_clean = env_clean or test_env.TEST_ENV_CLEAN | ||
| 487 | if env_clean then | ||
| 488 | print("Cleaning testing directory...") | ||
| 489 | test_env.remove_dir(testing_paths.luarocks_tmp) | ||
| 490 | test_env.remove_dir_pattern(testing_paths.testing_dir, "testing_") | ||
| 491 | test_env.remove_dir_pattern(testing_paths.testing_dir, "testing-") | ||
| 492 | test_env.remove_files(testing_paths.testing_dir, "testing_") | ||
| 493 | test_env.remove_files(testing_paths.testing_dir, "luacov") | ||
| 494 | print("Cleaning done!") | ||
| 495 | end | ||
| 496 | |||
| 497 | lfs.mkdir(testing_paths.testing_cache) | ||
| 498 | lfs.mkdir(testing_paths.luarocks_tmp) | ||
| 499 | |||
| 500 | --- CONFIG FILES | ||
| 501 | -- testing_config.lua and testing_config_show_downloads.lua | ||
| 502 | local config_content = ([[rocks_trees = { | ||
| 503 | "%{testing_tree}", | ||
| 504 | { name = "system", root = "%{testing_sys_tree}" }, | ||
| 505 | } | ||
| 506 | rocks_servers = { | ||
| 507 | "%{testing_server}" | ||
| 508 | } | ||
| 509 | local_cache = "%{testing_cache}" | ||
| 510 | upload_server = "testing" | ||
| 511 | upload_user = "%{user}" | ||
| 512 | upload_servers = { | ||
| 513 | testing = { | ||
| 514 | rsync = "localhost/tmp/luarocks_testing", | ||
| 515 | }, | ||
| 516 | } | ||
| 517 | external_deps_dirs = { | ||
| 518 | "/usr/local", | ||
| 519 | "/usr", | ||
| 520 | -- These are used for a test that fails, so it | ||
| 521 | -- can point to invalid paths: | ||
| 522 | { | ||
| 523 | prefix = "/opt", | ||
| 524 | bin = "bin", | ||
| 525 | include = "include", | ||
| 526 | lib = { "lib", "lib64" }, | ||
| 527 | } | ||
| 528 | }]]):gsub("%%%b{}", { | ||
| 529 | ["%{user}"] = os.getenv("USER"), | ||
| 530 | ["%{testing_sys_tree}"] = testing_paths.testing_sys_tree, | ||
| 531 | ["%{testing_tree}"] = testing_paths.testing_tree, | ||
| 532 | ["%{testing_server}"] = testing_paths.testing_server, | ||
| 533 | ["%{testing_cache}"] = testing_paths.testing_cache}) | ||
| 534 | |||
| 535 | create_config(testing_paths.testing_dir .. "/testing_config.lua", config_content .. " \nweb_browser = \"true\"") | ||
| 536 | create_config(testing_paths.testing_dir .. "/testing_config_show_downloads.lua", config_content | ||
| 537 | .. "show_downloads = true \n rocks_servers={\"http://luarocks.org/repositories/rocks\"}") | ||
| 538 | |||
| 539 | -- testing_config_sftp.lua | ||
| 540 | config_content=([[rocks_trees = { | ||
| 541 | "%{testing_tree}", | ||
| 542 | "%{testing_sys_tree}", | ||
| 543 | } | ||
| 544 | local_cache = "%{testing_cache}" | ||
| 545 | upload_server = "testing" | ||
| 546 | upload_user = "%{user}" | ||
| 547 | upload_servers = { | ||
| 548 | testing = { | ||
| 549 | sftp = "localhost/tmp/luarocks_testing", | ||
| 550 | }, | ||
| 551 | }]]):gsub("%%%b{}", { | ||
| 552 | ["%{user}"] = os.getenv("USER"), | ||
| 553 | ["%{testing_sys_tree}"] = testing_paths.testing_sys_tree, | ||
| 554 | ["%{testing_tree}"] = testing_paths.testing_tree, | ||
| 555 | ["%{testing_cache}"] = testing_paths.testing_cache}) | ||
| 556 | |||
| 557 | create_config(testing_paths.testing_dir .. "/testing_config_sftp.lua", config_content) | ||
| 558 | |||
| 559 | -- luacov.config | ||
| 560 | config_content=([[return { | ||
| 561 | statsfile = "%{testing_dir}/luacov.stats.out", | ||
| 562 | reportfile = "%{testing_dir}/luacov.report.out", | ||
| 563 | modules = { | ||
| 564 | ["luarocks"] = "src/bin/luarocks", | ||
| 565 | ["luarocks-admin"] = "src/bin/luarocks-admin", | ||
| 566 | ["luarocks.*"] = "src", | ||
| 567 | ["luarocks.*.*"] = "src", | ||
| 568 | ["luarocks.*.*.*"] = "src" | ||
| 569 | } | ||
| 570 | }]]):gsub("%%%b{}", { | ||
| 571 | ["%{testing_dir}"] = testing_paths.testing_dir}) | ||
| 572 | |||
| 573 | create_config(testing_paths.testing_dir .. "/luacov.config", config_content) | ||
| 574 | |||
| 575 | -- Create environment variables for configuration | ||
| 576 | local temp_env_variables = {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config.lua",LUA_PATH="",LUA_CPATH=""} | ||
| 577 | |||
| 578 | -- Configure LuaRocks testing environment | ||
| 579 | local configure_cmd = "./configure --with-lua=" .. testing_paths.luadir .. " --prefix=" .. testing_paths.testing_lrprefix | ||
| 580 | configure_cmd = configure_cmd .. " && make clean" | ||
| 581 | |||
| 582 | if not execute_bool(configure_cmd, false, temp_env_variables) then | ||
| 583 | os.exit(1) | ||
| 584 | end | ||
| 585 | if not execute_bool("make src/luarocks/site_config.lua && make dev", false, temp_env_variables) then | ||
| 586 | os.exit(1) | ||
| 587 | end | ||
| 588 | |||
| 589 | -- Preparation of rocks for building environment | ||
| 590 | env_type = env_type or test_env.TYPE_TEST_ENV | ||
| 591 | |||
| 592 | local env_rocks = {} -- short names of rocks, required for building environment | ||
| 593 | local rocks = {} -- full names of rocks required for download | ||
| 594 | rocks[#rocks+1] = "/luacov-0.11.0-1.rockspec" | ||
| 595 | rocks[#rocks+1] = "/luacov-0.11.0-1.src.rock" | ||
| 596 | |||
| 597 | if env_type == "full" then | ||
| 598 | rocks[#rocks+1] = "/luafilesystem-1.6.3-1.src.rock" | ||
| 599 | rocks[#rocks+1] = "/luasocket-3.0rc1-1.src.rock" | ||
| 600 | rocks[#rocks+1] = "/luasocket-3.0rc1-1.rockspec" | ||
| 601 | rocks[#rocks+1] = "/luaposix-33.2.1-1.src.rock" | ||
| 602 | rocks[#rocks+1] = "/md5-1.2-1.src.rock" | ||
| 603 | rocks[#rocks+1] = "/lzlib-0.4.1.53-1.src.rock" | ||
| 604 | env_rocks = {"luafilesystem", "luasocket", "luaposix", "md5", "lzlib"} | ||
| 605 | end | ||
| 606 | if env_type == "full" and luaversion_full ~= "5.1.5" then | ||
| 607 | rocks[#rocks+1] = "/luabitop-1.0.2-1.rockspec" | ||
| 608 | rocks[#rocks+1] = "/luabitop-1.0.2-1.src.rock" | ||
| 609 | table.insert(env_rocks, "luabitop") | ||
| 610 | end | ||
| 611 | |||
| 612 | table.insert(env_rocks, "luacov") -- luacov is needed for minimal or full environment | ||
| 613 | |||
| 614 | -- Download rocks needed for LuaRocks testing environment | ||
| 615 | lfs.mkdir(testing_paths.testing_server) | ||
| 616 | download_rocks(rocks, testing_paths.testing_server) | ||
| 617 | |||
| 618 | build_environment(env_rocks, testing_paths, temp_env_variables) | ||
| 619 | |||
| 620 | print("----------------") | ||
| 621 | print(" RUNNING TESTS") | ||
| 622 | print("----------------") | ||
| 623 | end | ||
| 624 | |||
| 625 | return test_env | ||
diff --git a/test/testing.lua b/test/testing.lua deleted file mode 100644 index 1a837484..00000000 --- a/test/testing.lua +++ /dev/null | |||
| @@ -1,483 +0,0 @@ | |||
| 1 | |||
| 2 | local variables = {} | ||
| 3 | |||
| 4 | -- Expand variables in the format $foo or ${foo} according | ||
| 5 | -- to the variables table. | ||
| 6 | local function expand_variables(str) | ||
| 7 | return str:gsub("%$({?)([A-Za-z0-9_]+)(}?)", function(o, v, c) | ||
| 8 | return #o <= #c and (variables[v] or "") .. (#o < #c and c or "") | ||
| 9 | end) | ||
| 10 | end | ||
| 11 | |||
| 12 | -- @param cmd command to run | ||
| 13 | -- @param envtable optional table of temporary environment variables | ||
| 14 | local function run(cmd, envtable) | ||
| 15 | cmd = expand_variables(cmd) | ||
| 16 | local env = {} | ||
| 17 | for var, val in pairs(envtable) do | ||
| 18 | table.insert(env, var.."='"..expand_variables(val).."' ") | ||
| 19 | end | ||
| 20 | local code = os.execute(table.concat(env)..cmd) | ||
| 21 | return (code == 0 or code == true) | ||
| 22 | end | ||
| 23 | |||
| 24 | local function cd_run(dir, cmd, envtable) | ||
| 25 | return run("cd "..dir.." && "..cmd, envtable) | ||
| 26 | end | ||
| 27 | |||
| 28 | local function run_get_contents(cmd) | ||
| 29 | end | ||
| 30 | |||
| 31 | local function mkdir(dirname) | ||
| 32 | cmd = expand_variables(dirname) | ||
| 33 | -- TODO | ||
| 34 | end | ||
| 35 | |||
| 36 | local function rm_rf(...) | ||
| 37 | -- TODO | ||
| 38 | end | ||
| 39 | |||
| 40 | local function mv(src, dst) | ||
| 41 | -- TODO | ||
| 42 | end | ||
| 43 | |||
| 44 | local function exists(filename) | ||
| 45 | filename = expand_variables(filename) | ||
| 46 | -- TODO | ||
| 47 | end | ||
| 48 | |||
| 49 | local function glob(patt) | ||
| 50 | -- TODO | ||
| 51 | end | ||
| 52 | |||
| 53 | local function touch(filename) | ||
| 54 | -- TODO | ||
| 55 | end | ||
| 56 | |||
| 57 | local function rm(...) | ||
| 58 | for _, filename in ipairs {...} do | ||
| 59 | filename = expand_variables(filename) | ||
| 60 | -- TODO | ||
| 61 | end | ||
| 62 | return true | ||
| 63 | end | ||
| 64 | |||
| 65 | local function file_set_contents(filename, contents) | ||
| 66 | filename = expand_variables(filename) | ||
| 67 | |||
| 68 | local fd, err = io.open(filename, "w") | ||
| 69 | if not fd then return nil, err end | ||
| 70 | fd:write(contents) | ||
| 71 | fd:close() | ||
| 72 | return true | ||
| 73 | end | ||
| 74 | |||
| 75 | local function need_luasocket() | ||
| 76 | -- TODO | ||
| 77 | end | ||
| 78 | |||
| 79 | local tests = { | ||
| 80 | |||
| 81 | test_version = function() return run "$luarocks --version" end, | ||
| 82 | fail_unknown_command = function() return run "$luarocks unknown_command" end, | ||
| 83 | fail_arg_boolean_parameter = function() return run "$luarocks --porcelain=invalid" end, | ||
| 84 | fail_arg_boolean_unknown = function() return run "$luarocks --invalid-flag" end, | ||
| 85 | fail_arg_string_no_parameter = function() return run "$luarocks --server" end, | ||
| 86 | fail_arg_string_followed_by_flag = function() return run "$luarocks --server --porcelain" end, | ||
| 87 | fail_arg_string_unknown = function() return run "$luarocks --invalid-flag=abc" end, | ||
| 88 | test_empty_list = function() return run "$luarocks list" end, | ||
| 89 | test_list_outdated = function () return run "$luarocks list --outdated" end, | ||
| 90 | fail_sysconfig_err = function() | ||
| 91 | mkdir "$testing_lrprefix/etc/luarocks" | ||
| 92 | file_set_contents("$testing_lrprefix/etc/luarocks/config.lua", "aoeui") | ||
| 93 | return run "$luarocks list" | ||
| 94 | and rm "$testing_lrprefix/etc/luarocks/config.lua" | ||
| 95 | end, | ||
| 96 | fail_sysconfig_default_err = function() | ||
| 97 | mkdir "$testing_lrprefix/etc/luarocks" | ||
| 98 | file_set_contents("$testing_lrprefix/etc/luarocks/config-$luashortversion.lua", "aoeui") | ||
| 99 | return run "$luarocks list" | ||
| 100 | and rm "$testing_lrprefix/etc/luarocks/config-$luashortversion.lua" | ||
| 101 | end, | ||
| 102 | fail_build_noarg = function() return run "$luarocks build" end, | ||
| 103 | fail_download_noarg = function() return run "$luarocks download" end, | ||
| 104 | fail_install_noarg = function() return run "$luarocks install" end, | ||
| 105 | fail_lint_noarg = function() return run "$luarocks lint" end, | ||
| 106 | fail_search_noarg = function() return run "$luarocks search" end, | ||
| 107 | fail_show_noarg = function() return run "$luarocks show" end, | ||
| 108 | fail_unpack_noarg = function() return run "$luarocks unpack" end, | ||
| 109 | fail_upload_noarg = function() return run "$luarocks upload" end, | ||
| 110 | fail_remove_noarg = function() return run "$luarocks remove" end, | ||
| 111 | fail_doc_noarg = function() return run "$luarocks doc" end, | ||
| 112 | fail_new_version_noarg = function() return run "$luarocks new_version" end, | ||
| 113 | fail_write_rockspec_noarg = function() return run "$luarocks write_rockspec" end, | ||
| 114 | fail_build_invalid = function() return run "$luarocks build invalid" end, | ||
| 115 | fail_download_invalid = function() return run "$luarocks download invalid" end, | ||
| 116 | fail_install_invalid = function() return run "$luarocks install invalid" end, | ||
| 117 | fail_lint_invalid = function() return run "$luarocks lint invalid" end, | ||
| 118 | fail_show_invalid = function() return run "$luarocks show invalid" end, | ||
| 119 | fail_new_version_invalid = function() return run "$luarocks new_version invalid" end, | ||
| 120 | test_list_invalidtree = function() return run "$luarocks --tree=/some/invalid/tree list" end, | ||
| 121 | fail_inexistent_dir = function() | ||
| 122 | -- Unix only? | ||
| 123 | return run "mkdir idontexist; cd idontexist; rmdir ../idontexist; $luarocks; err=$?; cd ..; return $err" | ||
| 124 | end, | ||
| 125 | fail_make_norockspec = function() return run "$luarocks make" end, | ||
| 126 | fail_build_permissions = function() return run "$luarocks build --tree=/usr lpeg" end, | ||
| 127 | fail_build_permissions_parent = function() return run "$luarocks build --tree=/usr/invalid lpeg" end, | ||
| 128 | test_build_verbose = function() return run "$luarocks build --verbose lpeg" end, | ||
| 129 | fail_build_blank_arg = function() return run "$luarocks build --tree="" lpeg" end, | ||
| 130 | test_build_withpatch = function() need_luasocket(); return run "$luarocks build luadoc" end, | ||
| 131 | test_build_diffversion = function() return run "$luarocks build luacov ${version_luacov}" end, | ||
| 132 | test_build_command = function() return run "$luarocks build stdlib" end, | ||
| 133 | test_build_install_bin = function() return run "$luarocks build luarepl" end, | ||
| 134 | test_build_nohttps = function() | ||
| 135 | need_luasocket() | ||
| 136 | return run "$luarocks download --rockspec validate-args ${verrev_validate_args}" | ||
| 137 | and run "$luarocks build ./validate-args-${version_validate_args}-1.rockspec" | ||
| 138 | and rm "./validate-args-${version_validate_args}-1.rockspec" | ||
| 139 | end, | ||
| 140 | test_build_https = function() | ||
| 141 | need_luasocket() | ||
| 142 | return run "$luarocks download --rockspec validate-args ${verrev_validate_args}" | ||
| 143 | and run "$luarocks install luasec" | ||
| 144 | and run "$luarocks build ./validate-args-${verrev_validate_args}.rockspec" | ||
| 145 | and rm "./validate-args-${verrev_validate_args}.rockspec" | ||
| 146 | end, | ||
| 147 | test_build_supported_platforms = function() return run "$luarocks build lpty" end, | ||
| 148 | test_build_only_deps_rockspec = function() | ||
| 149 | return run "$luarocks download --rockspec lxsh ${verrev_lxsh}" | ||
| 150 | and run "$luarocks build ./lxsh-${verrev_lxsh}.rockspec --only-deps" | ||
| 151 | and (not run "$luarocks show lxsh") | ||
| 152 | end, | ||
| 153 | test_build_only_deps_src_rock = function() | ||
| 154 | return run "$luarocks download --source lxsh ${verrev_lxsh}" | ||
| 155 | and run "$luarocks build ./lxsh-${verrev_lxsh}.src.rock --only-deps" | ||
| 156 | and (not run "$luarocks show lxsh") | ||
| 157 | end, | ||
| 158 | test_build_only_deps = function() return run "$luarocks build luasec --only-deps" and (not run "$luarocks show luasec") end, | ||
| 159 | test_install_only_deps = function() return run "$luarocks install lxsh ${verrev_lxsh} --only-deps" and (not run "$luarocks show lxsh") end, | ||
| 160 | fail_build_missing_external = function() return run '$luarocks build "$testing_dir/testfiles/missing_external-0.1-1.rockspec" INEXISTENT_INCDIR="/invalid/dir"' end, | ||
| 161 | fail_build_invalidpatch = function() | ||
| 162 | need_luasocket() | ||
| 163 | return run '$luarocks build "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"' | ||
| 164 | end, | ||
| 165 | test_build_deps_partial_match = function() return run "$luarocks build lmathx" end, | ||
| 166 | test_build_show_downloads = function() | ||
| 167 | return run("$luarocks build alien", { LUAROCKS_CONFIG="$testing_dir/testing_config_show_downloads.lua" }) | ||
| 168 | end, | ||
| 169 | test_download_all = function() | ||
| 170 | return run "$luarocks download --all validate-args" | ||
| 171 | and rm(glob("validate-args-*")) | ||
| 172 | end, | ||
| 173 | test_download_rockspecversion = function() | ||
| 174 | return run "$luarocks download --rockspec validate-args ${verrev_validate_args}" | ||
| 175 | and rm(glob("validate-args-*")) | ||
| 176 | end, | ||
| 177 | test_help = function() return run "$luarocks help" end, | ||
| 178 | fail_help_invalid = function() return run "$luarocks help invalid" end, | ||
| 179 | test_install_binaryrock = function() | ||
| 180 | return run "$luarocks build --pack-binary-rock cprint" | ||
| 181 | and run "$luarocks install ./cprint-${verrev_cprint}.${platform}.rock" | ||
| 182 | and rm "./cprint-${verrev_cprint}.${platform}.rock" | ||
| 183 | end, | ||
| 184 | test_install_with_bin = function() return run "$luarocks install wsapi" end, | ||
| 185 | fail_install_notazipfile = function() return run '$luarocks install "$testing_dir/testfiles/not_a_zipfile-1.0-1.src.rock"' end, | ||
| 186 | fail_install_invalidpatch = function() | ||
| 187 | need_luasocket() | ||
| 188 | return run '$luarocks install "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"' | ||
| 189 | end, | ||
| 190 | fail_install_invalid_filename = function() return run '$luarocks install "invalid.rock"' end, | ||
| 191 | fail_install_invalid_arch = function() return run '$luarocks install "foo-1.0-1.impossible-x86.rock"' end, | ||
| 192 | test_install_reinstall = function() | ||
| 193 | return run '$luarocks install "$testing_cache/luasocket-$verrev_luasocket.$platform.rock"' | ||
| 194 | and run '$luarocks install --deps-mode=none "$testing_cache/luasocket-$verrev_luasocket.$platform.rock"' | ||
| 195 | end, | ||
| 196 | fail_local_root = function() return run("$luarocks install --local luasocket", { USER="root" }) end, | ||
| 197 | test_site_config = function() | ||
| 198 | mv("../src/luarocks/site_config.lua", "../src/luarocks/site_config.lua.tmp") | ||
| 199 | local ok = run "$luarocks" | ||
| 200 | mv("../src/luarocks/site_config.lua.tmp", "../src/luarocks/site_config.lua") | ||
| 201 | return ok | ||
| 202 | end, | ||
| 203 | test_lint_ok = function() | ||
| 204 | return run "$luarocks download --rockspec validate-args ${verrev_validate_args}" | ||
| 205 | and run "$luarocks lint ./validate-args-${verrev_validate_args}.rockspec" | ||
| 206 | and rm "./validate-args-${verrev_validate_args}.rockspec" | ||
| 207 | end, | ||
| 208 | fail_lint_type_mismatch_string = function() return run '$luarocks lint "$testing_dir/testfiles/type_mismatch_string-1.0-1.rockspec"' end, | ||
| 209 | fail_lint_type_mismatch_version = function() return run '$luarocks lint "$testing_dir/testfiles/type_mismatch_version-1.0-1.rockspec"' end, | ||
| 210 | fail_lint_type_mismatch_table = function() return run '$luarocks lint "$testing_dir/testfiles/type_mismatch_table-1.0-1.rockspec"' end, | ||
| 211 | fail_lint_no_build_table = function() return run '$luarocks lint "$testing_dir/testfiles/no_build_table-0.1-1.rockspec"' end, | ||
| 212 | test_list = function() return run "$luarocks list" end, | ||
| 213 | test_list_porcelain = function() return run "$luarocks list --porcelain" end, | ||
| 214 | test_make_with_rockspec = function() | ||
| 215 | return rm_rf "./luasocket-${verrev_luasocket}" | ||
| 216 | and run "$luarocks download --source luasocket" | ||
| 217 | and run "$luarocks unpack ./luasocket-${verrev_luasocket}.src.rock" | ||
| 218 | and cd_run("luasocket-${verrev_luasocket}/${srcdir_luasocket}", "$luarocks make luasocket-${verrev_luasocket}.rockspec") | ||
| 219 | and rm_rf "./luasocket-${verrev_luasocket}" | ||
| 220 | end, | ||
| 221 | test_make_default_rockspec = function() | ||
| 222 | return rm_rf "./lxsh-${verrev_lxsh}" | ||
| 223 | and run "$luarocks download --source lxsh ${verrev_lxsh}" | ||
| 224 | and run "$luarocks unpack ./lxsh-${verrev_lxsh}.src.rock" | ||
| 225 | and cd_run("lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1", "$luarocks make") | ||
| 226 | and rm_rf "./lxsh-${verrev_lxsh}" | ||
| 227 | end, | ||
| 228 | test_make_pack_binary_rock = function() | ||
| 229 | return rm_rf "./lxsh-${verrev_lxsh}" | ||
| 230 | and run "$luarocks download --source lxsh ${verrev_lxsh}" | ||
| 231 | and run "$luarocks unpack ./lxsh-${verrev_lxsh}.src.rock" | ||
| 232 | and cd_run("lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1", "$luarocks make --deps-mode=none --pack-binary-rock") | ||
| 233 | and exists "lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1/lxsh-${verrev_lxsh}.all.rock" | ||
| 234 | and rm_rf "./lxsh-${verrev_lxsh}" | ||
| 235 | end, | ||
| 236 | fail_make_which_rockspec = function() | ||
| 237 | rm_rf "./luasocket-${verrev_luasocket}" | ||
| 238 | run "$luarocks download --source luasocket" | ||
| 239 | run "$luarocks unpack ./luasocket-${verrev_luasocket}.src.rock" | ||
| 240 | local ok = cd_run("luasocket-${verrev_luasocket}/${srcdir_luasocket}", "$luarocks make") | ||
| 241 | rm_rf "./luasocket-${verrev_luasocket}" | ||
| 242 | return ok | ||
| 243 | end, | ||
| 244 | test_new_version = function() | ||
| 245 | return run "$luarocks download --rockspec luacov ${version_luacov}" | ||
| 246 | and run "$luarocks new_version ./luacov-${version_luacov}-1.rockspec 0.2" | ||
| 247 | and rm(glob("./luacov-0.*")) | ||
| 248 | end, | ||
| 249 | test_new_version_url = function() | ||
| 250 | return run "$luarocks download --rockspec abelhas 1.0" | ||
| 251 | and run "$luarocks new_version ./abelhas-1.0-1.rockspec 1.1 https://github.com/downloads/ittner/abelhas/abelhas-1.1.tar.gz" | ||
| 252 | and rm(glob("./abelhas-*")) | ||
| 253 | end, | ||
| 254 | test_pack = function() | ||
| 255 | return run "$luarocks list" | ||
| 256 | and run "$luarocks pack luacov" | ||
| 257 | and rm(glob("./luacov-*.rock")) | ||
| 258 | end, | ||
| 259 | test_pack_src = function() | ||
| 260 | return run "$luarocks install luasec" | ||
| 261 | and run "$luarocks download --rockspec luasocket" | ||
| 262 | and run "$luarocks pack ./luasocket-${verrev_luasocket}.rockspec" | ||
| 263 | and rm(glob("./luasocket-${version_luasocket}-*.rock")) | ||
| 264 | end, | ||
| 265 | test_path = function() return run "$luarocks path --bin" end, | ||
| 266 | test_path_lr_path = function() return run "$luarocks path --lr-path" end, | ||
| 267 | test_path_lr_cpath = function() return run "$luarocks path --lr-cpath" end, | ||
| 268 | test_path_lr_bin = function() return run "$luarocks path --lr-bin" end, | ||
| 269 | test_path_with_tree = function() return run "$luarocks path --tree=lua_modules" end, | ||
| 270 | fail_purge_missing_tree = function() return run '$luarocks purge --tree="$testing_tree"' end, | ||
| 271 | test_purge = function() return run '$luarocks purge --tree="$testing_sys_tree"' end, | ||
| 272 | test_remove = function() | ||
| 273 | return run "$luarocks build abelhas ${version_abelhas}" | ||
| 274 | and run "$luarocks remove abelhas ${version_abelhas}" | ||
| 275 | end, | ||
| 276 | test_remove_force = function() | ||
| 277 | need_luasocket() | ||
| 278 | return run "$luarocks build lualogging" | ||
| 279 | and run "$luarocks remove --force luasocket" | ||
| 280 | end, | ||
| 281 | fail_remove_deps = function() | ||
| 282 | need_luasocket() | ||
| 283 | return run "$luarocks build lualogging" | ||
| 284 | and run "$luarocks remove luasocket" | ||
| 285 | end, | ||
| 286 | fail_remove_missing = function() return run "$luarocks remove missing_rock" end, | ||
| 287 | fail_remove_invalid_name = function() return run "$luarocks remove invalid.rock" end, | ||
| 288 | test_search_found = function() return run "$luarocks search zlib" end, | ||
| 289 | test_search_missing = function() return run "$luarocks search missing_rock" end, | ||
| 290 | test_show = function() return run "$luarocks show luacov" end, | ||
| 291 | test_show_modules = function() return run "$luarocks show --modules luacov" end, | ||
| 292 | test_show_home = function() return run "$luarocks show --home luacov" end, | ||
| 293 | test_show_depends = function() | ||
| 294 | need_luasocket() | ||
| 295 | return run "$luarocks install luasec" | ||
| 296 | and run "$luarocks show luasec" | ||
| 297 | end, | ||
| 298 | test_show_oldversion = function() | ||
| 299 | return run "$luarocks install luacov ${version_luacov}" | ||
| 300 | and run "$luarocks show luacov ${version_luacov}" | ||
| 301 | end, | ||
| 302 | test_unpack_download = function() | ||
| 303 | return rm_rf "./cprint-${verrev_cprint}" | ||
| 304 | and run "$luarocks unpack cprint" | ||
| 305 | and rm_rf "./cprint-${verrev_cprint}" | ||
| 306 | end, | ||
| 307 | test_unpack_src = function() | ||
| 308 | return rm_rf "./cprint-${verrev_cprint}" | ||
| 309 | and run "$luarocks download --source cprint" | ||
| 310 | and run "$luarocks unpack ./cprint-${verrev_cprint}.src.rock" | ||
| 311 | and rm_rf "./cprint-${verrev_cprint}" | ||
| 312 | end, | ||
| 313 | test_unpack_rockspec = function() | ||
| 314 | return rm_rf "./cprint-${verrev_cprint}" | ||
| 315 | and run "$luarocks download --rockspec cprint" | ||
| 316 | and run "$luarocks unpack ./cprint-${verrev_cprint}.rockspec" | ||
| 317 | and rm_rf "./cprint-${verrev_cprint}" | ||
| 318 | end, | ||
| 319 | test_unpack_binary = function() | ||
| 320 | return rm_rf "./cprint-${verrev_cprint}" | ||
| 321 | and run "$luarocks build cprint" | ||
| 322 | and run "$luarocks pack cprint" | ||
| 323 | and run "$luarocks unpack ./cprint-${verrev_cprint}.${platform}.rock" | ||
| 324 | and rm_rf "./cprint-${verrev_cprint}" | ||
| 325 | end, | ||
| 326 | fail_unpack_invalidpatch = function() | ||
| 327 | need_luasocket() | ||
| 328 | return run '$luarocks unpack "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"' | ||
| 329 | end, | ||
| 330 | fail_unpack_invalidrockspec = function() | ||
| 331 | need_luasocket() | ||
| 332 | return run '$luarocks unpack "invalid.rockspec"' | ||
| 333 | end, | ||
| 334 | fail_upload_invalidrockspec = function() return run '$luarocks upload "invalid.rockspec"' end, | ||
| 335 | fail_upload_invalidkey = function() return run '$luarocks upload --api-key="invalid" "invalid.rockspec"' end, | ||
| 336 | test_admin_help = function() return run "$luarocks_admin help" end, | ||
| 337 | test_admin_make_manifest = function() return run "$luarocks_admin make_manifest" end, | ||
| 338 | test_admin_add_rsync = function() return run '$luarocks_admin --server=testing add "$testing_server/luasocket-${verrev_luasocket}.src.rock"' end, | ||
| 339 | test_admin_add_sftp = function() | ||
| 340 | return run("$luarocks_admin --server=testing add ./luasocket-${verrev_luasocket}.src.rock", { LUAROCKS_CONFIG="$testing_dir/testing_config_sftp.lua" }) | ||
| 341 | end, | ||
| 342 | fail_admin_add_missing = function() return run "$luarocks_admin --server=testing add" end, | ||
| 343 | fail_admin_invalidserver = function() return run '$luarocks_admin --server=invalid add "$testing_server/luasocket-${verrev_luasocket}.src.rock"' end, | ||
| 344 | fail_admin_invalidrock = function() return run "$luarocks_admin --server=testing add invalid" end, | ||
| 345 | test_admin_refresh_cache = function() return run "$luarocks_admin --server=testing refresh_cache" end, | ||
| 346 | test_admin_remove = function() return run "$luarocks_admin --server=testing remove luasocket-${verrev_luasocket}.src.rock" end, | ||
| 347 | fail_admin_remove_missing = function() return run "$luarocks_admin --server=testing remove" end, | ||
| 348 | fail_deps_mode_invalid_arg = function() return run "$luarocks remove luacov --deps-mode" end, | ||
| 349 | |||
| 350 | test_deps_mode_one = function() | ||
| 351 | return run '$luarocks build --tree="system" lpeg' | ||
| 352 | and run '$luarocks list' | ||
| 353 | and run '$luarocks build --deps-mode=one --tree="$testing_tree" lxsh' | ||
| 354 | and run_get_contents '$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg' ~= "" | ||
| 355 | end, | ||
| 356 | test_deps_mode_order = function() | ||
| 357 | return run '$luarocks build --tree="system" lpeg' | ||
| 358 | and run '$luarocks build --deps-mode=order --tree="$testing_tree" lxsh' | ||
| 359 | and run '$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg' | ||
| 360 | and run_get_contents '$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg' == "" | ||
| 361 | end, | ||
| 362 | test_deps_mode_order_sys = function() | ||
| 363 | return run '$luarocks build --tree="$testing_tree" lpeg' | ||
| 364 | and run '$luarocks build --deps-mode=order --tree="$testing_sys_tree" lxsh' | ||
| 365 | and run_get_contents '$luarocks_noecho list --tree="$testing_sys_tree" --porcelain lpeg' ~= "" | ||
| 366 | end, | ||
| 367 | test_deps_mode_all_sys = function() | ||
| 368 | return run '$luarocks build --tree="$testing_tree" lpeg' | ||
| 369 | and run '$luarocks build --deps-mode=all --tree="$testing_sys_tree" lxsh' | ||
| 370 | and run_get_contents '$luarocks_noecho list --tree="$testing_sys_tree" --porcelain lpeg' == "" | ||
| 371 | end, | ||
| 372 | |||
| 373 | test_deps_mode_none = function() | ||
| 374 | return run '$luarocks build --tree="$testing_tree" --deps-mode=none lxsh' | ||
| 375 | and run_get_contents '$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg' == "" | ||
| 376 | end, | ||
| 377 | test_deps_mode_nodeps_alias = function() | ||
| 378 | return run '$luarocks build --tree="$testing_tree" --nodeps lxsh' | ||
| 379 | and run_get_contents '$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg' == "" | ||
| 380 | end, | ||
| 381 | test_deps_mode_make_order = function() | ||
| 382 | local ok = run '$luarocks build --tree="$testing_sys_tree" lpeg' | ||
| 383 | and rm_rf "./lxsh-${verrev_lxsh}" | ||
| 384 | and run "$luarocks download --source lxsh ${verrev_lxsh}" | ||
| 385 | and run "$luarocks unpack ./lxsh-${verrev_lxsh}.src.rock" | ||
| 386 | and cd_run("lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1", '$luarocks make --tree="$testing_tree" --deps-mode=order') | ||
| 387 | if not ok then | ||
| 388 | return false | ||
| 389 | end | ||
| 390 | local found = run_get_contents '$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg' | ||
| 391 | rm_rf "./lxsh-${verrev_lxsh}" | ||
| 392 | return found == "" | ||
| 393 | end, | ||
| 394 | test_deps_mode_make_order_sys = function() | ||
| 395 | local ok = run '$luarocks build --tree="$testing_tree" lpeg' | ||
| 396 | and rm_rf "./lxsh-${verrev_lxsh}" | ||
| 397 | and run "$luarocks download --source lxsh ${verrev_lxsh}" | ||
| 398 | and run "$luarocks unpack ./lxsh-${verrev_lxsh}.src.rock" | ||
| 399 | and cd_run("lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1", '$luarocks make --tree="$testing_sys_tree" --deps-mode=order') | ||
| 400 | if not ok then | ||
| 401 | return false | ||
| 402 | end | ||
| 403 | local found = run_get_contents '$luarocks_noecho list --tree="$testing_sys_tree" --porcelain lpeg' | ||
| 404 | rm_rf "./lxsh-${verrev_lxsh}" | ||
| 405 | return found ~= "" | ||
| 406 | end, | ||
| 407 | test_write_rockspec = function() return run "$luarocks write_rockspec git://github.com/keplerproject/luarocks" end, | ||
| 408 | test_write_rockspec_lib = function() return run '$luarocks write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license="3-clause BSD" --lua-version=5.1,5.2' end, | ||
| 409 | test_write_rockspec_format = function() return run '$luarocks write_rockspec git://github.com/keplerproject/luarocks --rockspec-format=1.1 --lua-version=5.1,5.2' end, | ||
| 410 | test_write_rockspec_fullargs = function() return run '$luarocks write_rockspec git://github.com/keplerproject/luarocks --lua-version=5.1,5.2 --license="MIT/X11" --homepage="http://www.luarocks.org" --summary="A package manager for Lua modules"' end, | ||
| 411 | fail_write_rockspec_args = function() return run "$luarocks write_rockspec invalid" end, | ||
| 412 | fail_write_rockspec_args_url = function() return run "$luarocks write_rockspec http://example.com/invalid.zip" end, | ||
| 413 | test_write_rockspec_http = function() return run "$luarocks write_rockspec http://luarocks.org/releases/luarocks-2.1.0.tar.gz --lua-version=5.1" end, | ||
| 414 | test_write_rockspec_basedir = function() return run "$luarocks write_rockspec https://github.com/downloads/Olivine-Labs/luassert/luassert-1.2.tar.gz --lua-version=5.1" end, | ||
| 415 | |||
| 416 | fail_config_noflags = function() return run "$luarocks config; " end, | ||
| 417 | test_config_lua_incdir = function() return run "$luarocks config --lua-incdir; " end, | ||
| 418 | test_config_lua_libdir = function() return run "$luarocks config --lua-libdir; " end, | ||
| 419 | test_config_lua_ver = function() return run "$luarocks config --lua-ver; " end, | ||
| 420 | fail_config_system_config = function() | ||
| 421 | return rm "$testing_lrprefix/etc/luarocks/config.lua" | ||
| 422 | and run "$luarocks config --system-config; " | ||
| 423 | end, | ||
| 424 | test_config_system_config = function() | ||
| 425 | local ok = mkdir "$testing_lrprefix/etc/luarocks" | ||
| 426 | and touch "$testing_lrprefix/etc/luarocks/config.lua" | ||
| 427 | and run "$luarocks config --system-config; " | ||
| 428 | rm "$testing_lrprefix/etc/luarocks/config.lua" | ||
| 429 | return ok | ||
| 430 | end, | ||
| 431 | fail_config_system_config_invalid = function() | ||
| 432 | local ok = mkdir "$testing_lrprefix/etc/luarocks" | ||
| 433 | and run "echo 'if if if' > '$testing_lrprefix/etc/luarocks/config.lua' ;" | ||
| 434 | and run "$luarocks config --system-config" | ||
| 435 | rm "$testing_lrprefix/etc/luarocks/config.lua" | ||
| 436 | return ok | ||
| 437 | end, | ||
| 438 | test_config_user_config = function() return run "$luarocks config --user-config; " end, | ||
| 439 | fail_config_user_config = function() return run "LUAROCKS_CONFIG='/missing_file.lua' $luarocks config --user-config; " end, | ||
| 440 | test_config_rock_trees = function() return run "$luarocks config --rock-trees;" end, | ||
| 441 | test_config_help = function() return run "$luarocks help config;" end, | ||
| 442 | test_doc = function() | ||
| 443 | return run "$luarocks install luarepl" | ||
| 444 | and run "$luarocks doc luarepl" | ||
| 445 | end, | ||
| 446 | test_doc_home = function() | ||
| 447 | return run "$luarocks install luacov" | ||
| 448 | and run "$luarocks doc luacov --home" | ||
| 449 | end, | ||
| 450 | fail_doc_invalid = function () return run "$luarocks doc invalid" end, | ||
| 451 | |||
| 452 | -- Tests for https://github.com/keplerproject/luarocks/issues/375 | ||
| 453 | test_fetch_base_dir = function() | ||
| 454 | local fetch = require "luarocks.fetch" | ||
| 455 | |||
| 456 | return assert("v0.3" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3.zip")) | ||
| 457 | and assert("lua-compat-5.2" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.zip")) | ||
| 458 | and assert("lua-compat-5.2" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.gz")) | ||
| 459 | and assert("lua-compat-5.2" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.bz2")) | ||
| 460 | and assert("parser.moon" == fetch.url_to_base_dir("git://github.com/Cirru/parser.moon")) | ||
| 461 | and assert("v0.3" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3")) | ||
| 462 | end, | ||
| 463 | |||
| 464 | -- Tests for https://github.com/keplerproject/luarocks/issues/552 | ||
| 465 | test_install_break_dependencies_warning = function() | ||
| 466 | need_luasocket() | ||
| 467 | return run "$luarocks install say ${new_version_say}" | ||
| 468 | and run "$luarocks install luassert" | ||
| 469 | and run "$luarocks install say ${old_version_say}" | ||
| 470 | end, | ||
| 471 | test_install_break_dependencies_force = function() | ||
| 472 | need_luasocket() | ||
| 473 | return run "$luarocks install say ${new_version_say}" | ||
| 474 | and run "$luarocks install luassert" | ||
| 475 | and run "$luarocks install --force say ${old_version_say}" | ||
| 476 | end, | ||
| 477 | test_install_break_dependencies_force = function() | ||
| 478 | need_luasocket() | ||
| 479 | return run "$luarocks install say ${new_version_say}" | ||
| 480 | and run "$luarocks install luassert" | ||
| 481 | and run "$luarocks install --force-fast say ${old_version_say}" | ||
| 482 | end | ||
| 483 | } | ||
diff --git a/test/testing.sh b/test/testing.sh deleted file mode 100755 index cb10441c..00000000 --- a/test/testing.sh +++ /dev/null | |||
| @@ -1,651 +0,0 @@ | |||
| 1 | #!/bin/bash -e | ||
| 2 | |||
| 3 | # Setup ######################################### | ||
| 4 | |||
| 5 | [ -e ../configure ] || { | ||
| 6 | echo "Please run this from the test/ directory." | ||
| 7 | exit 1 | ||
| 8 | } | ||
| 9 | |||
| 10 | if [ -z "$*" ] | ||
| 11 | then | ||
| 12 | ps aux | grep -q '[s]shd' || { | ||
| 13 | echo "Run sudo /bin/sshd in order to perform all tests." | ||
| 14 | exit 1 | ||
| 15 | } | ||
| 16 | fi | ||
| 17 | |||
| 18 | if [ "$1" == "--travis" ] | ||
| 19 | then | ||
| 20 | travis=true | ||
| 21 | shift | ||
| 22 | fi | ||
| 23 | |||
| 24 | luaversion=5.1.5 | ||
| 25 | |||
| 26 | if [ "$1" == "--lua" ] | ||
| 27 | then | ||
| 28 | shift | ||
| 29 | luaversion=$1 | ||
| 30 | shift | ||
| 31 | fi | ||
| 32 | |||
| 33 | luashortversion=`echo $luaversion | cut -d. -f 1-2` | ||
| 34 | |||
| 35 | testing_dir="$PWD" | ||
| 36 | |||
| 37 | testing_lrprefix="$testing_dir/testing_lrprefix-$luaversion" | ||
| 38 | testing_tree="$testing_dir/testing-$luaversion" | ||
| 39 | testing_sys_tree="$testing_dir/testing_sys-$luaversion" | ||
| 40 | testing_tree_copy="$testing_dir/testing_copy-$luaversion" | ||
| 41 | testing_sys_tree_copy="$testing_dir/testing_sys_copy-$luaversion" | ||
| 42 | testing_cache="$testing_dir/testing_cache-$luaversion" | ||
| 43 | testing_server="$testing_dir/testing_server-$luaversion" | ||
| 44 | |||
| 45 | if [ "$1" == "--clean" ] | ||
| 46 | then | ||
| 47 | shift | ||
| 48 | rm -rf "$testing_cache" | ||
| 49 | rm -rf "$testing_server" | ||
| 50 | fi | ||
| 51 | |||
| 52 | [ "$1" ] || rm -f luacov.stats.out | ||
| 53 | rm -f luacov.report.out | ||
| 54 | rm -rf /tmp/luarocks_testing | ||
| 55 | mkdir /tmp/luarocks_testing | ||
| 56 | rm -rf "$testing_lrprefix" | ||
| 57 | rm -rf "$testing_tree" | ||
| 58 | rm -rf "$testing_sys_tree" | ||
| 59 | rm -rf "$testing_tree_copy" | ||
| 60 | rm -rf "$testing_sys_tree_copy" | ||
| 61 | rm -rf "$testing_dir/testing_config.lua" | ||
| 62 | rm -rf "$testing_dir/testing_config_show_downloads.lua" | ||
| 63 | rm -rf "$testing_dir/testing_config_sftp.lua" | ||
| 64 | rm -rf "$testing_dir/luacov.config" | ||
| 65 | |||
| 66 | mkdir -p "$testing_cache" | ||
| 67 | |||
| 68 | [ "$1" = "clean" ] && { | ||
| 69 | rm -f luacov.stats.out | ||
| 70 | exit 0 | ||
| 71 | } | ||
| 72 | |||
| 73 | cat <<EOF > $testing_dir/testing_config.lua | ||
| 74 | rocks_trees = { | ||
| 75 | "$testing_tree", | ||
| 76 | { name = "system", root = "$testing_sys_tree" }, | ||
| 77 | } | ||
| 78 | rocks_servers = { | ||
| 79 | "$testing_server" | ||
| 80 | } | ||
| 81 | local_cache = "$testing_cache" | ||
| 82 | upload_server = "testing" | ||
| 83 | upload_user = "$USER" | ||
| 84 | upload_servers = { | ||
| 85 | testing = { | ||
| 86 | rsync = "localhost/tmp/luarocks_testing", | ||
| 87 | }, | ||
| 88 | } | ||
| 89 | external_deps_dirs = { | ||
| 90 | "/usr/local", | ||
| 91 | "/usr", | ||
| 92 | -- These are used for a test that fails, so it | ||
| 93 | -- can point to invalid paths: | ||
| 94 | { | ||
| 95 | prefix = "/opt", | ||
| 96 | bin = "bin", | ||
| 97 | include = "include", | ||
| 98 | lib = { "lib", "lib64" }, | ||
| 99 | } | ||
| 100 | } | ||
| 101 | EOF | ||
| 102 | ( | ||
| 103 | cat $testing_dir/testing_config.lua | ||
| 104 | echo "show_downloads = true" | ||
| 105 | ) > $testing_dir/testing_config_show_downloads.lua | ||
| 106 | cat <<EOF > $testing_dir/testing_config_sftp.lua | ||
| 107 | rocks_trees = { | ||
| 108 | "$testing_tree", | ||
| 109 | "$testing_sys_tree", | ||
| 110 | } | ||
| 111 | local_cache = "$testing_cache" | ||
| 112 | upload_server = "testing" | ||
| 113 | upload_user = "$USER" | ||
| 114 | upload_servers = { | ||
| 115 | testing = { | ||
| 116 | sftp = "localhost/tmp/luarocks_testing", | ||
| 117 | }, | ||
| 118 | } | ||
| 119 | EOF | ||
| 120 | cat <<EOF > $testing_dir/luacov.config | ||
| 121 | return { | ||
| 122 | statsfile = "$testing_dir/luacov.stats.out", | ||
| 123 | reportfile = "$testing_dir/luacov.report.out", | ||
| 124 | modules = { | ||
| 125 | ["luarocks"] = "src/bin/luarocks", | ||
| 126 | ["luarocks-admin"] = "src/bin/luarocks-admin", | ||
| 127 | ["luarocks.*"] = "src", | ||
| 128 | ["luarocks.*.*"] = "src", | ||
| 129 | ["luarocks.*.*.*"] = "src" | ||
| 130 | } | ||
| 131 | } | ||
| 132 | EOF | ||
| 133 | |||
| 134 | export LUAROCKS_CONFIG="$testing_dir/testing_config.lua" | ||
| 135 | export LUA_PATH= | ||
| 136 | export LUA_CPATH= | ||
| 137 | |||
| 138 | if [ "$travis" ] | ||
| 139 | then | ||
| 140 | luadir=/tmp/lua-$luaversion | ||
| 141 | pushd /tmp | ||
| 142 | if [ ! -e "$luadir/bin/lua" ] | ||
| 143 | then | ||
| 144 | mkdir -p lua | ||
| 145 | echo "Downloading lua $luaversion..." | ||
| 146 | wget "http://www.lua.org/ftp/lua-$luaversion.tar.gz" &> /dev/null | ||
| 147 | tar zxpf "lua-$luaversion.tar.gz" | ||
| 148 | cd "lua-$luaversion" | ||
| 149 | echo "Building lua $luaversion..." | ||
| 150 | make linux INSTALL_TOP="$luadir" &> /dev/null | ||
| 151 | make install INSTALL_TOP="$luadir" &> /dev/null | ||
| 152 | fi | ||
| 153 | popd | ||
| 154 | [ -e ~/.ssh/id_rsa.pub ] || ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa | ||
| 155 | cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys | ||
| 156 | chmod og-wx ~/.ssh/authorized_keys | ||
| 157 | ssh-keyscan localhost >> ~/.ssh/known_hosts | ||
| 158 | else | ||
| 159 | luadir="/Programs/Lua/Current" | ||
| 160 | if [ ! -e "$luadir" ] | ||
| 161 | then | ||
| 162 | luadir="/usr/local" | ||
| 163 | fi | ||
| 164 | fi | ||
| 165 | |||
| 166 | if [ `uname -m` = i686 ] | ||
| 167 | then | ||
| 168 | platform="linux-x86" | ||
| 169 | else | ||
| 170 | platform="linux-x86_64" | ||
| 171 | fi | ||
| 172 | |||
| 173 | lua="$luadir/bin/lua" | ||
| 174 | |||
| 175 | version_luasocket=3.0rc1 | ||
| 176 | verrev_luasocket=${version_luasocket}-1 | ||
| 177 | srcdir_luasocket=luasocket-3.0-rc1 | ||
| 178 | |||
| 179 | version_cprint=0.1 | ||
| 180 | verrev_cprint=0.1-2 | ||
| 181 | |||
| 182 | new_version_say=1.2-1 | ||
| 183 | old_version_say=1.0-1 | ||
| 184 | |||
| 185 | version_luacov=0.11.0 | ||
| 186 | verrev_luacov=${version_luacov}-1 | ||
| 187 | version_lxsh=0.8.6 | ||
| 188 | version_validate_args=1.5.4 | ||
| 189 | verrev_validate_args=1.5.4-1 | ||
| 190 | verrev_lxsh=${version_lxsh}-2 | ||
| 191 | version_abelhas=1.0 | ||
| 192 | verrev_abelhas=${version_abelhas}-1 | ||
| 193 | |||
| 194 | luasec=luasec | ||
| 195 | |||
| 196 | cd .. | ||
| 197 | ./configure --with-lua="$luadir" --prefix="$testing_lrprefix" | ||
| 198 | make clean | ||
| 199 | make src/luarocks/site_config.lua | ||
| 200 | make dev | ||
| 201 | cd src | ||
| 202 | basedir=$PWD | ||
| 203 | run_lua() { | ||
| 204 | if [ "$1" = "--noecho" ]; then shift; noecho=1; else noecho=0; fi | ||
| 205 | if [ "$1" = "--nocov" ]; then shift; nocov=1; else nocov=0; fi | ||
| 206 | if [ "$noecho" = 0 ] | ||
| 207 | then | ||
| 208 | echo $* | ||
| 209 | fi | ||
| 210 | cmd=$1 | ||
| 211 | shift | ||
| 212 | if [ "$nocov" = 0 ] | ||
| 213 | then | ||
| 214 | "$lua" -e"require('luacov.runner')('$testing_dir/luacov.config')" "$basedir/bin/$cmd" "$@" | ||
| 215 | else | ||
| 216 | "$lua" "$basedir/bin/$cmd" "$@" | ||
| 217 | fi | ||
| 218 | } | ||
| 219 | luarocks="run_lua luarocks" | ||
| 220 | luarocks_nocov="run_lua --nocov luarocks" | ||
| 221 | luarocks_noecho="run_lua --noecho luarocks" | ||
| 222 | luarocks_noecho_nocov="run_lua --noecho --nocov luarocks" | ||
| 223 | luarocks_admin="run_lua luarocks-admin" | ||
| 224 | luarocks_admin_nocov="run_lua --nocov luarocks-admin" | ||
| 225 | |||
| 226 | ################################################### | ||
| 227 | |||
| 228 | mkdir -p "$testing_server" | ||
| 229 | ( | ||
| 230 | cd "$testing_server" | ||
| 231 | luarocks_repo="https://luarocks.org" | ||
| 232 | get() { [ -e `basename "$1"` ] || wget -c "$1"; } | ||
| 233 | get "$luarocks_repo/luacov-${verrev_luacov}.src.rock" | ||
| 234 | get "$luarocks_repo/luacov-${verrev_luacov}.rockspec" | ||
| 235 | get "$luarocks_repo/luadoc-3.0.1-1.src.rock" | ||
| 236 | get "$luarocks_repo/lualogging-1.3.0-1.src.rock" | ||
| 237 | get "$luarocks_repo/luasocket-${verrev_luasocket}.src.rock" | ||
| 238 | get "$luarocks_repo/luasocket-${verrev_luasocket}.rockspec" | ||
| 239 | get "$luarocks_repo/luafilesystem-1.6.3-1.src.rock" | ||
| 240 | get "$luarocks_repo/stdlib-41.0.0-1.src.rock" | ||
| 241 | get "$luarocks_repo/luarepl-0.4-1.src.rock" | ||
| 242 | get "$luarocks_repo/validate-args-1.5.4-1.rockspec" | ||
| 243 | get "$luarocks_repo/luasec-0.6-1.rockspec" | ||
| 244 | get "$luarocks_repo/luabitop-1.0.2-1.rockspec" | ||
| 245 | get "$luarocks_repo/luabitop-1.0.2-1.src.rock" | ||
| 246 | get "$luarocks_repo/lpty-1.0.1-1.src.rock" | ||
| 247 | get "$luarocks_repo/cprint-${verrev_cprint}.src.rock" | ||
| 248 | get "$luarocks_repo/cprint-${verrev_cprint}.rockspec" | ||
| 249 | get "$luarocks_repo/wsapi-1.6-1.src.rock" | ||
| 250 | get "$luarocks_repo/lxsh-${verrev_lxsh}.src.rock" | ||
| 251 | get "$luarocks_repo/lxsh-${verrev_lxsh}.rockspec" | ||
| 252 | get "$luarocks_repo/abelhas-${verrev_abelhas}.rockspec" | ||
| 253 | get "$luarocks_repo/lzlib-0.4.1.53-1.src.rock" | ||
| 254 | get "$luarocks_repo/lpeg-0.12-1.src.rock" | ||
| 255 | get "$luarocks_repo/luaposix-33.2.1-1.src.rock" | ||
| 256 | get "$luarocks_repo/md5-1.2-1.src.rock" | ||
| 257 | get "$luarocks_repo/lmathx-20120430.51-1.src.rock" | ||
| 258 | get "$luarocks_repo/lmathx-20120430.51-1.rockspec" | ||
| 259 | get "$luarocks_repo/lmathx-20120430.52-1.src.rock" | ||
| 260 | get "$luarocks_repo/lmathx-20120430.52-1.rockspec" | ||
| 261 | get "$luarocks_repo/lmathx-20150505-1.src.rock" | ||
| 262 | get "$luarocks_repo/lmathx-20150505-1.rockspec" | ||
| 263 | get "$luarocks_repo/lua-path-0.2.3-1.src.rock" | ||
| 264 | get "$luarocks_repo/lua-cjson-2.1.0-1.src.rock" | ||
| 265 | get "$luarocks_repo/luacov-coveralls-0.1.1-1.src.rock" | ||
| 266 | get "$luarocks_repo/say-1.2-1.src.rock" | ||
| 267 | get "$luarocks_repo/say-1.0-1.src.rock" | ||
| 268 | get "$luarocks_repo/luassert-1.7.0-1.src.rock" | ||
| 269 | ) | ||
| 270 | $luarocks_admin_nocov make_manifest "$testing_server" | ||
| 271 | |||
| 272 | ################################################### | ||
| 273 | |||
| 274 | checksum_path() { | ||
| 275 | ( cd "$1"; find . -printf "%s %p\n" | md5sum ) | ||
| 276 | } | ||
| 277 | |||
| 278 | build_environment() { | ||
| 279 | rm -rf "$testing_tree" | ||
| 280 | rm -rf "$testing_sys_tree" | ||
| 281 | rm -rf "$testing_tree_copy" | ||
| 282 | rm -rf "$testing_sys_tree_copy" | ||
| 283 | mkdir -p "$testing_tree" | ||
| 284 | mkdir -p "$testing_sys_tree" | ||
| 285 | $luarocks_admin_nocov make_manifest "$testing_cache" | ||
| 286 | for package in "$@" | ||
| 287 | do | ||
| 288 | $luarocks_nocov install --only-server="$testing_cache" --tree="$testing_sys_tree" $package || { | ||
| 289 | $luarocks_nocov build --tree="$testing_sys_tree" $package | ||
| 290 | $luarocks_nocov pack --tree="$testing_sys_tree" $package; mv $package-*.rock "$testing_cache" | ||
| 291 | } | ||
| 292 | done | ||
| 293 | export LUA_PATH= | ||
| 294 | export LUA_CPATH= | ||
| 295 | eval `$luarocks_noecho_nocov path --bin` | ||
| 296 | cp -a "$testing_tree" "$testing_tree_copy" | ||
| 297 | cp -a "$testing_sys_tree" "$testing_sys_tree_copy" | ||
| 298 | testing_tree_copy_md5=`checksum_path "$testing_tree_copy"` | ||
| 299 | testing_sys_tree_copy_md5=`checksum_path "$testing_sys_tree_copy"` | ||
| 300 | } | ||
| 301 | |||
| 302 | reset_environment() { | ||
| 303 | testing_tree_md5=`checksum_path "$testing_tree"` | ||
| 304 | testing_sys_tree_md5=`checksum_path "$testing_sys_tree"` | ||
| 305 | if [ "$testing_tree_md5" != "$testing_tree_copy_md5" ] | ||
| 306 | then | ||
| 307 | rm -rf "$testing_tree" | ||
| 308 | cp -a "$testing_tree_copy" "$testing_tree" | ||
| 309 | fi | ||
| 310 | if [ "$testing_sys_tree_md5" != "$testing_sys_tree_copy_md5" ] | ||
| 311 | then | ||
| 312 | rm -rf "$testing_sys_tree" | ||
| 313 | cp -a "$testing_sys_tree_copy" "$testing_sys_tree" | ||
| 314 | fi | ||
| 315 | } | ||
| 316 | |||
| 317 | need() { | ||
| 318 | echo "Obtaining $1 $2..." | ||
| 319 | if $luarocks show $1 &> /dev/null | ||
| 320 | then | ||
| 321 | echo "Already available" | ||
| 322 | return | ||
| 323 | fi | ||
| 324 | platrock="$1-$2.$platform.rock" | ||
| 325 | if [ ! -e "$testing_cache/$platrock" ] | ||
| 326 | then | ||
| 327 | echo "Building $1 $2..." | ||
| 328 | $luarocks_nocov build --pack-binary-rock $1 $2 | ||
| 329 | mv "$platrock" "$testing_cache" | ||
| 330 | fi | ||
| 331 | echo "Installing $1 $2..." | ||
| 332 | $luarocks_nocov install "$testing_cache/$platrock" | ||
| 333 | return | ||
| 334 | } | ||
| 335 | need_luasocket() { need luasocket $verrev_luasocket; } | ||
| 336 | |||
| 337 | # Tests ######################################### | ||
| 338 | test_version() { $luarocks --version; } | ||
| 339 | |||
| 340 | fail_unknown_command() { $luarocks unknown_command; } | ||
| 341 | |||
| 342 | fail_arg_boolean_parameter() { $luarocks --porcelain=invalid; } | ||
| 343 | fail_arg_boolean_unknown() { $luarocks --invalid-flag; } | ||
| 344 | fail_arg_string_no_parameter() { $luarocks --server; } | ||
| 345 | fail_arg_string_followed_by_flag() { $luarocks --server --porcelain; } | ||
| 346 | fail_arg_string_unknown() { $luarocks --invalid-flag=abc; } | ||
| 347 | |||
| 348 | fail_invalid_assignment() { $luarocks invalid=5; } | ||
| 349 | |||
| 350 | test_empty_list() { $luarocks list; } | ||
| 351 | test_list_outdated() { $luarocks list --outdated; } | ||
| 352 | |||
| 353 | fail_sysconfig_err() { local err=0; local scdir="$testing_lrprefix/etc/luarocks/"; mkdir -p "$scdir"; local sysconfig="$scdir/config.lua"; echo "aoeui" > "$sysconfig"; echo $sysconfig; $luarocks list; err=$?; rm "$sysconfig"; return "$err"; } | ||
| 354 | fail_sysconfig_default_err() { local err=0; local scdir="$testing_lrprefix/etc/luarocks/"; mkdir -p "$scdir"; local sysconfig="$scdir/config-$luashortversion.lua"; echo "aoeui" > "$sysconfig"; echo $sysconfig; $luarocks list; err=$?; rm "$sysconfig"; return "$err"; } | ||
| 355 | |||
| 356 | fail_build_noarg() { $luarocks build; } | ||
| 357 | fail_download_noarg() { $luarocks download; } | ||
| 358 | fail_install_noarg() { $luarocks install; } | ||
| 359 | fail_lint_noarg() { $luarocks lint; } | ||
| 360 | fail_search_noarg() { $luarocks search; } | ||
| 361 | fail_show_noarg() { $luarocks show; } | ||
| 362 | fail_unpack_noarg() { $luarocks unpack; } | ||
| 363 | fail_upload_noarg() { $luarocks upload; } | ||
| 364 | fail_remove_noarg() { $luarocks remove; } | ||
| 365 | fail_doc_noarg() { $luarocks doc; } | ||
| 366 | |||
| 367 | fail_build_invalid() { $luarocks build invalid; } | ||
| 368 | fail_download_invalid() { $luarocks download invalid; } | ||
| 369 | fail_install_invalid() { $luarocks install invalid; } | ||
| 370 | fail_lint_invalid() { $luarocks lint invalid; } | ||
| 371 | fail_show_invalid() { $luarocks show invalid; } | ||
| 372 | fail_new_version_invalid() { $luarocks new_version invalid; } | ||
| 373 | |||
| 374 | test_list_invalidtree() { $luarocks --tree=/some/invalid/tree list; } | ||
| 375 | |||
| 376 | fail_inexistent_dir() { mkdir idontexist; cd idontexist; rmdir ../idontexist; $luarocks; err=$?; cd ..; return $err; } | ||
| 377 | |||
| 378 | fail_make_norockspec() { $luarocks make; } | ||
| 379 | |||
| 380 | fail_build_permissions() { $luarocks build --tree=/usr lpeg; } | ||
| 381 | fail_build_permissions_parent() { $luarocks build --tree=/usr/invalid lpeg; } | ||
| 382 | |||
| 383 | test_build_verbose() { $luarocks build --verbose lpeg; } | ||
| 384 | test_build_timeout() { $luarocks --timeout=10; } | ||
| 385 | fail_build_timeout_invalid() { $luarocks --timeout=abc; } | ||
| 386 | test_build_branch() { $luarocks build --branch=master lpeg; } | ||
| 387 | fail_build_invalid_entry_deps_mode() { $luarocks build --deps-mode=123 lpeg; } | ||
| 388 | test_build_only_server() { $luarocks --only-server=testing; } | ||
| 389 | test_build_only_sources() { $luarocks build --only-sources="http://example.com" lpeg; } | ||
| 390 | fail_build_blank_arg() { $luarocks build --tree="" lpeg; } | ||
| 391 | test_build_withpatch() { need_luasocket; $luarocks build luadoc; } | ||
| 392 | test_build_diffversion() { $luarocks build luacov ${version_luacov}; } | ||
| 393 | test_build_command() { $luarocks build stdlib; } | ||
| 394 | test_build_install_bin() { $luarocks build luarepl; } | ||
| 395 | test_build_nohttps() { need_luasocket; $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks build ./validate-args-${version_validate_args}-1.rockspec && rm ./validate-args-${version_validate_args}-1.rockspec; } | ||
| 396 | test_build_https() { need_luasocket; $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks install $luasec && $luarocks build ./validate-args-${verrev_validate_args}.rockspec && rm ./validate-args-${verrev_validate_args}.rockspec; } | ||
| 397 | test_build_supported_platforms() { $luarocks build lpty; } | ||
| 398 | test_build_only_deps_rockspec() { $luarocks download --rockspec lxsh ${verrev_lxsh} && $luarocks build ./lxsh-${verrev_lxsh}.rockspec --only-deps && { $luarocks show lxsh; [ $? -ne 0 ]; }; } | ||
| 399 | test_build_only_deps_src_rock() { $luarocks download --source lxsh ${verrev_lxsh} && $luarocks build ./lxsh-${verrev_lxsh}.src.rock --only-deps && { $luarocks show lxsh; [ $? -ne 0 ]; }; } | ||
| 400 | test_build_only_deps() { $luarocks build luasec --only-deps && { $luarocks show luasec; [ $? -ne 0 ]; }; } | ||
| 401 | test_install_only_deps() { $luarocks install lxsh ${verrev_lxsh} --only-deps && { $luarocks show lxsh; [ $? -ne 0 ]; }; } | ||
| 402 | test_build_no_deps() { $luarocks build luasec --nodeps; } | ||
| 403 | test_install_no_deps() { $luarocks install luasec --nodeps; } | ||
| 404 | fail_build_missing_external() { $luarocks build "$testing_dir/testfiles/missing_external-0.1-1.rockspec" INEXISTENT_INCDIR="/invalid/dir"; } | ||
| 405 | fail_build_invalidpatch() { need_luasocket; $luarocks build "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"; } | ||
| 406 | |||
| 407 | test_build_deps_partial_match() { $luarocks build lmathx; } | ||
| 408 | test_build_show_downloads() { export LUAROCKS_CONFIG="$testing_dir/testing_config_show_downloads.lua" && $luarocks build alien; export LUAROCKS_CONFIG="$testing_dir/testing_config.lua"; } | ||
| 409 | |||
| 410 | test_download_all() { $luarocks download --all validate-args && rm validate-args-*; } | ||
| 411 | test_download_rockspecversion() { $luarocks download --rockspec validate-args ${verrev_validate_args} && rm validate-args-*; } | ||
| 412 | |||
| 413 | test_help() { $luarocks help; } | ||
| 414 | fail_help_invalid() { $luarocks help invalid; } | ||
| 415 | |||
| 416 | test_install_only_deps() { $luarocks install --only-deps "$testing_cache/luasocket-$verrev_luasocket.$platform.rock"; } | ||
| 417 | test_install_binaryrock() { $luarocks build --pack-binary-rock cprint && $luarocks install ./cprint-${verrev_cprint}.${platform}.rock && rm ./cprint-${verrev_cprint}.${platform}.rock; } | ||
| 418 | test_install_with_bin() { $luarocks install wsapi; } | ||
| 419 | fail_install_notazipfile() { $luarocks install "$testing_dir/testfiles/not_a_zipfile-1.0-1.src.rock"; } | ||
| 420 | fail_install_invalidpatch() { need_luasocket; $luarocks install "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"; } | ||
| 421 | fail_install_invalid_filename() { $luarocks install "invalid.rock"; } | ||
| 422 | fail_install_invalid_arch() { $luarocks install "foo-1.0-1.impossible-x86.rock"; } | ||
| 423 | test_install_reinstall() { $luarocks install "$testing_cache/luasocket-$verrev_luasocket.$platform.rock"; $luarocks install --deps-mode=none "$testing_cache/luasocket-$verrev_luasocket.$platform.rock"; } | ||
| 424 | |||
| 425 | fail_local_root() { USER=root $luarocks install --local luasocket; } | ||
| 426 | |||
| 427 | test_site_config() { mv ../src/luarocks/site_config.lua ../src/luarocks/site_config.lua.tmp; $luarocks; mv ../src/luarocks/site_config.lua.tmp ../src/luarocks/site_config.lua; } | ||
| 428 | |||
| 429 | test_lint_ok() { $luarocks download --rockspec validate-args ${verrev_validate_args} && $luarocks lint ./validate-args-${verrev_validate_args}.rockspec && rm ./validate-args-${verrev_validate_args}.rockspec; } | ||
| 430 | fail_lint_type_mismatch_string() { $luarocks lint "$testing_dir/testfiles/type_mismatch_string-1.0-1.rockspec"; } | ||
| 431 | fail_lint_type_mismatch_version() { $luarocks lint "$testing_dir/testfiles/type_mismatch_version-1.0-1.rockspec"; } | ||
| 432 | fail_lint_type_mismatch_table() { $luarocks lint "$testing_dir/testfiles/type_mismatch_table-1.0-1.rockspec"; } | ||
| 433 | fail_lint_no_build_table() { $luarocks lint "$testing_dir/testfiles/no_build_table-0.1-1.rockspec"; } | ||
| 434 | |||
| 435 | test_list() { $luarocks list; } | ||
| 436 | test_list_porcelain() { $luarocks list --porcelain; } | ||
| 437 | |||
| 438 | test_make_with_rockspec() { rm -rf ./luasocket-${verrev_luasocket} && $luarocks download --source luasocket && $luarocks unpack ./luasocket-${verrev_luasocket}.src.rock && cd luasocket-${verrev_luasocket}/${srcdir_luasocket} && $luarocks make luasocket-${verrev_luasocket}.rockspec && cd ../.. && rm -rf ./luasocket-${verrev_luasocket}; } | ||
| 439 | test_make_default_rockspec() { rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && $luarocks new_version lxsh-${verrev_lxsh}.rockspec && $luarocks make && cd ../.. && rm -rf ./lxsh-${verrev_lxsh}; } | ||
| 440 | test_make_unnamed_rockspec() { rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && cp lxsh-${verrev_lxsh}.rockspec rockspec && $luarocks make && cd ../.. && rm -rf ./lxsh-${verrev_lxsh}; } | ||
| 441 | fail_make_ambiguous_rockspec() { rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && cp lxsh-${verrev_lxsh}.rockspec lxsh2-${verrev_lxsh}.rockspec && $luarocks make && cd ../.. && rm -rf ./lxsh-${verrev_lxsh}; } | ||
| 442 | fail_make_ambiguous_unnamed_rockspec() { rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && mv lxsh-${verrev_lxsh}.rockspec 1_rockspec && cp 1_rockspec 2_rockspec && $luarocks make && cd ../.. && rm -rf ./lxsh-${verrev_lxsh}; } | ||
| 443 | test_make_pack_binary_rock() { rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && $luarocks make --deps-mode=none --pack-binary-rock && [ -e ./lxsh-${verrev_lxsh}.all.rock ] && cd ../.. && rm -rf ./lxsh-${verrev_lxsh}; } | ||
| 444 | |||
| 445 | test_new_version() { $luarocks download --rockspec luacov ${version_luacov} && $luarocks new_version ./luacov-${version_luacov}-1.rockspec 0.2 && rm ./luacov-0.*; } | ||
| 446 | test_new_version_url() { $luarocks download --rockspec abelhas 1.0 && $luarocks new_version ./abelhas-1.0-1.rockspec 1.1 https://github.com/downloads/ittner/abelhas/abelhas-1.1.tar.gz && rm ./abelhas-*; } | ||
| 447 | test_new_version_tag() { $luarocks download --rockspec luacov ${version_luacov} && $luarocks new_version ./luacov-${version_luacov}-1.rockspec --tag v0.3 && rm ./luacov-0.3-1.rockspec; } | ||
| 448 | test_new_version_tag_without_arg() { rm -rf ./*rockspec && $luarocks download --rockspec luacov ${version_luacov} && $luarocks new_version --tag v0.3 && rm ./luacov-0.3-1.rockspec; } | ||
| 449 | |||
| 450 | test_pack() { $luarocks list && $luarocks pack luacov && rm ./luacov-*.rock; } | ||
| 451 | test_pack_src() { $luarocks install $luasec && $luarocks download --rockspec luasocket && $luarocks pack ./luasocket-${verrev_luasocket}.rockspec && rm ./luasocket-${version_luasocket}-*.rock; } | ||
| 452 | |||
| 453 | test_path() { $luarocks path --bin; } | ||
| 454 | test_path_lr_path() { $luarocks path --lr-path; } | ||
| 455 | test_path_lr_cpath() { $luarocks path --lr-cpath; } | ||
| 456 | test_path_lr_bin() { $luarocks path --lr-bin; } | ||
| 457 | test_path_with_tree() { $luarocks path --tree=lua_modules; } | ||
| 458 | |||
| 459 | fail_purge_missing_tree() { $luarocks purge --tree="$testing_tree"; } | ||
| 460 | fail_purge_tree_notstring() { $luarocks purge --tree=1; } | ||
| 461 | test_purge() { $luarocks purge --tree="$testing_sys_tree"; } | ||
| 462 | test_purge_oldversions() { $luarocks purge --old-versions --tree="$testing_sys_tree"; } | ||
| 463 | |||
| 464 | test_remove() { $luarocks build abelhas ${version_abelhas} && $luarocks remove abelhas ${version_abelhas}; } | ||
| 465 | test_remove_force() { need_luasocket; $luarocks build lualogging && $luarocks remove --force luasocket; } | ||
| 466 | test_remove_force_fast() { need_luasocket; $luarocks build lualogging && $luarocks remove --force-fast luasocket; } | ||
| 467 | fail_remove_deps() { need_luasocket; $luarocks build lualogging && $luarocks remove luasocket; } | ||
| 468 | fail_remove_missing() { $luarocks remove missing_rock; } | ||
| 469 | fail_remove_invalid_name() { $luarocks remove invalid.rock; } | ||
| 470 | |||
| 471 | test_search_found() { $luarocks search zlib; } | ||
| 472 | test_search_missing() { $luarocks search missing_rock; } | ||
| 473 | test_search_version() { $luarocks search zlib 1.1; } | ||
| 474 | test_search_all() { $luarocks search --all; } | ||
| 475 | fail_search_nostring() { $var=123; $luarocks search $var; } | ||
| 476 | |||
| 477 | test_show() { $luarocks show luacov; } | ||
| 478 | test_show_modules() { $luarocks show --modules luacov; } | ||
| 479 | test_show_home() { $luarocks show --home luacov; } | ||
| 480 | test_show_deps() { $luarocks show --deps luacov; } | ||
| 481 | test_show_rockspec() { $luarocks show --rockspec luacov; } | ||
| 482 | test_show_mversion() { $luarocks show --mversion luacov; } | ||
| 483 | test_show_rocktree() { $luarocks show --rock-tree luacov; } | ||
| 484 | test_show_rockdir() { $luarocks show --rock-dir luacov; } | ||
| 485 | test_show_depends() { need_luasocket; $luarocks install $luasec && $luarocks show luasec; } | ||
| 486 | test_show_oldversion() { $luarocks install luacov ${version_luacov} && $luarocks show luacov ${version_luacov}; } | ||
| 487 | |||
| 488 | test_unpack_download() { rm -rf ./cprint-${verrev_cprint} && $luarocks unpack cprint && rm -rf ./cprint-${verrev_cprint}; } | ||
| 489 | test_unpack_src() { rm -rf ./cprint-${verrev_cprint} && $luarocks download --source cprint && $luarocks unpack ./cprint-${verrev_cprint}.src.rock && rm -rf ./cprint-${verrev_cprint}; } | ||
| 490 | test_unpack_rockspec() { rm -rf ./cprint-${verrev_cprint} && $luarocks download --rockspec cprint && $luarocks unpack ./cprint-${verrev_cprint}.rockspec && rm -rf ./cprint-${verrev_cprint}; } | ||
| 491 | test_unpack_binary() { rm -rf ./cprint-${verrev_cprint} && $luarocks build cprint && $luarocks pack cprint && $luarocks unpack ./cprint-${verrev_cprint}.${platform}.rock && rm -rf ./cprint-${verrev_cprint}; } | ||
| 492 | fail_unpack_invalidpatch() { need_luasocket; $luarocks unpack "$testing_dir/testfiles/invalid_patch-0.1-1.rockspec"; } | ||
| 493 | fail_unpack_invalidrockspec() { need_luasocket; $luarocks unpack "invalid.rockspec"; } | ||
| 494 | |||
| 495 | fail_upload_invalidrockspec() { $luarocks upload "invalid.rockspec"; } | ||
| 496 | fail_upload_invalidkey() { $luarocks upload --api-key="invalid" "invalid.rockspec"; } | ||
| 497 | fail_upload_skippack() { $luarocks upload --api-key="invalid" --skip-pack "luacov-${verrev_luacov}.rockspec"; } | ||
| 498 | fail_upload_force() { $luarocks install lua-cjson && $luarocks upload --api-key="invalid" --force "luacov-${verrev_luacov}.rockspec" && $luarocks remove lua-cjson; } | ||
| 499 | |||
| 500 | |||
| 501 | test_admin_help() { $luarocks_admin help; } | ||
| 502 | |||
| 503 | test_admin_make_manifest() { $luarocks_admin make_manifest; } | ||
| 504 | test_admin_add_rsync() { $luarocks_admin --server=testing add "$testing_server/luasocket-${verrev_luasocket}.src.rock"; } | ||
| 505 | test_admin_add_sftp() { export LUAROCKS_CONFIG="$testing_dir/testing_config_sftp.lua" && $luarocks_admin --server=testing add ./luasocket-${verrev_luasocket}.src.rock; export LUAROCKS_CONFIG="$testing_dir/testing_config.lua"; } | ||
| 506 | fail_admin_add_missing() { $luarocks_admin --server=testing add; } | ||
| 507 | fail_admin_invalidserver() { $luarocks_admin --server=invalid add "$testing_server/luasocket-${verrev_luasocket}.src.rock"; } | ||
| 508 | fail_admin_invalidrock() { $luarocks_admin --server=testing add invalid; } | ||
| 509 | test_admin_refresh_cache() { $luarocks_admin --server=testing refresh_cache; } | ||
| 510 | test_admin_remove() { $luarocks_admin --server=testing remove luasocket-${verrev_luasocket}.src.rock; } | ||
| 511 | fail_admin_remove_missing() { $luarocks_admin --server=testing remove; } | ||
| 512 | fail_admin_split_server_url() { $luarocks_admin --server="localhost@/tmp/luarocks_testing" add "$testing_server/luasocket-${verrev_luasocket}.src.rock"; } | ||
| 513 | |||
| 514 | fail_deps_mode_invalid_arg() { $luarocks remove luacov --deps-mode; } | ||
| 515 | test_deps_mode_one() { $luarocks build --tree="system" lpeg && $luarocks list && $luarocks build --deps-mode=one --tree="$testing_tree" lxsh && [ `$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg | wc -l` = 1 ]; } | ||
| 516 | test_deps_mode_order() { $luarocks build --tree="system" lpeg && $luarocks build --deps-mode=order --tree="$testing_tree" lxsh && $luarocks_noecho list --tree="$testing_tree" --porcelain lpeg && [ `$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ]; } | ||
| 517 | test_deps_mode_order_sys() { $luarocks build --tree="$testing_tree" lpeg && $luarocks build --deps-mode=order --tree="$testing_sys_tree" lxsh && [ `$luarocks_noecho list --tree="$testing_sys_tree" --porcelain lpeg | wc -l` = 1 ]; } | ||
| 518 | test_deps_mode_all_sys() { $luarocks build --tree="$testing_tree" lpeg && $luarocks build --deps-mode=all --tree="$testing_sys_tree" lxsh && [ `$luarocks_noecho list --tree="$testing_sys_tree" --porcelain lpeg | wc -l` = 0 ]; } | ||
| 519 | test_deps_mode_none() { $luarocks build --tree="$testing_tree" --deps-mode=none lxsh; [ `$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ]; } | ||
| 520 | test_deps_mode_nodeps_alias() { $luarocks build --tree="$testing_tree" --nodeps lxsh; [ `$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ]; } | ||
| 521 | test_deps_mode_make_order() { $luarocks build --tree="$testing_sys_tree" lpeg && rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && $luarocks make --tree="$testing_tree" --deps-mode=order && cd ../.. && [ `$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg | wc -l` = 0 ] && rm -rf ./lxsh-${verrev_lxsh}; } | ||
| 522 | test_deps_mode_make_order_sys() { $luarocks build --tree="$testing_tree" lpeg && rm -rf ./lxsh-${verrev_lxsh} && $luarocks download --source lxsh ${verrev_lxsh} && $luarocks unpack ./lxsh-${verrev_lxsh}.src.rock && cd lxsh-${verrev_lxsh}/lxsh-${version_lxsh}-1 && $luarocks make --tree="$testing_sys_tree" --deps-mode=order && cd ../.. && [ `$luarocks_noecho list --tree="$testing_tree" --porcelain lpeg | wc -l` = 1 ] && rm -rf ./lxsh-${verrev_lxsh}; } | ||
| 523 | |||
| 524 | test_write_rockspec() { $luarocks write_rockspec git://github.com/keplerproject/luarocks; } | ||
| 525 | test_write_rockspec_name() { $luarocks write_rockspec luarocks git://github.com/keplerproject/luarocks; } | ||
| 526 | test_write_rockspec_name_version() { $luarocks write_rockspec luarocks 7.8.9 git://github.com/keplerproject/luarocks; } | ||
| 527 | test_write_rockspec_current_dir() { $luarocks write_rockspec; } | ||
| 528 | test_write_rockspec_tag() { $luarocks write_rockspec git://github.com/keplerproject/luarocks --tag=v2.3.0; } | ||
| 529 | test_write_rockspec_lib() { $luarocks write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license="3-clause BSD" --lua-version=5.1,5.2; } | ||
| 530 | test_write_rockspec_format() { $luarocks write_rockspec git://github.com/keplerproject/luarocks --rockspec-format=1.1 --lua-version=5.1,5.2; } | ||
| 531 | test_write_rockspec_fullargs() { $luarocks write_rockspec git://github.com/keplerproject/luarocks --lua-version=5.1,5.2 --license="MIT/X11" --homepage="http://www.luarocks.org" --summary="A package manager for Lua modules"; } | ||
| 532 | fail_write_rockspec_args() { $luarocks write_rockspec invalid; } | ||
| 533 | fail_write_rockspec_args_url() { $luarocks write_rockspec http://example.com/invalid.zip; } | ||
| 534 | test_write_rockspec_http() { $luarocks write_rockspec http://luarocks.org/releases/luarocks-2.1.0.tar.gz --lua-version=5.1; } | ||
| 535 | test_write_rockspec_basedir() { $luarocks write_rockspec https://github.com/downloads/Olivine-Labs/luassert/luassert-1.2.tar.gz --lua-version=5.1; } | ||
| 536 | |||
| 537 | fail_config_noflags() { $luarocks config; } | ||
| 538 | test_config_lua_incdir() { $luarocks config --lua-incdir; } | ||
| 539 | test_config_lua_libdir() { $luarocks config --lua-libdir; } | ||
| 540 | test_config_lua_ver() { $luarocks config --lua-ver; } | ||
| 541 | fail_config_system_config() { rm -f "$testing_lrprefix/etc/luarocks/config.lua"; $luarocks config --system-config; } | ||
| 542 | test_config_system_config() { mkdir -p "$testing_lrprefix/etc/luarocks"; touch "$testing_lrprefix/etc/luarocks/config.lua"; $luarocks config --system-config; err=$?; rm -f "$testing_lrprefix/etc/luarocks/config.lua"; return $err; } | ||
| 543 | fail_config_system_config_invalid() { mkdir -p "$testing_lrprefix/etc/luarocks"; echo "if if if" > "$testing_lrprefix/etc/luarocks/config.lua"; $luarocks config --system-config; err=$?; rm -f "$testing_lrprefix/etc/luarocks/config.lua"; return $err; } | ||
| 544 | test_config_user_config() { $luarocks config --user-config; } | ||
| 545 | fail_config_user_config() { LUAROCKS_CONFIG="/missing_file.lua" $luarocks config --user-config; } | ||
| 546 | test_config_rock_trees() { $luarocks config --rock-trees; } | ||
| 547 | test_config_help() { $luarocks help config; } | ||
| 548 | |||
| 549 | # Tests for https://github.com/keplerproject/luarocks/issues/375 | ||
| 550 | test_fetch_base_dir() { $lua <<EOF | ||
| 551 | local fetch = require "luarocks.fetch" | ||
| 552 | |||
| 553 | assert("v0.3" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3.zip")) | ||
| 554 | assert("lua-compat-5.2" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.zip")) | ||
| 555 | assert("lua-compat-5.2" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.gz")) | ||
| 556 | assert("lua-compat-5.2" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2.tar.bz2")) | ||
| 557 | assert("parser.moon" == fetch.url_to_base_dir("git://github.com/Cirru/parser.moon")) | ||
| 558 | assert("v0.3" == fetch.url_to_base_dir("https://github.com/hishamhm/lua-compat-5.2/archive/v0.3")) | ||
| 559 | EOF | ||
| 560 | } | ||
| 561 | |||
| 562 | test_doc() { $luarocks install luarepl; $luarocks doc luarepl; } | ||
| 563 | test_doc_home() { $luarocks install luacov; $luarocks doc luacov --home; } | ||
| 564 | fail_doc_invalid() { $luarocks doc invalid; } | ||
| 565 | test_doc_list() { $luarocks install luacov; $luarocks doc luacov --list; } | ||
| 566 | test_doc_local() { $luarocks install luacov; $luarocks doc luacov --local; } | ||
| 567 | test_doc_porcelain() { $luarocks install luacov; $luarocks doc luacov --porcelain; } | ||
| 568 | |||
| 569 | # Tests for https://github.com/keplerproject/luarocks/pull/552 | ||
| 570 | test_install_break_dependencies_warning() { need_luasocket; $luarocks install say ${new_version_say} && $luarocks install luassert && $luarocks install say ${old_version_say}; } | ||
| 571 | test_install_break_dependencies_force() { need_luasocket; $luarocks install say ${new_version_say} && $luarocks install luassert && $luarocks install --force say ${old_version_say}; } | ||
| 572 | test_install_break_dependencies_forcefast() { need_luasocket; $luarocks install say ${new_version_say} && $luarocks install luassert && $luarocks install --force-fast say ${old_version_say}; } | ||
| 573 | |||
| 574 | # Driver ######################################### | ||
| 575 | run_tests() { | ||
| 576 | grep "^test_$1.*(" < $testing_dir/testing.sh | cut -d'(' -f1 | while read test | ||
| 577 | do | ||
| 578 | echo "-------------------------------------------" | ||
| 579 | echo "$test" | ||
| 580 | echo "-------------------------------------------" | ||
| 581 | reset_environment | ||
| 582 | if $test | ||
| 583 | then | ||
| 584 | echo "OK: Expected success." | ||
| 585 | else | ||
| 586 | if [ $? = 99 ] | ||
| 587 | then echo "FAIL: Unexpected crash!"; exit 99 | ||
| 588 | fi | ||
| 589 | echo "FAIL: Unexpected failure."; exit 1 | ||
| 590 | fi | ||
| 591 | done | ||
| 592 | grep "^fail_$1.*(" < $testing_dir/testing.sh | cut -d'(' -f1 | while read test | ||
| 593 | do | ||
| 594 | echo "-------------------------------------------" | ||
| 595 | echo "$test" | ||
| 596 | echo "-------------------------------------------" | ||
| 597 | reset_environment | ||
| 598 | if $test | ||
| 599 | then echo "FAIL: Unexpected success."; exit 1 | ||
| 600 | else | ||
| 601 | if [ $? = 99 ] | ||
| 602 | then echo "FAIL: Unexpected crash!"; exit 99 | ||
| 603 | fi | ||
| 604 | echo "OK: Expected failure." | ||
| 605 | fi | ||
| 606 | done | ||
| 607 | } | ||
| 608 | |||
| 609 | run_with_minimal_environment() { | ||
| 610 | echo "===========================================" | ||
| 611 | echo "Running with minimal environment" | ||
| 612 | echo "===========================================" | ||
| 613 | build_environment luacov | ||
| 614 | run_tests $1 | ||
| 615 | } | ||
| 616 | |||
| 617 | run_with_full_environment() { | ||
| 618 | echo "===========================================" | ||
| 619 | echo "Running with full environment" | ||
| 620 | echo "===========================================" | ||
| 621 | |||
| 622 | local bitop= | ||
| 623 | [ "$luaversion" = "5.1.5" ] && bitop=luabitop | ||
| 624 | |||
| 625 | build_environment luacov luafilesystem luasocket $bitop luaposix md5 lzlib | ||
| 626 | run_tests $1 | ||
| 627 | } | ||
| 628 | |||
| 629 | run_all_tests() { | ||
| 630 | run_with_minimal_environment $1 | ||
| 631 | run_with_full_environment $1 | ||
| 632 | } | ||
| 633 | |||
| 634 | run_all_tests $1 | ||
| 635 | #run_with_minimal_environment $1 | ||
| 636 | |||
| 637 | cd "$testing_dir/.." | ||
| 638 | |||
| 639 | if [ "$travis" ] | ||
| 640 | then | ||
| 641 | if [ "$TRAVIS" ] | ||
| 642 | then | ||
| 643 | build_environment luacov luafilesystem luacov-coveralls | ||
| 644 | $testing_sys_tree/bin/luacov-coveralls -c "$testing_dir/luacov.config" || echo "ok" | ||
| 645 | fi | ||
| 646 | $testing_sys_tree/bin/luacov -c "$testing_dir/luacov.config" | ||
| 647 | grep "Summary" -B1 -A1000 "$testing_dir/luacov.report.out" | ||
| 648 | else | ||
| 649 | $testing_sys_tree/bin/luacov -c "$testing_dir/luacov.config" | ||
| 650 | cat "$testing_dir/luacov.report.out" | ||
| 651 | fi | ||
