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(-) 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(-) 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 3dd43e885f1d273bd3b51f4f9e7e7d20a1beb146 Mon Sep 17 00:00:00 2001 From: roboo Date: Sun, 21 Aug 2016 22:23:09 +0200 Subject: Update of YAML files, changed coveralls for codecov --- .travis.yml | 2 +- appveyor.yml | 34 +++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 02bdb6c9..4962f290 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,8 +55,8 @@ script: - busted -Xhelper travis,env=full --verbose after_success: - - luacov-coveralls -c $TRAVIS_BUILD_DIR/test/luacov.config --exclude $TRAVIS_BUILD_DIR/test/ - luacov -c $TRAVIS_BUILD_DIR/test/luacov.config + - cd $TRAVIS_BUILD_DIR/test/ && bash <(curl -s https://codecov.io/bash) - grep "Summary" -B1 -A1000 $TRAVIS_BUILD_DIR/test/luacov.report.out notifications: diff --git a/appveyor.yml b/appveyor.yml index d7fc7cc2..66a12896 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,28 +3,36 @@ version: 2.2.1.{build}-test shallow_clone: true environment: - LUAROCKS_VER: 2.2.1 + LUAROCKS_VER: 2.3.0 matrix: - - LUA_VER: 5.1.5 - - LUA_VER: 5.2.4 - - LUA_VER: 5.3.1 - - LJ_VER: 2.0.4 - - LJ_VER: 2.1 + - LUA: "lua 5.1" + - LUA: "lua 5.2" + - LUA: "lua 5.3" + - LUA: "luajit 2.0" + - LUA: "luajit 2.1" + init: # Setup Lua development/build environment # Make VS 2015 command line tools available - call "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %platform% -install: -# Setup Lua development/build environment -- call .appveyor\install.bat +before_build: + - set PATH=C:\Python27\Scripts;%PATH% # Add directory containing 'pip' to PATH + - pip install hererocks + - hererocks env --%LUA% -rlatest + - call env\bin\activate build_script: -- call .appveyor\build.bat + - luarocks install busted 1> NUL 2> NUL test_script: -- echo "Testing..." -- cd test -- call testing.bat + - busted --lpath=.//?.lua --exclude-tags=ssh,unix,mock -Xhelper appveyor + +after_test: + - if "%LUA%"=="lua 5.1" (luarocks show bit32 || luarocks install bit32) + - luarocks install luacov + - pip install codecov + - luacov -c test/luacov.config + - cd test && codecov \ No newline at end of file -- cgit v1.2.3-55-g6feb From cb212b167b120490d872cc9e1b8548a0770dd4c4 Mon Sep 17 00:00:00 2001 From: roboo Date: Sun, 21 Aug 2016 22:36:23 +0200 Subject: Update of README --- test/README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/README.md b/test/README.md index c374438f..5deaa175 100644 --- a/test/README.md +++ b/test/README.md @@ -12,7 +12,7 @@ Test suite for LuaRocks project with Busted unit testing framework(http://olivin ##Usage -Running of tests is based on basic Busted usage. *-Xhelper* flag is mandatory for inserting arguments into testing (primary black-box). Flag *--tags=* or *-t* is mandatory for specifying which tests will run. Mandatory *-Xhelper* flag always needs version of Lua or LuaJIT (e.g. *lua=5.2.4* or *luajit=2.0.3*). Start tests inside LuaRocks folder or specify with *-C* flag. +Running of tests is based on basic Busted usage. *-Xhelper* flag is mandatory for inserting arguments into testing (primary black-box). Flag *--tags=* or *-t* is mandatory for specifying which tests will run. Start tests inside LuaRocks folder or specify with *-C* flag. **Arguments for Busted helper script** @@ -22,7 +22,9 @@ OR luajit=, !mandatory! type your full version of LuaJIT (e.g. luajit=5.2.4) env=, (default:"minimal") type what kind of environment to use ["minimal", "full"] +noreset, Don't reset environment after each test clean, remove existing testing environment +appveyor, add just if running on TravisCI travis, add just if running on TravisCI os=, type your OS ["linux", "os x", "windows"] ``` @@ -35,6 +37,10 @@ os=, type your OS ["linux", "os x", "windows"] **ssh** - run all tests which require ssh +**mock** - run all tests which require mock LuaRocks server (upload tests) + +**unix** - run all tests which are UNIX based, won't work on Windows systems + **w**\_*name-of-command* - whitebox testing of command **b**\_*name-of-command* - blackbox testing of command @@ -42,6 +48,9 @@ os=, type your OS ["linux", "os x", "windows"] for example: `b_install` or `w_help` ###Examples +To run all tests: +`busted` + To run white-box tests in LuaRocks directory type : `busted -t "whitebox"` -- cgit v1.2.3-55-g6feb From beaecdbccb9fa244bbc0253aedd26d372aa312aa Mon Sep 17 00:00:00 2001 From: roboo Date: Sun, 21 Aug 2016 22:46:19 +0200 Subject: Fix of test_environment --- test/test_environment.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_environment.lua b/test/test_environment.lua index 42473b38..1c31462c 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua @@ -181,7 +181,7 @@ function test_env.set_args() if execute_bool("sw_vers") then test_env.TEST_TARGET_OS = "osx" - elseif execute_bool("uname -s") then + elseif execute_output("uname -s") == "Linux" then test_env.TEST_TARGET_OS = "linux" else test_env.TEST_TARGET_OS = "windows" @@ -321,7 +321,7 @@ local function create_env(testing_paths) env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;" env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" - env_variables.PATH = os.getenv("PATH") .. ":" .. testing_paths.testing_tree .. "/bin:" .. testing_paths.testing_sys_tree .. "/bin" + env_variables.PATH = os.getenv("PATH") .. ";" .. testing_paths.testing_tree .. "/bin;" .. testing_paths.testing_sys_tree .. "/bin;" return env_variables end -- 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(-) 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(-) 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 de72b50eb21fa264a6090c3d062217963c52f74b Mon Sep 17 00:00:00 2001 From: roboo Date: Mon, 22 Aug 2016 16:08:34 +0200 Subject: Remove unused global variables --- test/test_environment.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/test_environment.lua b/test/test_environment.lua index 1c31462c..37bd38f1 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua @@ -660,9 +660,7 @@ function test_env.main() create_configs() local install_env_vars = { - LUAROCKS_CONFIG = test_env.testing_paths.testing_dir .. "/testing_config.lua", - LUA_PATH, - LUA_CPATH + LUAROCKS_CONFIG = test_env.testing_paths.testing_dir .. "/testing_config.lua" } install_luarocks(install_env_vars) -- cgit v1.2.3-55-g6feb