From 2f3c8648289bb4e22eee5f8ff8d27afca6592fa4 Mon Sep 17 00:00:00 2001 From: roboo Date: Sun, 21 Aug 2016 21:50:38 +0200 Subject: Windows and appveyor support for tests --- spec/add_spec.lua | 16 ++++---- spec/build_spec.lua | 89 ++++++++++++++++++++++++++++++--------------- spec/config_spec.lua | 70 +++++++++++++++++++++++++---------- spec/deps_spec.lua | 70 +++++++++++++++++------------------ spec/install_spec.lua | 36 +++++++++++------- spec/make_manifest_spec.lua | 2 +- spec/make_spec.lua | 43 ++++++++++++---------- spec/pack_spec.lua | 18 +++++---- spec/refresh_cache_spec.lua | 2 +- spec/remove_spec.lua | 6 +-- spec/search_spec.lua | 1 - spec/show_spec.lua | 6 ++- spec/unpack_spec.lua | 18 ++++----- spec/upload_spec.lua | 14 +++++-- spec/util_spec.lua | 59 ++++++++++++++++++++---------- 15 files changed, 277 insertions(+), 173 deletions(-) (limited to 'spec') diff --git a/spec/add_spec.lua b/spec/add_spec.lua index dca6f850..d42a97d0 100644 --- a/spec/add_spec.lua +++ b/spec/add_spec.lua @@ -5,8 +5,8 @@ local testing_paths = test_env.testing_paths test_env.unload_luarocks() local extra_rocks = { - "/luasocket-3.0rc1-1.src.rock", - "/luasocket-3.0rc1-1.rockspec" + "/luasocket-3.0rc1-2.src.rock", + "/luasocket-3.0rc1-2.rockspec" } describe("LuaRocks add tests #blackbox #b_add", function() @@ -25,20 +25,20 @@ describe("LuaRocks add tests #blackbox #b_add", function() end) it("LuaRocks-admin add invalid server", function() - assert.is_false(run.luarocks_admin_bool("--server=invalid add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-1.src.rock")) + assert.is_false(run.luarocks_admin_bool("--server=invalid add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock")) end) it("LuaRocks-admin add invalid server #ssh", function() - assert.is_true(run.luarocks_admin_bool("--server=testing add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-1.src.rock")) + assert.is_true(run.luarocks_admin_bool("--server=testing add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock")) end) - --TODO This test fails, sftp not implemented - it("LuaRocks-admin add invalid server", function() --? - 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" } )) + --TODO This test fails, sftp support not yet implemented + it("LuaRocks-admin add invalid server", function() + assert.is_false(run.luarocks_admin_bool("--server=testing add luasocket-3.0rc1-2.src.rock", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_sftp.lua" } )) end) it("LuaRocks-admin add, split server url", function() - assert.is_false(run.luarocks_admin_bool("--server=\"localhost@/tmp/luarocks_testing\" add " .. testing_paths.testing_server .. "luasocket-3.0rc1-1.src.rock")) + assert.is_false(run.luarocks_admin_bool("--server=\"localhost@/tmp/luarocks_testing\" add " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.src.rock")) end) end) end) diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 2ede5211..b4f838ca 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua @@ -12,15 +12,16 @@ local extra_rocks = { "/lmathx-20120430.52-1.rockspec", "/lmathx-20150505-1.src.rock", "/lmathx-20150505-1.rockspec", - "/lpeg-0.12-1.src.rock", + "/lpeg-1.0.0-1.rockspec", + "/lpeg-1.0.0-1.src.rock", "/lpty-1.0.1-1.src.rock", "/luadoc-3.0.1-1.src.rock", "/luafilesystem-1.6.3-1.src.rock", "/lualogging-1.3.0-1.src.rock", "/luarepl-0.4-1.src.rock", "/luasec-0.6-1.rockspec", - "/luasocket-3.0rc1-1.src.rock", - "/luasocket-3.0rc1-1.rockspec", + "/luasocket-3.0rc1-2.src.rock", + "/luasocket-3.0rc1-2.rockspec", "/lxsh-0.8.6-2.src.rock", "/lxsh-0.8.6-2.rockspec", "/stdlib-41.0.0-1.src.rock", @@ -57,27 +58,35 @@ describe("LuaRocks build tests #blackbox #b_build", function() end) it("LuaRocks build lpeg verbose", function() - assert.is.truthy(run.luarocks("build --verbose lpeg")) + assert.is_true(run.luarocks_bool("build --verbose lpeg")) end) it("LuaRocks build lpeg branch=master", function() assert.is_true(run.luarocks_bool("build --branch=master lpeg")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) end) it("LuaRocks build lpeg deps-mode=123", function() - assert.is_false(run.luarocks_bool("build --deps-mode=123 lpeg")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) + assert.is_false(run.luarocks_bool("build --deps-mode=123 lpeg --verbose")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) end) it("LuaRocks build lpeg only-sources example", function() - assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) + assert.is_true(run.luarocks_bool("download --rockspec lpeg")) + assert.is_false(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + + assert.is_true(run.luarocks_bool("download --source lpeg")) + assert.is_true(run.luarocks_bool("build --only-sources=\"http://example.com\" lpeg-1.0.0-1.src.rock")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + + assert.is_true(os.remove("lpeg-1.0.0-1.rockspec")) + assert.is_true(os.remove("lpeg-1.0.0-1.src.rock")) end) it("LuaRocks build lpeg with empty tree", function() assert.is_false(run.luarocks_bool("build --tree=\"\" lpeg")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) end) end) @@ -88,32 +97,47 @@ describe("LuaRocks build tests #blackbox #b_build", function() it("LuaRocks build luacov diff version", function() assert.is_true(run.luarocks_bool("build luacov 0.11.0-1")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luacov")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luacov/0.11.0-1/luacov-0.11.0-1.rockspec")) end) it("LuaRocks build command stdlib", function() assert.is_true(run.luarocks_bool("build stdlib")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/stdlib")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/stdlib/41.0.0-1/stdlib-41.0.0-1.rockspec")) end) it("LuaRocks build install bin luarepl", function() assert.is_true(run.luarocks_bool("build luarepl")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luarepl/0.4-1/luarepl-0.4-1.rockspec")) end) it("LuaRocks build supported platforms lpty", function() - assert.is_true(run.luarocks_bool(test_env.quiet("build lpty"))) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty")) + if test_env.TEST_TARGET_OS == "windows" then + assert.is_false(run.luarocks_bool("build lpty")) --Error: This rockspec for lpty does not support win32, windows platforms + else + assert.is_true(run.luarocks_bool(test_env.quiet("build lpty"))) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpty/1.0.1-1/lpty-1.0.1-1.rockspec")) + end end) it("LuaRocks build luasec with skipping dependency checks", function() - assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --nodeps"))) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) + if test_env.APPVEYOR then + assert.is_true(run.luarocks_bool("build luasec " .. test_env.APPVEYOR_OPENSSL .. " --nodeps")) + else + assert.is_true(run.luarocks_bool("build luasec --nodeps")) + end + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec")) end) it("LuaRocks build lmathx deps partial match", function() assert.is_true(run.luarocks_bool("build lmathx")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx")) + + if test_env.LUA_V == "5.1" or test_env.LUAJIT_V then + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx/20120430.51-1/lmathx-20120430.51-1.rockspec")) + elseif test_env.LUA_V == "5.2" then + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx/20120430.52-1/lmathx-20120430.52-1.rockspec")) + elseif test_env.LUA_V == "5.3" then + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lmathx/20150505-1/lmathx-20150505-1.rockspec")) + end end) end) @@ -126,17 +150,21 @@ describe("LuaRocks build tests #blackbox #b_build", function() end it("LuaRocks build luasec only deps", function() - assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --only-deps"))) + if test_env.APPVEYOR then + assert.is_true(run.luarocks_bool(test_env.quiet("build luasec " .. test_env.APPVEYOR_OPENSSL .. " --only-deps"))) + else + assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --only-deps"))) + end assert.is_false(run.luarocks_bool("show luasec")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec")) end) it("LuaRocks build only deps of downloaded rockspec of lxsh", function() assert.is_true(run.luarocks_bool("download --rockspec lxsh 0.8.6-2")) assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.rockspec --only-deps")) assert.is_false(run.luarocks_bool("show lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) assert.is_true(os.remove("lxsh-0.8.6-2.rockspec")) end) @@ -144,8 +172,8 @@ describe("LuaRocks build tests #blackbox #b_build", function() assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) assert.is.truthy(run.luarocks("build lxsh-0.8.6-2.src.rock --only-deps")) assert.is_false(run.luarocks_bool("show lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) end) @@ -154,19 +182,22 @@ describe("LuaRocks build tests #blackbox #b_build", function() assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) assert.is.truthy(run.luarocks("show validate-args")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args/1.5.4-1/validate-args-1.5.4-1.rockspec")) assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) end) it("LuaRocks build with https", function() assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) - assert.is_true(run.luarocks_bool(test_env.quiet("install luasec"))) + + if test_env.APPVEYOR then + assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.APPVEYOR_OPENSSL))) + else + assert.is_true(run.luarocks_bool(test_env.quiet("install luasec"))) + end assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) - assert.is.truthy(run.luarocks("show validate-args")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args")) - + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/validate-args/1.5.4-1/validate-args-1.5.4-1.rockspec")) assert.is_true(os.remove("validate-args-1.5.4-1.rockspec")) end) diff --git a/spec/config_spec.lua b/spec/config_spec.lua index 0dee8620..439d0493 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua @@ -2,6 +2,7 @@ local test_env = require("test/test_environment") local lfs = require("lfs") local run = test_env.run local testing_paths = test_env.testing_paths +local env_variables = test_env.env_variables local site_config test_env.unload_luarocks() @@ -21,12 +22,20 @@ describe("LuaRocks config tests #blackbox #b_config", function() it("LuaRocks config include dir", function() local output = run.luarocks("config --lua-incdir") - assert.are.same(output, site_config.LUA_INCDIR) + if test_env.TEST_TARGET_OS == "windows" then + assert.are.same(output, site_config.LUA_INCDIR:gsub("\\","/")) + else + assert.are.same(output, site_config.LUA_INCDIR) + end end) it("LuaRocks config library dir", function() local output = run.luarocks("config --lua-libdir") - assert.are.same(output, site_config.LUA_LIBDIR) + if test_env.TEST_TARGET_OS == "windows" then + assert.are.same(output, site_config.LUA_LIBDIR:gsub("\\","/")) + else + assert.are.same(output, site_config.LUA_LIBDIR) + end end) it("LuaRocks config lua version", function() @@ -53,38 +62,61 @@ describe("LuaRocks config tests #blackbox #b_config", function() end) describe("LuaRocks config - more complex tests", function() + local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" + local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" + local scname = scdir .. "/config.lua" + + local configfile + if test_env.TEST_TARGET_OS == "windows" then + configfile = versioned_scname + else + configfile = scname + end + it("LuaRocks fail system config", function() - os.remove(testing_paths.testing_lrprefix .. "/etc/luarocks/config.lua") - assert.is_false(run.luarocks_bool("config --system-config;")) + os.rename(versioned_scname, versioned_scname .. ".bak") + assert.is_false(run.luarocks_bool("config --system-config")) + os.rename(versioned_scname .. ".bak", versioned_scname) end) it("LuaRocks system config", function() - local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" lfs.mkdir(testing_paths.testing_lrprefix) lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - local sysconfig = io.open(scdir .. "/config.lua", "w+") - sysconfig:write(" ") - sysconfig:close() - - local output = run.luarocks("config --system-config;") - assert.are.same(output, scdir .. "/config.lua") - test_env.remove_dir(testing_paths.testing_lrprefix) + if test_env.TEST_TARGET_OS == "windows" then + local output = run.luarocks("config --system-config") + assert.are.same(output, versioned_scname) + else + sysconfig = io.open(scname, "w+") + sysconfig:write(" ") + sysconfig:close() + + local output = run.luarocks("config --system-config") + assert.are.same(output, scname) + os.remove(scname) + end end) it("LuaRocks fail system config invalid", function() - local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" lfs.mkdir(testing_paths.testing_lrprefix) lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - local sysconfig = io.open(scdir .. "/config.lua", "w+") - sysconfig:write("if if if") - sysconfig:close() - - assert.is_false(run.luarocks_bool("config --system-config;")) - test_env.remove_dir(testing_paths.testing_lrprefix) + if test_env.TEST_TARGET_OS == "windows" then + test_env.copy(versioned_scname, "versioned_scname_temp") + sysconfig = io.open(versioned_scname, "w+") + sysconfig:write("if if if") + sysconfig:close() + assert.is_false(run.luarocks_bool("config --system-config")) + test_env.copy("versioned_scname_temp", versioned_scname) + else + sysconfig = io.open(scname, "w+") + sysconfig:write("if if if") + sysconfig:close() + assert.is_false(run.luarocks_bool("config --system-config")) + os.remove(scname) + end end) end) end) diff --git a/spec/deps_spec.lua b/spec/deps_spec.lua index c1bd404d..e453c9a1 100644 --- a/spec/deps_spec.lua +++ b/spec/deps_spec.lua @@ -8,9 +8,9 @@ test_env.unload_luarocks() local extra_rocks = { "/lxsh-0.8.6-2.src.rock", "/lxsh-0.8.6-2.rockspec", - "/luasocket-3.0rc1-1.src.rock", - "/luasocket-3.0rc1-1.rockspec", - "/lpeg-0.12-1.src.rock" + "/luasocket-3.0rc1-2.src.rock", + "/luasocket-3.0rc1-2.rockspec", + "/lpeg-1.0.0-1.src.rock", } describe("LuaRocks deps tests #blackbox #b_deps", function() @@ -23,59 +23,59 @@ describe("LuaRocks deps tests #blackbox #b_deps", function() assert.is_true(run.luarocks_bool("build --tree=system lpeg")) assert.is_true(run.luarocks_bool("build --deps-mode=one --tree=" .. testing_paths.testing_tree .. " lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) + assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks deps mode order", function() assert.is_true(run.luarocks_bool("build --tree=system lpeg")) assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_tree .. " lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) + assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks deps mode order sys", function() assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) assert.is_true(run.luarocks_bool("build --deps-mode=order --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) + assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks deps mode all sys", function() assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) assert.is_true(run.luarocks_bool("build --deps-mode=all --tree=" .. testing_paths.testing_sys_tree .. " lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) + assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks deps mode none", function() assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " lpeg")) assert.is_true(run.luarocks_bool("build --deps-mode=none lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) + assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks nodeps alias", function() assert.is_true(run.luarocks_bool("build --tree=" .. testing_paths.testing_tree .. " --nodeps lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) + assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks deps mode make order", function() @@ -89,10 +89,10 @@ describe("LuaRocks deps tests #blackbox #b_deps", function() test_env.remove_dir("lxsh-0.8.6-2") assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) + assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks deps mode make order sys", function() @@ -106,9 +106,9 @@ describe("LuaRocks deps tests #blackbox #b_deps", function() test_env.remove_dir("lxsh-0.8.6-2") assert.is_true(os.remove("lxsh-0.8.6-2.src.rock")) - assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg")) - assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) + assert.is.truthy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) + assert.is.falsy(lfs.attributes(testing_paths.testing_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) end) diff --git a/spec/install_spec.lua b/spec/install_spec.lua index bd480c21..2b6cb77f 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua @@ -12,8 +12,8 @@ local extra_rocks = { "/lpeg-0.12-1.src.rock", "/luasec-0.6-1.rockspec", "/luassert-1.7.0-1.src.rock", - "/luasocket-3.0rc1-1.src.rock", - "/luasocket-3.0rc1-1.rockspec", + "/luasocket-3.0rc1-2.src.rock", + "/luasocket-3.0rc1-2.rockspec", "/lxsh-0.8.6-2.src.rock", "/lxsh-0.8.6-2.rockspec", "/say-1.2-1.src.rock", @@ -44,8 +44,8 @@ describe("LuaRocks install tests #blackbox #b_install", function() assert.is_false(run.luarocks_bool("install \"invalid.rock\" ")) end) - it("LuaRocks install with local flag as root", function() - assert.is_false(run.luarocks_bool("install --local luasocket", { USER = "root" } )) + it("LuaRocks install with local flag as root #unix", function() + assert.is_false(run.luarocks_bool("install --local luasocket ", { USER = "root" } )) end) it("LuaRocks install not a zip file", function() @@ -66,14 +66,22 @@ describe("LuaRocks install tests #blackbox #b_install", function() end) it("LuaRocks install luasec and show luasocket (dependency)", function() - assert.is_true(run.luarocks_bool("install luasec")) + if test_env.APPVEYOR then + assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.APPVEYOR_OPENSSL))) + else + assert.is_true(run.luarocks_bool(test_env.quiet("install luasec"))) + end assert.is_true(run.luarocks_bool("show luasocket")) end) end) describe("LuaRocks install - more complex tests", function() it('LuaRocks install luasec with skipping dependency checks', function() - run.luarocks_bool(test_env.quiet(" install luasec --nodeps")) + if test_env.APPVEYOR then + assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.APPVEYOR_OPENSSL .. " --nodeps"))) + else + assert.is_true(run.luarocks_bool(test_env.quiet("install luasec --nodeps"))) + end assert.is_true(run.luarocks_bool(test_env.quiet("show luasec"))) if env_variables.TYPE_TEST_ENV == "minimal" then assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket"))) @@ -83,17 +91,17 @@ describe("LuaRocks install tests #blackbox #b_install", function() end) it("LuaRocks install only-deps of luasocket packed rock", function() - assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-1"))) - local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock") - assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-1") - assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) + assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-2"))) + local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock") + assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-2") + assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) end) it("LuaRocks install reinstall", function() - assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-1"))) - assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) - assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) - assert.is_true(os.remove("luasocket-3.0rc1-1." .. test_env.platform .. ".rock")) + assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock luasocket 3.0rc1-2"))) + assert.is_true(run.luarocks_bool("install " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) + assert.is_true(run.luarocks_bool("install --deps-mode=none " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) + assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) end) it("LuaRocks install binary rock of cprint", function() diff --git a/spec/make_manifest_spec.lua b/spec/make_manifest_spec.lua index 1c7f5bf8..3e998cbf 100644 --- a/spec/make_manifest_spec.lua +++ b/spec/make_manifest_spec.lua @@ -4,7 +4,7 @@ local run = test_env.run test_env.unload_luarocks() describe("LuaRocks make_manifest tests #blackbox #b_make_manifest", function() - + before_each(function() test_env.setup_specs() end) diff --git a/spec/make_spec.lua b/spec/make_spec.lua index e684033a..624badff 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua @@ -6,9 +6,9 @@ local testing_paths = test_env.testing_paths test_env.unload_luarocks() local extra_rocks = { - "/lpeg-0.12-1.src.rock", - "/luasocket-3.0rc1-1.src.rock", - "/luasocket-3.0rc1-1.rockspec", + "lpeg-1.0.0-1.rockspec", + "/luasocket-3.0rc1-2.src.rock", + "/luasocket-3.0rc1-2.rockspec", "/lxsh-0.8.6-2.src.rock", "/lxsh-0.8.6-2.rockspec" } @@ -27,19 +27,19 @@ describe("LuaRocks make tests #blackbox #b_make", function() it("LuaRocks make with rockspec", function() -- make luasocket - assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-1")) - assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-1.src.rock")) - lfs.chdir("luasocket-3.0rc1-1/luasocket-3.0-rc1/") - assert.is_true(run.luarocks_bool(test_env.quiet("make luasocket-3.0rc1-1.rockspec"))) + assert.is_true(run.luarocks_bool("download --source luasocket 3.0rc1-2")) + assert.is_true(run.luarocks_bool("unpack luasocket-3.0rc1-2.src.rock")) + lfs.chdir("luasocket-3.0rc1-2/luasocket-3.0-rc1/") + assert.is_true(run.luarocks_bool(test_env.quiet("make luasocket-3.0rc1-2.rockspec"))) -- test it assert.is_true(run.luarocks_bool(test_env.quiet("show luasocket"))) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket/3.0rc1-2/luasocket-3.0rc1-2.rockspec")) -- delete downloaded and unpacked files lfs.chdir(testing_paths.luarocks_dir) - test_env.remove_dir("luasocket-3.0rc1-1") - assert.is_true(os.remove("luasocket-3.0rc1-1.src.rock")) + test_env.remove_dir("luasocket-3.0rc1-2") + assert.is_true(os.remove("luasocket-3.0rc1-2.src.rock")) end) describe("LuaRocks making rockspecs (using lxsh)", function() @@ -61,33 +61,36 @@ describe("LuaRocks make tests #blackbox #b_make", function() assert.is_true(run.luarocks_bool("new_version lxsh-0.8.6-2.rockspec")) assert.is_true(run.luarocks_bool("make")) - assert.is_true(run.luarocks_bool(test_env.quiet("show lxsh"))) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) + assert.is_true(run.luarocks_bool("show lxsh")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-3/lxsh-0.8.6-3.rockspec")) end) it("LuaRocks make unnamed rockspec", function() - os.execute("cp lxsh-0.8.6-2.rockspec rockspec") --rewrite with lfs + test_env.copy("lxsh-0.8.6-2.rockspec", "rockspec") assert.is_true(run.luarocks_bool("make")) assert.is_true(run.luarocks_bool(test_env.quiet("show lxsh"))) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) + os.remove("rockspec") end) it("LuaRocks make ambiguous rockspec", function() assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "lxsh2-0.8.6-2.rockspec")) - assert.is_false(run.luarocks_bool("make")) + local output = run.luarocks("make") + assert.is.truthy(output:match("Error: Inconsistency between rockspec filename")) assert.is_false(run.luarocks_bool("show lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) - + it("LuaRocks make ambiguous unnamed rockspec", function() assert.is.truthy(os.rename("lxsh-0.8.6-2.rockspec", "1_rockspec")) - os.execute("cp 1_rockspec 2_rockspec") --rewrite with lfs - assert.is_false(run.luarocks_bool("make")) + test_env.copy("1_rockspec", "2_rockspec") + local output = run.luarocks("make") + assert.is.truthy(output:match("Error: Please specify which rockspec file to use")) assert.is_false(run.luarocks_bool("show lxsh")) - assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/lxsh/0.8.6-2/lxsh-0.8.6-2.rockspec")) end) it("LuaRocks make pack binary rock", function() diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index 0e5b31c6..21f33b02 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua @@ -6,9 +6,10 @@ local testing_paths = test_env.testing_paths test_env.unload_luarocks() local extra_rocks = { - "/luasec-0.6-1.rockspec", - "/luasocket-3.0rc1-1.src.rock", - "/luasocket-3.0rc1-1.rockspec", + "/luasec-0.6-1.rockspec", + "/luassert-1.7.0-1.src.rock", + "/luasocket-3.0rc1-2.src.rock", + "/luasocket-3.0rc1-2.rockspec", "/say-1.2-1.src.rock", "/say-1.0-1.src.rock" } @@ -44,14 +45,17 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() assert.is_true(run.luarocks_bool("install say 1.2")) assert.is_true(run.luarocks_bool("install luassert")) assert.is_true(run.luarocks_bool("install say 1.0")) - assert.is_false(run.luarocks_bool("pack say")) end) it("LuaRocks pack src", function() - assert.is_true(run.luarocks_bool(test_env.quiet("install luasec"))) - assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-1")) - assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-1.rockspec")) + if test_env.APPVEYOR then + assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.APPVEYOR_OPENSSL))) + else + assert.is_true(run.luarocks_bool(test_env.quiet("install luasec"))) + end + assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-2")) + assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-2.rockspec")) assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-")) end) end) diff --git a/spec/refresh_cache_spec.lua b/spec/refresh_cache_spec.lua index c20771ab..09f5645e 100644 --- a/spec/refresh_cache_spec.lua +++ b/spec/refresh_cache_spec.lua @@ -4,7 +4,7 @@ local run = test_env.run test_env.unload_luarocks() describe("LuaRocks refresh_cache tests #blackbox #b_refresh_cache", function() - + before_each(function() test_env.setup_specs() end) diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index 7bf1bb10..3d321e30 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua @@ -8,8 +8,8 @@ test_env.unload_luarocks() local extra_rocks = { "/abelhas-1.0-1.rockspec", "/lualogging-1.3.0-1.src.rock", - "/luasocket-3.0rc1-1.src.rock", - "/luasocket-3.0rc1-1.rockspec" + "/luasocket-3.0rc1-2.src.rock", + "/luasocket-3.0rc1-2.rockspec" } describe("LuaRocks remove tests #blackbox #b_remove", function() @@ -76,7 +76,7 @@ describe("LuaRocks remove tests #blackbox #b_remove", function() end) it("LuaRocks-admin remove #ssh", function() - assert.is_true(run.luarocks_admin_bool("--server=testing remove luasocket-3.0rc1-1.src.rock")) + assert.is_true(run.luarocks_admin_bool("--server=testing remove luasocket-3.0rc1-2.src.rock")) end) it("LuaRocks-admin remove missing", function() diff --git a/spec/search_spec.lua b/spec/search_spec.lua index b31624b8..f75bc3c1 100644 --- a/spec/search_spec.lua +++ b/spec/search_spec.lua @@ -32,5 +32,4 @@ describe("LuaRocks search tests #blackbox #b_search", function() it("LuaRocks search with flag all", function() assert.is_true(run.luarocks_bool(test_env.quiet("search --all"))) end) - end) diff --git a/spec/show_spec.lua b/spec/show_spec.lua index f528a6de..915129ae 100644 --- a/spec/show_spec.lua +++ b/spec/show_spec.lua @@ -20,10 +20,12 @@ describe("LuaRocks show tests #blackbox #b_show", function() it("LuaRocks show luacov", function() local output = run.luarocks("show luacov") + assert.is.truthy(output:match("LuaCov")) end) it("LuaRocks show modules of luacov", function() local output = run.luarocks("show --modules luacov") + assert.is.truthy(output:match("luacovluacov.defaultsluacov.reporterluacov.reporter.defaultluacov.runnerluacov.statsluacov.tick")) end) it("LuaRocks show dependencies of luacov", function() @@ -32,10 +34,12 @@ describe("LuaRocks show tests #blackbox #b_show", function() it("LuaRocks show rockspec of luacov", function() local output = run.luarocks("show --rockspec luacov") + assert.is.truthy(output:match("luacov-0.11.0-1.rockspec")) end) it("LuaRocks show mversion of luacov", function() local output = run.luarocks("show --mversion luacov") + assert.is.truthy(output:match("0.11.0--1")) end) it("LuaRocks show rock tree of luacov", function() @@ -49,6 +53,6 @@ describe("LuaRocks show tests #blackbox #b_show", function() it("LuaRocks show old version of luacov", function() run.luarocks("install luacov 0.11.0") - run.luarocks("show luacov 0.11.0") + run.luarocks_bool("show luacov 0.11.0") end) end) diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua index 8db779c3..220ef00d 100644 --- a/spec/unpack_spec.lua +++ b/spec/unpack_spec.lua @@ -1,14 +1,12 @@ local test_env = require("test/test_environment") local run = test_env.run local testing_paths = test_env.testing_paths -local lfs = require("lfs") test_env.unload_luarocks() local extra_rocks = { "/cprint-0.1-2.src.rock", - "/cprint-0.1-2.rockspec", - "/luazip-1.2.4-1.rockspec" + "/cprint-0.1-2.rockspec" } describe("LuaRocks unpack tests #blackbox #b_unpack", function() @@ -21,9 +19,11 @@ describe("LuaRocks unpack tests #blackbox #b_unpack", function() it("LuaRocks unpack with no flags/arguments", function() assert.is_false(run.luarocks_bool("unpack")) end) + it("LuaRocks unpack with invalid rockspec", function() assert.is_false(run.luarocks_bool("unpack invalid.rockspec")) end) + it("LuaRocks unpack with invalid patch", function() assert.is_false(run.luarocks_bool("unpack " .. testing_paths.testing_dir .. "/testfiles/invalid_patch-0.1-1.rockspec")) end) @@ -34,26 +34,22 @@ describe("LuaRocks unpack tests #blackbox #b_unpack", function() assert.is_true(run.luarocks_bool("unpack cprint")) test_env.remove_dir("cprint-0.1-2") end) + it("LuaRocks unpack src", function() assert.is_true(run.luarocks_bool("download --source cprint")) assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.src.rock")) os.remove("cprint-0.1-2.src.rock") test_env.remove_dir("cprint-0.1-2") end) - it("LuaRocks unpack rockspec", function() + + it("LuaRocks unpack src", function() assert.is_true(run.luarocks_bool("download --rockspec cprint")) assert.is_true(run.luarocks_bool("unpack cprint-0.1-2.rockspec")) os.remove("cprint-0.1-2.rockspec") os.remove("lua-cprint") test_env.remove_dir("cprint-0.1-2") end) - -- #595 luarocks unpack of a git:// rockspec fails to copy the rockspec - it("LuaRocks unpack git:// rockspec", function() - assert.is_true(run.luarocks_bool("download --rockspec luazip")) - assert.is_true(run.luarocks_bool("unpack luazip-1.2.4-1.rockspec")) - assert.is_truthy(lfs.attributes("luazip-1.2.4-1/luazip/luazip-1.2.4-1.rockspec")) - test_env.remove_dir("luazip-1.2.4-1") - end) + it("LuaRocks unpack binary", function() assert.is_true(run.luarocks_bool("build cprint")) assert.is_true(run.luarocks_bool("pack cprint")) diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index c68a1cdf..af4c36d3 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua @@ -45,7 +45,7 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --skip-pack luacov-0.11.0-1.rockspec")) end) - it("LuaRocks upload force", function() + it("LuaRocks upload force #unix", function() assert.is_true(run.luarocks_bool("install lua-cjson")) assert.is_false(run.luarocks_bool("upload --api-key=\"invalid\" --force luacov-0.11.0-1.rockspec")) assert.is_true(run.luarocks_bool("install lua-cjson")) @@ -63,10 +63,18 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() end) it("LuaRocks upload rockspec with api-key", function() - assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) + if test_env.APPVEYOR then + assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec " .. test_env.APPVEYOR_OPENSSL .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) + else + assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) + end end) it("LuaRocks upload rockspec with api-key and skip-pack", function() - assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) + if test_env.APPVEYOR then + assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec " .. test_env.APPVEYOR_OPENSSL .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) + else + assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) + end end) end) end) diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 23e3ebd8..e6776e4b 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua @@ -27,7 +27,7 @@ describe("Basic tests #blackbox #b_util", function() assert.is_false(run.luarocks_bool("invalid=5")) end) - it("LuaRocks execute from not existing directory", function() + it("LuaRocks execute from not existing directory #unix", function() local main_path = lfs.currentdir() assert.is_true(lfs.mkdir("idontexist")) assert.is_true(lfs.chdir("idontexist")) @@ -66,34 +66,53 @@ describe("Basic tests #blackbox #b_util", function() assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua")) end) - describe("LuaRocks sysconfig fails", function() - local scdir = "" - - before_each(function() - scdir = testing_paths.testing_lrprefix .. "/etc/luarocks/" + -- Disable versioned config temporarily, because it always takes + -- precedence over config.lua (config-5.x.lua is installed by default on Windows, + -- but not on Unix, so on Unix the os.rename commands below will fail silently, but this is harmless) + describe("LuaRocks config - more complex tests", function() + local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" + local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" + local scname = scdir .. "/config.lua" + + local configfile + if test_env.TEST_TARGET_OS == "windows" then + configfile = versioned_scname + else + configfile = scname + end + + it("LuaRocks fail system config", function() + os.rename(versioned_scname, versioned_scname .. "bak") + local ok = run.luarocks_bool("config --system-config") + os.rename(versioned_scname .. ".bak", versioned_scname) + assert.is_false(ok) + end) + + it("LuaRocks system config", function() lfs.mkdir(testing_paths.testing_lrprefix) lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - end) - - after_each(function() - test_env.remove_dir(testing_paths.testing_lrprefix) - end) - it("LuaRocks sysconfig fail", function() - local sysconfig = io.open(scdir .. "/config.lua", "w+") - sysconfig:write("aoeui") + local sysconfig = io.open(configfile, "w+") + sysconfig:write(" ") sysconfig:close() - assert.is_false(run.luarocks_bool("list")) + local output = run.luarocks("config --system-config") + os.remove(configfile) + assert.are.same(output, configfile) end) - it("LuaRocks sysconfig fail", function() - local sysconfig = io.open(scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua", "w+") - sysconfig:write("aoeui") - sysconfig:close() + it("LuaRocks fail system config invalid", function() + lfs.mkdir(testing_paths.testing_lrprefix) + lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") + lfs.mkdir(scdir) - assert.is_false(run.luarocks_bool("list")) + local sysconfig = io.open(configfile, "w+") + sysconfig:write("if if if") + sysconfig:close() + local ok = run.luarocks_bool("config --system-config") + os.remove(configfile) + assert.is_false(ok) end) end) end) -- cgit v1.2.3-55-g6feb From c22227e0e0bdf27e273d9faee7955686ceb4724c Mon Sep 17 00:00:00 2001 From: roboo Date: Sun, 21 Aug 2016 22:20:23 +0200 Subject: Fix of show test --- spec/show_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/show_spec.lua b/spec/show_spec.lua index 915129ae..b2cdc07e 100644 --- a/spec/show_spec.lua +++ b/spec/show_spec.lua @@ -34,7 +34,7 @@ describe("LuaRocks show tests #blackbox #b_show", function() it("LuaRocks show rockspec of luacov", function() local output = run.luarocks("show --rockspec luacov") - assert.is.truthy(output:match("luacov-0.11.0-1.rockspec")) + assert.is.truthy(output:match("luacov--0.11.0--1.rockspec")) end) it("LuaRocks show mversion of luacov", function() -- cgit v1.2.3-55-g6feb From f1c9fd4895fe107683488c501bc07d4e22f46a4f Mon Sep 17 00:00:00 2001 From: roboo Date: Mon, 22 Aug 2016 13:40:03 +0200 Subject: Fix of config test --- spec/config_spec.lua | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'spec') diff --git a/spec/config_spec.lua b/spec/config_spec.lua index 439d0493..807b077a 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua @@ -61,7 +61,7 @@ describe("LuaRocks config tests #blackbox #b_config", function() end) end) - describe("LuaRocks config - more complex tests", function() + describe("LuaRocks config - more complex tests #special", function() local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" local scname = scdir .. "/config.lua" @@ -74,9 +74,9 @@ describe("LuaRocks config tests #blackbox #b_config", function() end it("LuaRocks fail system config", function() - os.rename(versioned_scname, versioned_scname .. ".bak") + os.rename(configfile, configfile .. ".bak") assert.is_false(run.luarocks_bool("config --system-config")) - os.rename(versioned_scname .. ".bak", versioned_scname) + os.rename(configfile .. ".bak", configfile) end) it("LuaRocks system config", function() @@ -84,18 +84,20 @@ describe("LuaRocks config tests #blackbox #b_config", function() lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - if test_env.TEST_TARGET_OS == "windows" then - local output = run.luarocks("config --system-config") - assert.are.same(output, versioned_scname) - else - sysconfig = io.open(scname, "w+") + -- if test_env.TEST_TARGET_OS == "windows" then + -- local output = run.luarocks("config --system-config") + -- assert.are.same(output, versioned_scname) + -- else + local sysconfig = io.open(configfile, "w+") + test_env.copy(configfile, "configfile_temp") sysconfig:write(" ") sysconfig:close() local output = run.luarocks("config --system-config") - assert.are.same(output, scname) - os.remove(scname) - end + assert.are.same(output, configfile) + test_env.copy("configfile_temp", configfile) + os.remove("configfile_temp") + -- end end) it("LuaRocks fail system config invalid", function() @@ -103,20 +105,21 @@ describe("LuaRocks config tests #blackbox #b_config", function() lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - if test_env.TEST_TARGET_OS == "windows" then - test_env.copy(versioned_scname, "versioned_scname_temp") - sysconfig = io.open(versioned_scname, "w+") + -- if test_env.TEST_TARGET_OS == "windows" then + sysconfig = io.open(configfile, "w+") + test_env.copy(configfile, "configfile_temp") sysconfig:write("if if if") sysconfig:close() assert.is_false(run.luarocks_bool("config --system-config")) - test_env.copy("versioned_scname_temp", versioned_scname) - else - sysconfig = io.open(scname, "w+") - sysconfig:write("if if if") - sysconfig:close() - assert.is_false(run.luarocks_bool("config --system-config")) - os.remove(scname) - end + test_env.copy("configfile_temp", configfile) + os.remove("configfile_temp") + -- else + -- sysconfig = io.open(scname, "w+") + -- sysconfig:write("if if if") + -- sysconfig:close() + -- assert.is_false(run.luarocks_bool("config --system-config")) + -- os.remove(scname) + -- end end) end) end) -- cgit v1.2.3-55-g6feb From 1026d63ba37b8a1074c49797ce737edb5726ed2f Mon Sep 17 00:00:00 2001 From: roboo Date: Mon, 22 Aug 2016 13:50:53 +0200 Subject: Fix of config test --- spec/config_spec.lua | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'spec') diff --git a/spec/config_spec.lua b/spec/config_spec.lua index 807b077a..4a7f4aea 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua @@ -61,7 +61,7 @@ describe("LuaRocks config tests #blackbox #b_config", function() end) end) - describe("LuaRocks config - more complex tests #special", function() + describe("LuaRocks config - more complex tests", function() local scdir = testing_paths.testing_lrprefix .. "/etc/luarocks" local versioned_scname = scdir .. "/config-" .. env_variables.LUA_VERSION .. ".lua" local scname = scdir .. "/config.lua" @@ -84,20 +84,18 @@ describe("LuaRocks config tests #blackbox #b_config", function() lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - -- if test_env.TEST_TARGET_OS == "windows" then - -- local output = run.luarocks("config --system-config") - -- assert.are.same(output, versioned_scname) - -- else + if test_env.TEST_TARGET_OS == "windows" then + local output = run.luarocks("config --system-config") + assert.are.same(output, configfile) + else local sysconfig = io.open(configfile, "w+") - test_env.copy(configfile, "configfile_temp") sysconfig:write(" ") sysconfig:close() local output = run.luarocks("config --system-config") assert.are.same(output, configfile) - test_env.copy("configfile_temp", configfile) - os.remove("configfile_temp") - -- end + os.remove(configfile) + end end) it("LuaRocks fail system config invalid", function() @@ -105,21 +103,20 @@ describe("LuaRocks config tests #blackbox #b_config", function() lfs.mkdir(testing_paths.testing_lrprefix .. "/etc/") lfs.mkdir(scdir) - -- if test_env.TEST_TARGET_OS == "windows" then - sysconfig = io.open(configfile, "w+") + if test_env.TEST_TARGET_OS == "windows" then test_env.copy(configfile, "configfile_temp") + local sysconfig = io.open(configfile, "w+") sysconfig:write("if if if") sysconfig:close() assert.is_false(run.luarocks_bool("config --system-config")) test_env.copy("configfile_temp", configfile) - os.remove("configfile_temp") - -- else - -- sysconfig = io.open(scname, "w+") - -- sysconfig:write("if if if") - -- sysconfig:close() - -- assert.is_false(run.luarocks_bool("config --system-config")) - -- os.remove(scname) - -- end + else + local sysconfig = io.open(configfile, "w+") + sysconfig:write("if if if") + sysconfig:close() + assert.is_false(run.luarocks_bool("config --system-config")) + os.remove(configfile) + end end) end) end) -- cgit v1.2.3-55-g6feb