From 36b0198c669e1fcbe706b371bb983e190decd664 Mon Sep 17 00:00:00 2001 From: Hisham Date: Thu, 28 Jul 2016 18:25:24 -0300 Subject: Fix download in test. --- spec/unpack_spec.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/unpack_spec.lua b/spec/unpack_spec.lua index 495c514e..8db779c3 100644 --- a/spec/unpack_spec.lua +++ b/spec/unpack_spec.lua @@ -49,7 +49,7 @@ describe("LuaRocks unpack tests #blackbox #b_unpack", function() 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 cprint")) + 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") -- cgit v1.2.3-55-g6feb 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 ++++++++++----- test/test_environment.lua | 173 +++++++++++++++++++++++++++++++++----------- 16 files changed, 408 insertions(+), 215 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) diff --git a/test/test_environment.lua b/test/test_environment.lua index 13e548f9..42473b38 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua @@ -17,6 +17,7 @@ ARGUMENTS noreset Don't reset environment after each test clean Remove existing testing environment. travis Add if running on TravisCI. + appveyor Add if running on Appveyor. os= Set OS ("linux", "osx", or "windows"). ]] @@ -36,18 +37,54 @@ local function exists(path) return lfs.attributes(path, "mode") ~= nil end -function test_env.quiet(commad) +--- Quote argument for shell processing. Fixes paths on Windows. +-- Adds double quotes and escapes. Based on function in fs/win32.lua. +-- @param arg string: Unquoted argument. +-- @return string: Quoted argument. +local function Q(arg) + if test_env.TEST_TARGET_OS == "windows" then + local drive_letter = "[%.a-zA-Z]?:?[\\/]" + -- Quote DIR for Windows + if arg:match("^"..drive_letter) then + arg = arg:gsub("/", "\\") + end + + if arg == "\\" then + return '\\' -- CHDIR needs special handling for root dir + end + + return '"' .. arg .. '"' + else + return "'" .. arg:gsub("'", "'\\''") .. "'" + end +end + +function test_env.quiet(command) if not test_env.VERBOSE then - if test_env.TEST_TARGET_OS == "linux" or test_env.TEST_TARGET_OS == "osx" then - return commad .. " 1> /dev/null 2> /dev/null" - elseif test_env.TEST_TARGET_OS == "windows" then - return commad .. " 2> NUL 1> NUL" + if test_env.TEST_TARGET_OS == "windows" then + return command .. " 1> NUL 2> NUL" + else + return command .. " 1> /dev/null 2> /dev/null" end else return command end end +function test_env.copy(source, destination) + local r_source, err = io.open(source, "r") + local r_destination, err = io.open(destination, "w") + + while true do + local block = r_source:read(8192) + if not block then break end + r_destination:write(block) + end + + r_source:close() + r_destination:close() +end + --- Helper function for execute_bool and execute_output -- @param command string: command to execute -- @param print_command boolean: print command if 'true' @@ -61,15 +98,22 @@ function test_env.execute_helper(command, print_command, env_variables) end if env_variables then - final_command = "export " - for k,v in pairs(env_variables) do - final_command = final_command .. k .. "='" .. v .. "' " + if test_env.TEST_TARGET_OS == "windows" then + for k,v in pairs(env_variables) do + final_command = final_command .. "set " .. k .. "=" .. v .. "&" + end + final_command = final_command:sub(1, -2) .. "&" + else + final_command = "export " + for k,v in pairs(env_variables) do + final_command = final_command .. k .. "='" .. v .. "' " + end + -- remove last space and add ';' to separate exporting variables from command + final_command = final_command:sub(1, -2) .. "; " end - -- remove last space and add ';' to separate exporting variables from command - final_command = final_command:sub(1, -2) .. "; " end - final_command = final_command .. command + final_command = final_command .. command .. " 2>&1" return final_command end @@ -122,6 +166,9 @@ function test_env.set_args() test_env.VERBOSE = true elseif argument == "travis" then test_env.TRAVIS = true + elseif argument == "appveyor" then + test_env.APPVEYOR = true + test_env.APPVEYOR_OPENSSL = "OPENSSL_LIBDIR=C:\\OpenSSL-Win32\\lib OPENSSL_INCDIR=C:\\OpenSSL-Win32\\include" elseif argument:find("^os=") then test_env.TEST_TARGET_OS = argument:match("^os=(.*)$") else @@ -143,6 +190,15 @@ function test_env.set_args() return true end +local function copy_dir(source_path, target_path) + local testing_paths = test_env.testing_paths + if test_env.TEST_TARGET_OS == "windows" then + execute_bool(testing_paths.win_tools .. "/cp -R ".. source_path .. "/. " .. target_path) + else + execute_bool("cp -a ".. source_path .. "/. " .. target_path) + end +end + --- Remove directory recursively -- @param path string: directory path to delete function test_env.remove_dir(path) @@ -159,7 +215,7 @@ function test_env.remove_dir(path) end end end - os.remove(path) + lfs.rmdir(path) end --- Remove subdirectories of a directory that match a pattern @@ -205,13 +261,17 @@ end -- @param save_path string: path to directory, where to download rocks/rockspecs -- @return make_manifest boolean: true if new rocks downloaded local function download_rocks(urls, save_path) - local luarocks_repo = "https://luarocks.org" + local luarocks_repo = "https://www.luarocks.org" local make_manifest = false for _, url in ipairs(urls) do -- check if already downloaded if not exists(save_path .. url) then - execute_bool("wget -cP " .. save_path .. " " .. luarocks_repo .. url) + if test_env.TEST_TARGET_OS == "windows" then + execute_bool(test_env.testing_paths.win_tools .. "/wget -cP " .. save_path .. " " .. luarocks_repo .. url .. " --no-check-certificate") + else + execute_bool("wget -cP " .. save_path .. " " .. luarocks_repo .. url) + end make_manifest = true end end @@ -235,9 +295,9 @@ local function hash_environment(path) return execute_output("find " .. path .. " -printf \"%s %p\n\" | md5sum") elseif test_env.TEST_TARGET_OS == "osx" then return execute_output("find " .. path .. " -type f -exec stat -f \"%z %N\" {} \\; | md5") - else - -- TODO: Windows - return "" + elseif test_env.TEST_TARGET_OS == "windows" then + return execute_output("\"" .. Q(test_env.testing_paths.win_tools .. "/find") .. " " .. Q(path) + .. " -printf \"%s %p\"\" > temp_sum.txt && certUtil -hashfile temp_sum.txt && del temp_sum.txt") end end @@ -278,13 +338,17 @@ local function create_md5sums(testing_paths) end local function make_run_function(cmd_name, exec_function, with_coverage, do_print) - local cmd_prefix = test_env.testing_paths.lua .. " " + local cmd_prefix = Q(test_env.testing_paths.lua) .. " " if with_coverage then cmd_prefix = cmd_prefix .. "-e \"require('luacov.runner')('" .. test_env.testing_paths.testing_dir .. "/luacov.config')\" " end - - cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " " + + if test_env.TEST_TARGET_OS == "windows" then + cmd_prefix = cmd_prefix .. Q(test_env.testing_paths.testing_lrprefix .. "/" .. cmd_name .. ".lua") .. " " + else + cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " " + end return function(cmd, new_vars) local temp_vars = {} @@ -327,19 +391,23 @@ local function build_environment(rocks, env_variables) lfs.mkdir(testing_paths.testing_tree) lfs.mkdir(testing_paths.testing_sys_tree) - test_env.run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_server) - test_env.run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_cache) + test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_server)) + test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_cache)) for _, rock in ipairs(rocks) do - if not test_env.run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. rock, env_variables) then - test_env.run.luarocks_nocov("build --tree=" .. testing_paths.testing_sys_tree .. " " .. rock, env_variables) - test_env.run.luarocks_nocov("pack --tree=" .. testing_paths.testing_sys_tree .. " " .. rock, env_variables) - execute_bool("mv " .. rock .. "-*.rock " .. testing_paths.testing_cache) + if not test_env.run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. Q(rock), env_variables) then + test_env.run.luarocks_nocov("build --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock) .. "", env_variables) + test_env.run.luarocks_nocov("pack --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock), env_variables) + if test_env.TEST_TARGET_OS == "windows" then + execute_bool(testing_paths.win_tools .. "/mv " .. rock .. "-*.rock " .. testing_paths.testing_cache) + else + execute_bool("mv " .. rock .. "-*.rock " .. testing_paths.testing_cache) + end end end - - execute_bool("cp -a " .. testing_paths.testing_tree .. "/. " .. testing_paths.testing_tree_copy) - execute_bool("cp -a " .. testing_paths.testing_sys_tree .. "/. " .. testing_paths.testing_sys_tree_copy) + + copy_dir(testing_paths.testing_tree, testing_paths.testing_tree_copy) + copy_dir(testing_paths.testing_sys_tree, testing_paths.testing_sys_tree_copy) end --- Reset testing environment @@ -349,14 +417,13 @@ local function reset_environment(testing_paths, md5sums) if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then test_env.remove_dir(testing_paths.testing_tree) - execute_bool("cp -a " .. testing_paths.testing_tree_copy .. "/. " .. testing_paths.testing_tree) + copy_dir(testing_paths.testing_tree_copy, testing_paths.testing_tree) end if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then test_env.remove_dir(testing_paths.testing_sys_tree) - execute_bool("cp -a " .. testing_paths.testing_sys_tree_copy .. "/. " .. testing_paths.testing_sys_tree) + copy_dir(testing_paths.testing_sys_tree_copy, testing_paths.testing_sys_tree) end - print("\n[ENVIRONMENT RESET]") end @@ -367,9 +434,18 @@ local function create_paths(luaversion_full) testing_paths.luadir = cfg.variables.LUA_BINDIR:gsub("/bin/?$", "") testing_paths.lua = cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter - testing_paths.luarocks_tmp = "/tmp/luarocks_testing" --windows? + if test_env.TEST_TARGET_OS == "windows" then + testing_paths.luarocks_tmp = os.getenv("TEMP") + else + testing_paths.luarocks_tmp = "/tmp/luarocks_testing" + end testing_paths.luarocks_dir = lfs.currentdir() + + if test_env.TEST_TARGET_OS == "windows" then + testing_paths.luarocks_dir = testing_paths.luarocks_dir:gsub("\\","/") + end + testing_paths.testing_dir = testing_paths.luarocks_dir .. "/test" testing_paths.src_dir = testing_paths.luarocks_dir .. "/src" testing_paths.testing_lrprefix = testing_paths.testing_dir .. "/testing_lrprefix-" .. luaversion_full @@ -380,6 +456,10 @@ local function create_paths(luaversion_full) testing_paths.testing_cache = testing_paths.testing_dir .. "/testing_cache-" .. luaversion_full testing_paths.testing_server = testing_paths.testing_dir .. "/testing_server-" .. luaversion_full + if test_env.TEST_TARGET_OS == "windows" then + testing_paths.win_tools = testing_paths.testing_lrprefix .. "/tools" + end + return testing_paths end @@ -409,7 +489,7 @@ function test_env.setup_specs(extra_rocks) test_env.main() package.path = test_env.env_variables.LUA_PATH - test_env.platform = execute_output(test_env.testing_paths.lua .. " -e 'print(require(\"luarocks.cfg\").arch)'", false, test_env.env_variables) + test_env.platform = execute_output(test_env.testing_paths.lua .. " -e \"print(require('luarocks.cfg').arch)\"", false, test_env.env_variables) test_env.md5sums = create_md5sums(test_env.testing_paths) test_env.setup_done = true title("RUNNING TESTS") @@ -546,13 +626,22 @@ end --- Install luarocks into testing prefix. local function install_luarocks(install_env_vars) - -- Configure LuaRocks testing environment + local testing_paths = test_env.testing_paths title("Installing LuaRocks") - local configure_cmd = "./configure --with-lua=" .. test_env.testing_paths.luadir .. " --prefix=" .. test_env.testing_paths.testing_lrprefix - assert(execute_bool(test_env.quiet(configure_cmd), false, install_env_vars)) - assert(execute_bool(test_env.quiet("make clean"), false, install_env_vars)) - assert(execute_bool(test_env.quiet("make src/luarocks/site_config.lua"), false, install_env_vars)) - assert(execute_bool(test_env.quiet("make dev"), false, install_env_vars)) + if test_env.TEST_TARGET_OS == "windows" then + if test_env.LUA_V then + assert(execute_bool("install.bat /LUA " .. testing_paths.luadir .. " /LV " .. test_env.LUA_V .. " /P " .. testing_paths.testing_lrprefix .. " /NOREG /NOADMIN /F /Q /CONFIG " .. testing_paths.testing_lrprefix .. "/etc/luarocks", false, install_env_vars)) + else + assert(execute_bool("install.bat /LUA " .. testing_paths.luadir .. " /P " .. testing_paths.testing_lrprefix .. " /NOREG /NOADMIN /F /Q /CONFIG " .. testing_paths.testing_lrprefix .. "/etc/luarocks", false, install_env_vars)) + end + assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/site_config* " .. testing_paths.src_dir .. "/luarocks/site_config.lua")) + else + local configure_cmd = "./configure --with-lua=" .. testing_paths.luadir .. " --prefix=" .. testing_paths.testing_lrprefix + assert(execute_bool(configure_cmd, false, install_env_vars)) + assert(execute_bool("make clean", false, install_env_vars)) + assert(execute_bool("make src/luarocks/site_config.lua", false, install_env_vars)) + assert(execute_bool("make dev", false, install_env_vars)) + end print("LuaRocks installed correctly!") end @@ -572,8 +661,8 @@ function test_env.main() local install_env_vars = { LUAROCKS_CONFIG = test_env.testing_paths.testing_dir .. "/testing_config.lua", - LUA_PATH = "", - LUA_CPATH = "" + LUA_PATH, + LUA_CPATH } install_luarocks(install_env_vars) -- 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 From 6d9c9997645c07ed93719d85e260d9ffbc2d1d25 Mon Sep 17 00:00:00 2001 From: roboo Date: Mon, 22 Aug 2016 21:01:23 +0200 Subject: Change APPVEYOR_OPENSSL to OPENSSL_DIRS for better test readability --- spec/build_spec.lua | 18 +++--------------- spec/install_spec.lua | 12 ++---------- spec/pack_spec.lua | 6 +----- spec/upload_spec.lua | 12 ++---------- 4 files changed, 8 insertions(+), 40 deletions(-) (limited to 'spec') diff --git a/spec/build_spec.lua b/spec/build_spec.lua index b4f838ca..8f08f0a0 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua @@ -120,11 +120,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() end) it("LuaRocks build luasec with skipping dependency checks", function() - 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_true(run.luarocks_bool("build luasec " .. test_env.OPENSSL_DIRS .. " --nodeps")) assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec")) end) @@ -150,11 +146,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() end it("LuaRocks build luasec only deps", function() - 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_true(run.luarocks_bool(test_env.quiet("build luasec " .. test_env.OPENSSL_DIRS .. " --only-deps"))) assert.is_false(run.luarocks_bool("show luasec")) assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec")) end) @@ -189,12 +181,8 @@ describe("LuaRocks build tests #blackbox #b_build", function() 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 " .. test_env.OPENSSL_DIRS))) - 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/1.5.4-1/validate-args-1.5.4-1.rockspec")) diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 2b6cb77f..e5b9e2cc 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua @@ -66,22 +66,14 @@ describe("LuaRocks install tests #blackbox #b_install", function() end) it("LuaRocks install luasec and show luasocket (dependency)", function() - 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(test_env.quiet("install luasec " .. test_env.OPENSSL_DIRS))) 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() - 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("install luasec " .. test_env.OPENSSL_DIRS .. " --nodeps"))) 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"))) diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index 21f33b02..3191e80c 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua @@ -49,11 +49,7 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() end) it("LuaRocks pack src", function() - 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(test_env.quiet("install luasec " .. test_env.OPENSSL_DIRS))) 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-")) diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index af4c36d3..ff39cb96 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua @@ -63,18 +63,10 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() end) it("LuaRocks upload rockspec with api-key", function() - 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 + assert.is_true(run.luarocks_bool("upload " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec " .. test_env.OPENSSL_DIRS .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) end) it("LuaRocks upload rockspec with api-key and skip-pack", function() - 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 + assert.is_true(run.luarocks_bool("upload --skip-pack " .. testing_paths.testing_server .. "/luasocket-3.0rc1-2.rockspec " .. test_env.OPENSSL_DIRS .. " --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) end) end) end) -- cgit v1.2.3-55-g6feb From f91fc9a6ef9ef488c709894a29ce63db2bc1e399 Mon Sep 17 00:00:00 2001 From: Hisham Date: Thu, 8 Sep 2016 14:04:40 -0300 Subject: Tests: luarocks_bool commands log their outputs on failure. --- spec/build_spec.lua | 8 ++++---- spec/help_spec.lua | 4 ++-- spec/install_spec.lua | 12 ++++++------ spec/make_spec.lua | 8 ++++---- spec/pack_spec.lua | 4 ++-- spec/search_spec.lua | 2 +- test/test_environment.lua | 22 +++++++++++++++++++--- 7 files changed, 38 insertions(+), 22 deletions(-) (limited to 'spec') diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 8f08f0a0..2ff7cbe6 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua @@ -92,7 +92,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() describe("LuaRocks build - basic builds", function() it("LuaRocks build luadoc", function() - assert.is_true(run.luarocks_bool(test_env.quiet("build luadoc"))) + assert.is_true(run.luarocks_bool("build luadoc")) end) it("LuaRocks build luacov diff version", function() @@ -114,7 +114,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() 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_true(run.luarocks_bool("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) @@ -146,7 +146,7 @@ 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 " .. test_env.OPENSSL_DIRS .. " --only-deps"))) + assert.is_true(run.luarocks_bool("build luasec " .. test_env.OPENSSL_DIRS .. " --only-deps")) assert.is_false(run.luarocks_bool("show luasec")) assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec/0.6-1/luasec-0.6-1.rockspec")) end) @@ -181,7 +181,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() 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 " .. test_env.OPENSSL_DIRS))) + assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) assert.is.truthy(run.luarocks("show validate-args")) diff --git a/spec/help_spec.lua b/spec/help_spec.lua index 88aa5030..71b1b9f6 100644 --- a/spec/help_spec.lua +++ b/spec/help_spec.lua @@ -10,7 +10,7 @@ describe("LuaRocks help tests #blackbox #b_help", function() end) it("LuaRocks help with no flags/arguments", function() - assert.is_true(run.luarocks_bool(test_env.quiet("help"))) + assert.is_true(run.luarocks_bool("help")) end) it("LuaRocks help invalid argument", function() @@ -18,7 +18,7 @@ describe("LuaRocks help tests #blackbox #b_help", function() end) it("LuaRocks help config", function() - assert.is_true(run.luarocks_bool(test_env.quiet("help config"))) + assert.is_true(run.luarocks_bool("help config")) end) it("LuaRocks-admin help with no flags/arguments", function() diff --git a/spec/install_spec.lua b/spec/install_spec.lua index e5b9e2cc..8857e4bd 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua @@ -66,15 +66,15 @@ describe("LuaRocks install tests #blackbox #b_install", function() end) it("LuaRocks install luasec and show luasocket (dependency)", function() - assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.OPENSSL_DIRS))) + assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) 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() - assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.OPENSSL_DIRS .. " --nodeps"))) - assert.is_true(run.luarocks_bool(test_env.quiet("show luasec"))) + assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS .. " --nodeps")) + assert.is_true(run.luarocks_bool("show luasec")) if env_variables.TYPE_TEST_ENV == "minimal" then assert.is_false(run.luarocks_bool(test_env.quiet("show luasocket"))) assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasocket")) @@ -83,21 +83,21 @@ 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-2"))) + assert.is_true(run.luarocks_bool("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-2"))) + assert.is_true(run.luarocks_bool("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() - assert.is_true(run.luarocks_bool(test_env.quiet("build --pack-binary-rock cprint"))) + assert.is_true(run.luarocks_bool("build --pack-binary-rock cprint")) assert.is_true(run.luarocks_bool("install cprint-0.1-2." .. test_env.platform .. ".rock")) assert.is_true(os.remove("cprint-0.1-2." .. test_env.platform .. ".rock")) end) diff --git a/spec/make_spec.lua b/spec/make_spec.lua index 624badff..ae79a29c 100644 --- a/spec/make_spec.lua +++ b/spec/make_spec.lua @@ -30,10 +30,10 @@ describe("LuaRocks make tests #blackbox #b_make", function() 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"))) + assert.is_true(run.luarocks_bool("make luasocket-3.0rc1-2.rockspec")) -- test it - assert.is_true(run.luarocks_bool(test_env.quiet("show luasocket"))) + assert.is_true(run.luarocks_bool("show 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 @@ -69,7 +69,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() 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_true(run.luarocks_bool("show 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) @@ -94,7 +94,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() end) it("LuaRocks make pack binary rock", function() - assert.is_true(run.luarocks_bool(test_env.quiet("make --deps-mode=none --pack-binary-rock"))) + assert.is_true(run.luarocks_bool("make --deps-mode=none --pack-binary-rock")) assert.is.truthy(lfs.attributes("lxsh-0.8.6-2.all.rock")) end) end) diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index 3191e80c..3c9ed9fd 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua @@ -25,7 +25,7 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() end) it("LuaRocks pack basic", function() - assert.is_true(run.luarocks_bool(test_env.quiet("pack luacov"))) + assert.is_true(run.luarocks_bool("pack luacov")) assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov-")) end) @@ -49,7 +49,7 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() end) it("LuaRocks pack src", function() - assert.is_true(run.luarocks_bool(test_env.quiet("install luasec " .. test_env.OPENSSL_DIRS))) + assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) 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-")) diff --git a/spec/search_spec.lua b/spec/search_spec.lua index f75bc3c1..04f84eeb 100644 --- a/spec/search_spec.lua +++ b/spec/search_spec.lua @@ -30,6 +30,6 @@ describe("LuaRocks search tests #blackbox #b_search", function() end) it("LuaRocks search with flag all", function() - assert.is_true(run.luarocks_bool(test_env.quiet("search --all"))) + assert.is_true(run.luarocks_bool("search --all")) end) end) diff --git a/test/test_environment.lua b/test/test_environment.lua index 00213d31..8239795d 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua @@ -119,13 +119,29 @@ function test_env.execute_helper(command, print_command, env_variables) end --- Execute command and returns true/false --- In Lua5.1 os.execute returns numeric value, but in Lua5.2+ returns boolean -- @return true/false boolean: status of the command execution local function execute_bool(command, print_command, env_variables) command = test_env.execute_helper(command, print_command, env_variables) - local ok = os.execute(command) - return ok == true or ok == 0 + local redirect_filename + local redirect = "" + if print_command ~= nil then + redirect_filename = test_env.testing_paths.luarocks_tmp.."/output.txt" + redirect = " > "..redirect_filename + end + local ok = os.execute(command .. redirect) + ok = (ok == true or ok == 0) -- normalize Lua 5.1 output to boolean + if redirect ~= "" then + if not ok then + local fd = io.open(redirect_filename, "r") + if fd then + print(fd:read("*a")) + fd:close() + end + end + os.remove(redirect_filename) + end + return ok end --- Execute command and returns output of command -- cgit v1.2.3-55-g6feb From f2daf51d17f696bebf6db59a53e26eee579bb5a7 Mon Sep 17 00:00:00 2001 From: Hisham Date: Thu, 8 Sep 2016 14:38:37 -0300 Subject: Fix test to match new behavior of `pack`. --- spec/pack_spec.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index 3c9ed9fd..aa84be8d 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua @@ -41,11 +41,12 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif")) end) - it("LuaRocks pack specify which version of rock", function() + it("LuaRocks pack detects latest version version of rock", 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")) + assert.is_truthy(lfs.attributes("say-1.2-1.all.rock")) + assert.is_true(test_env.remove_files(lfs.currentdir(), "say-")) end) it("LuaRocks pack src", function() -- cgit v1.2.3-55-g6feb From 412ada2cf8ca4792e8c36c181df2a948cecd892d Mon Sep 17 00:00:00 2001 From: Hisham Date: Thu, 8 Sep 2016 14:55:07 -0300 Subject: Restore accidentally deleted line! --- spec/pack_spec.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'spec') diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index aa84be8d..0c6dd8f2 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua @@ -45,6 +45,7 @@ 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_true(run.luarocks_bool("pack say")) assert.is_truthy(lfs.attributes("say-1.2-1.all.rock")) assert.is_true(test_env.remove_files(lfs.currentdir(), "say-")) end) -- cgit v1.2.3-55-g6feb From adcba81974979be3763c8d9d46eb2de9a88ff67c Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Thu, 6 Oct 2016 16:24:55 +0300 Subject: Add tests for util.sortedpairs --- spec/util_spec.lua | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'spec') diff --git a/spec/util_spec.lua b/spec/util_spec.lua index e6776e4b..2779b1ce 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua @@ -116,3 +116,59 @@ describe("Basic tests #blackbox #b_util", function() end) end) end) + +test_env.unload_luarocks() +local util = require("luarocks.util") + +describe("Luarocks util test #whitebox #w_util", function() + describe("util.sortedpairs", function() + local function collect(iter, state, var) + local collected = {} + + while true do + local returns = {iter(state, var)} + + if returns[1] == nil then + return collected + else + table.insert(collected, returns) + var = returns[1] + end + end + end + + it("default sort", function() + assert.are.same({}, collect(util.sortedpairs({}))) + assert.are.same({ + {1, "v1"}, + {2, "v2"}, + {3, "v3"}, + {"bar", "v5"}, + {"foo", "v4"} + }, collect(util.sortedpairs({"v1", "v2", "v3", foo = "v4", bar = "v5"}))) + end) + + it("sort by function", function() + local function compare(a, b) return a > b end + assert.are.same({}, collect(util.sortedpairs({}, compare))) + assert.are.same({ + {3, "v3"}, + {2, "v2"}, + {1, "v1"} + }, collect(util.sortedpairs({"v1", "v2", "v3"}, compare))) + end) + + it("sort by priority table", function() + assert.are.same({}, collect(util.sortedpairs({}, {"k1", "k2"}))) + assert.are.same({ + {"k3", "v3"}, + {"k2", "v2", {"sub order"}}, + {"k1", "v1"}, + {"k4", "v4"}, + {"k5", "v5"}, + }, collect(util.sortedpairs({ + k1 = "v1", k2 = "v2", k3 = "v3", k4 = "v4", k5 = "v5" + }, {"k3", {"k2", {"sub order"}}, "k1"}))) + end) + end) +end) -- cgit v1.2.3-55-g6feb