From 3945f90b0bd80024294b048a793bae526cad30e2 Mon Sep 17 00:00:00 2001 From: roboo Date: Tue, 19 Jul 2016 22:56:28 +0200 Subject: Test improvements --- spec/build_spec.lua | 36 +++++++++++++++++++----------------- spec/help_spec.lua | 6 +++--- spec/install_spec.lua | 12 ++++++------ spec/make_spec.lua | 10 +++++----- spec/pack_spec.lua | 6 ++---- spec/remove_spec.lua | 2 +- spec/search_spec.lua | 6 +----- spec/upload_spec.lua | 6 +++--- spec/util_spec.lua | 13 ++++++++----- spec/write_rockspec_spec.lua | 3 +-- 10 files changed, 49 insertions(+), 51 deletions(-) (limited to 'spec') diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 682c6dcf..2ede5211 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua @@ -57,7 +57,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() end) it("LuaRocks build lpeg verbose", function() - assert.is_true(run.luarocks_bool("build --verbose lpeg")) + assert.is.truthy(run.luarocks("build --verbose lpeg")) end) it("LuaRocks build lpeg branch=master", function() @@ -82,9 +82,8 @@ describe("LuaRocks build tests #blackbox #b_build", function() end) describe("LuaRocks build - basic builds", function() - it("LuaRocks build luadoc", function() - assert.is_true(run.luarocks_bool("build luadoc")) + assert.is_true(run.luarocks_bool(test_env.quiet("build luadoc"))) end) it("LuaRocks build luacov diff version", function() @@ -103,12 +102,12 @@ describe("LuaRocks build tests #blackbox #b_build", function() end) it("LuaRocks build supported platforms lpty", function() - assert.is_true(run.luarocks_bool("build lpty")) + 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")) end) it("LuaRocks build luasec with skipping dependency checks", function() - assert.is_true(run.luarocks_bool("build luasec --nodeps")) + 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")) end) @@ -119,31 +118,34 @@ describe("LuaRocks build tests #blackbox #b_build", function() end) describe("LuaRocks build - more complex tests", function() - - it("LuaRocks build luacheck show downloads test_config", function() - local out = run.luarocks("build luacheck", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_show_downloads.lua"} ) - print(out) - end) - + if test_env.TYPE_TEST_ENV == "full" then + it("LuaRocks build luacheck show downloads test_config", function() + local output = run.luarocks("build luacheck", { LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config_show_downloads.lua"} ) + assert.is.truthy(output:match("%.%.%.")) + end) + end + it("LuaRocks build luasec only deps", function() - assert.is_true(run.luarocks_bool("build luasec --only-deps")) + assert.is_true(run.luarocks_bool(test_env.quiet("build luasec --only-deps"))) assert.is_false(run.luarocks_bool("show luasec")) assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) 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_true(run.luarocks_bool("build lxsh-0.8.6-2.rockspec --only-deps")) + 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_true(os.remove("lxsh-0.8.6-2.rockspec")) end) it("LuaRocks build only deps of downloaded rock of lxsh", function() assert.is_true(run.luarocks_bool("download --source lxsh 0.8.6-2")) - assert.is_true(run.luarocks_bool("build lxsh-0.8.6-2.src.rock --only-deps")) + 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_true(os.remove("lxsh-0.8.6-2.src.rock")) end) @@ -151,7 +153,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() assert.is_true(run.luarocks_bool("download --rockspec validate-args 1.5.4-1")) assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) - assert.is_true(run.luarocks_bool("show validate-args")) + 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_true(os.remove("validate-args-1.5.4-1.rockspec")) @@ -159,10 +161,10 @@ 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("install luasec")) + assert.is_true(run.luarocks_bool(test_env.quiet("install luasec"))) assert.is_true(run.luarocks_bool("build validate-args-1.5.4-1.rockspec")) - assert.is_true(run.luarocks_bool("show validate-args")) + 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_true(os.remove("validate-args-1.5.4-1.rockspec")) diff --git a/spec/help_spec.lua b/spec/help_spec.lua index 0d41e2e9..88aa5030 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("help")) + assert.is_true(run.luarocks_bool(test_env.quiet("help"))) end) it("LuaRocks help invalid argument", function() @@ -18,10 +18,10 @@ describe("LuaRocks help tests #blackbox #b_help", function() end) it("LuaRocks help config", function() - assert.is_true(run.luarocks_bool("help config")) + assert.is_true(run.luarocks_bool(test_env.quiet("help config"))) end) it("LuaRocks-admin help with no flags/arguments", function() - assert.is_true(run.luarocks_admin_bool("help")) + assert.is_true(run.luarocks_admin_bool(test_env.quiet("help"))) end) end) diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 28e349c3..bd480c21 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua @@ -73,31 +73,31 @@ describe("LuaRocks install tests #blackbox #b_install", function() describe("LuaRocks install - more complex tests", function() it('LuaRocks install luasec with skipping dependency checks', function() - run.luarocks(" install luasec --nodeps") - assert.is_true(run.luarocks_bool("show luasec")) + run.luarocks_bool(test_env.quiet(" install luasec --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("show luasocket")) + 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")) end assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/luarocks/rocks/luasec")) end) it("LuaRocks install only-deps of luasocket packed rock", function() - assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-1")) + 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")) end) it("LuaRocks install reinstall", function() - assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-1")) + 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")) end) it("LuaRocks install binary rock of cprint", function() - assert.is_true(run.luarocks_bool("build --pack-binary-rock cprint")) + assert.is_true(run.luarocks_bool(test_env.quiet("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 3e843f7b..e684033a 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-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("make luasocket-3.0rc1-1.rockspec")) + assert.is_true(run.luarocks_bool(test_env.quiet("make luasocket-3.0rc1-1.rockspec"))) -- test it - assert.is_true(run.luarocks_bool("show luasocket")) + 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")) -- delete downloaded and unpacked files @@ -61,7 +61,7 @@ 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("show lxsh")) + 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")) end) @@ -69,7 +69,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() os.execute("cp lxsh-0.8.6-2.rockspec rockspec") --rewrite with lfs assert.is_true(run.luarocks_bool("make")) - assert.is_true(run.luarocks_bool("show lxsh")) + 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")) end) @@ -91,7 +91,7 @@ describe("LuaRocks make tests #blackbox #b_make", function() end) it("LuaRocks make pack binary rock", function() - assert.is_true(run.luarocks_bool("make --deps-mode=none --pack-binary-rock")) + assert.is_true(run.luarocks_bool(test_env.quiet("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 78aab9aa..0e5b31c6 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua @@ -24,8 +24,7 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() end) it("LuaRocks pack basic", function() - assert.is_true(run.luarocks_bool("list")) - assert.is_true(run.luarocks_bool("pack luacov")) + assert.is_true(run.luarocks_bool(test_env.quiet("pack luacov"))) assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov-")) end) @@ -49,9 +48,8 @@ describe("LuaRocks pack tests #blackbox #b_pack", function() assert.is_false(run.luarocks_bool("pack say")) end) - it("LuaRocks pack src", function() - assert.is_true(run.luarocks_bool("install luasec")) + 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")) assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket-")) diff --git a/spec/remove_spec.lua b/spec/remove_spec.lua index c7f83b95..7bf1bb10 100644 --- a/spec/remove_spec.lua +++ b/spec/remove_spec.lua @@ -45,7 +45,7 @@ describe("LuaRocks remove tests #blackbox #b_remove", function() describe("LuaRocks remove more complex tests", function() before_each(function() - assert.is_true(test_env.need_rock("luasocket")) + assert.is.truthy(test_env.need_rock("luasocket")) end) it("LuaRocks remove fail, break dependencies", function() diff --git a/spec/search_spec.lua b/spec/search_spec.lua index 33c49856..b31624b8 100644 --- a/spec/search_spec.lua +++ b/spec/search_spec.lua @@ -30,11 +30,7 @@ describe("LuaRocks search tests #blackbox #b_search", function() end) it("LuaRocks search with flag all", function() - assert.is_true(run.luarocks_bool("search --all")) + assert.is_true(run.luarocks_bool(test_env.quiet("search --all"))) end) - it("LuaRocks search zlib", function() - local num = 123 - assert.is_true(run.luarocks_bool("search " .. num)) - end) end) diff --git a/spec/upload_spec.lua b/spec/upload_spec.lua index 02b68611..c68a1cdf 100644 --- a/spec/upload_spec.lua +++ b/spec/upload_spec.lua @@ -53,7 +53,7 @@ describe("LuaRocks upload tests #blackbox #b_upload", function() describe("LuaRocks upload tests with Xavante server #mock", function() before_each(function() - assert.is_true(test_env.need_rock("restserver-xavante")) + assert.is.truthy(test_env.need_rock("restserver-xavante")) local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.testing_dir .. "/mock-server.lua &", true, test_env.env_variables) os.execute(final_command) end) @@ -63,10 +63,10 @@ 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-1.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) + 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) 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-1.rockspec --api-key=123", {LUAROCKS_CONFIG = testing_paths.testing_dir .. "/luarocks_site.lua"})) + 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) diff --git a/spec/util_spec.lua b/spec/util_spec.lua index 9118ffc9..23e3ebd8 100644 --- a/spec/util_spec.lua +++ b/spec/util_spec.lua @@ -34,13 +34,16 @@ describe("Basic tests #blackbox #b_util", function() local delete_path = lfs.currentdir() assert.is_true(os.remove(delete_path)) - assert.is_false(run.luarocks_bool(" ")) + local output = run.luarocks("") + assert.is.falsy(output:find("LuaRocks scm, a module deployment system for Lua")) assert.is_true(lfs.chdir(main_path)) - assert.is_true(run.luarocks_bool(" ")) + + output = run.luarocks("") + assert.is.truthy(output:find("LuaRocks scm, a module deployment system for Lua")) end) it("LuaRocks timeout", function() - assert.is_true(run.luarocks_bool("--timeout=10")) + assert.is.truthy(run.luarocks("--timeout=10")) end) it("LuaRocks timeout invalid", function() @@ -48,7 +51,7 @@ describe("Basic tests #blackbox #b_util", function() end) it("LuaRocks only server=testing", function() - assert.is_true(run.luarocks_bool("--only-server=testing")) + assert.is.truthy(run.luarocks("--only-server=testing")) end) it("LuaRocks test site config", function() @@ -56,7 +59,7 @@ describe("Basic tests #blackbox #b_util", function() assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua")) assert.is.truthy(lfs.attributes("src/luarocks/site_config.lua.tmp")) - assert.is_true(run.luarocks_bool("")) + assert.is.truthy(run.luarocks("")) assert.is.truthy(os.rename("src/luarocks/site_config.lua.tmp", "src/luarocks/site_config.lua")) assert.is.falsy(lfs.attributes("src/luarocks/site_config.lua.tmp")) diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua index 85e345d5..531d11eb 100644 --- a/spec/write_rockspec_spec.lua +++ b/spec/write_rockspec_spec.lua @@ -64,8 +64,7 @@ describe("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() end) it("LuaRocks write_rockspec git luafcgi with many flags", function() - assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license=\"3-clause BSD\" " - .. "--lua-version=5.1,5.2")) + assert.is_true(run.luarocks_bool("write_rockspec git://github.com/mbalmer/luafcgi --lib=fcgi --license=\"3-clause BSD\" " .. "--lua-version=5.1,5.2")) assert.is.truthy(lfs.attributes("luafcgi-scm-1.rockspec")) -- TODO maybe read it content and find arguments from flags? assert.is_true(os.remove("luafcgi-scm-1.rockspec")) end) -- cgit v1.2.3-55-g6feb