diff options
Diffstat (limited to 'test/testing.lua')
| -rw-r--r-- | test/testing.lua | 483 |
1 files changed, 0 insertions, 483 deletions
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 | } | ||
