From fa3f92059c51cbcdf26df9a010f5eadd11a9567d Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 2 Apr 2018 13:12:17 -0300 Subject: Tests: add test for namespaced install --- spec/fixtures/a_repo/a_rock-1.0-1.rockspec | 17 ++++++ spec/fixtures/a_repo/a_rock-1.0-1.src.rock | Bin 0 -> 446 bytes .../has_another_namespaced_dep-1.0-1.rockspec | 19 +++++++ .../has_another_namespaced_dep-1.0-1.src.rock | Bin 0 -> 603 bytes .../a_repo/has_namespaced_dep-1.0-1.rockspec | 19 +++++++ .../a_repo/has_namespaced_dep-1.0-1.src.rock | Bin 0 -> 580 bytes spec/fixtures/a_repo/manifest | 14 +++++ spec/fixtures/a_repo/manifest-5.1 | 14 +++++ spec/fixtures/a_repo/manifest-5.2 | 14 +++++ spec/fixtures/a_repo/manifest-5.3 | 14 +++++ .../a_repo/manifests/a_user/a_rock-2.0-1.rockspec | 17 ++++++ .../a_repo/manifests/a_user/a_rock-2.0-1.src.rock | Bin 0 -> 446 bytes spec/fixtures/a_repo/manifests/a_user/manifest | 14 +++++ spec/fixtures/a_repo/manifests/a_user/manifest-5.1 | 14 +++++ spec/fixtures/a_repo/manifests/a_user/manifest-5.2 | 14 +++++ spec/fixtures/a_repo/manifests/a_user/manifest-5.3 | 14 +++++ .../manifests/another_user/a_rock-3.0-1.rockspec | 17 ++++++ .../manifests/another_user/a_rock-3.0-1.src.rock | Bin 0 -> 449 bytes .../a_repo/manifests/another_user/manifest | 14 +++++ .../a_repo/manifests/another_user/manifest-5.1 | 14 +++++ .../a_repo/manifests/another_user/manifest-5.2 | 14 +++++ .../a_repo/manifests/another_user/manifest-5.3 | 14 +++++ spec/install_spec.lua | 58 ++++++++++++--------- 23 files changed, 290 insertions(+), 25 deletions(-) create mode 100644 spec/fixtures/a_repo/a_rock-1.0-1.rockspec create mode 100644 spec/fixtures/a_repo/a_rock-1.0-1.src.rock create mode 100644 spec/fixtures/a_repo/has_another_namespaced_dep-1.0-1.rockspec create mode 100644 spec/fixtures/a_repo/has_another_namespaced_dep-1.0-1.src.rock create mode 100644 spec/fixtures/a_repo/has_namespaced_dep-1.0-1.rockspec create mode 100644 spec/fixtures/a_repo/has_namespaced_dep-1.0-1.src.rock create mode 100644 spec/fixtures/a_repo/manifest create mode 100644 spec/fixtures/a_repo/manifest-5.1 create mode 100644 spec/fixtures/a_repo/manifest-5.2 create mode 100644 spec/fixtures/a_repo/manifest-5.3 create mode 100644 spec/fixtures/a_repo/manifests/a_user/a_rock-2.0-1.rockspec create mode 100644 spec/fixtures/a_repo/manifests/a_user/a_rock-2.0-1.src.rock create mode 100644 spec/fixtures/a_repo/manifests/a_user/manifest create mode 100644 spec/fixtures/a_repo/manifests/a_user/manifest-5.1 create mode 100644 spec/fixtures/a_repo/manifests/a_user/manifest-5.2 create mode 100644 spec/fixtures/a_repo/manifests/a_user/manifest-5.3 create mode 100644 spec/fixtures/a_repo/manifests/another_user/a_rock-3.0-1.rockspec create mode 100644 spec/fixtures/a_repo/manifests/another_user/a_rock-3.0-1.src.rock create mode 100644 spec/fixtures/a_repo/manifests/another_user/manifest create mode 100644 spec/fixtures/a_repo/manifests/another_user/manifest-5.1 create mode 100644 spec/fixtures/a_repo/manifests/another_user/manifest-5.2 create mode 100644 spec/fixtures/a_repo/manifests/another_user/manifest-5.3 (limited to 'spec') diff --git a/spec/fixtures/a_repo/a_rock-1.0-1.rockspec b/spec/fixtures/a_repo/a_rock-1.0-1.rockspec new file mode 100644 index 00000000..9f15e87a --- /dev/null +++ b/spec/fixtures/a_repo/a_rock-1.0-1.rockspec @@ -0,0 +1,17 @@ +package = "a_rock" +version = "1.0-1" +source = { + url = "http://localhost:8080/file/a_rock.lua" +} +description = { + summary = "An example rockspec", +} +dependencies = { + "lua >= 5.1" +} +build = { + type = "builtin", + modules = { + build = "a_rock.lua" + }, +} diff --git a/spec/fixtures/a_repo/a_rock-1.0-1.src.rock b/spec/fixtures/a_repo/a_rock-1.0-1.src.rock new file mode 100644 index 00000000..9d0bb455 Binary files /dev/null and b/spec/fixtures/a_repo/a_rock-1.0-1.src.rock differ diff --git a/spec/fixtures/a_repo/has_another_namespaced_dep-1.0-1.rockspec b/spec/fixtures/a_repo/has_another_namespaced_dep-1.0-1.rockspec new file mode 100644 index 00000000..04cb06cf --- /dev/null +++ b/spec/fixtures/a_repo/has_another_namespaced_dep-1.0-1.rockspec @@ -0,0 +1,19 @@ +rockspec_format = "3.0" +package = "has_another_namespaced_dep" +version = "1.0-1" +source = { + url = "http://localhost:8080/file/a_rock.lua" +} +description = { + summary = "An example rockspec", +} +dependencies = { + "another_user/a_rock", + "lua >= 5.1", +} +build = { + type = "builtin", + modules = { + bla = "a_rock.lua" + }, +} diff --git a/spec/fixtures/a_repo/has_another_namespaced_dep-1.0-1.src.rock b/spec/fixtures/a_repo/has_another_namespaced_dep-1.0-1.src.rock new file mode 100644 index 00000000..4bbbf1a6 Binary files /dev/null and b/spec/fixtures/a_repo/has_another_namespaced_dep-1.0-1.src.rock differ diff --git a/spec/fixtures/a_repo/has_namespaced_dep-1.0-1.rockspec b/spec/fixtures/a_repo/has_namespaced_dep-1.0-1.rockspec new file mode 100644 index 00000000..6152c78d --- /dev/null +++ b/spec/fixtures/a_repo/has_namespaced_dep-1.0-1.rockspec @@ -0,0 +1,19 @@ +rockspec_format = "3.0" +package = "has_namespaced_dep" +version = "1.0-1" +source = { + url = "http://localhost:8080/file/a_rock.lua" +} +description = { + summary = "An example rockspec", +} +dependencies = { + "a_user/a_rock", + "lua >= 5.1", +} +build = { + type = "builtin", + modules = { + bla = "a_rock.lua" + }, +} diff --git a/spec/fixtures/a_repo/has_namespaced_dep-1.0-1.src.rock b/spec/fixtures/a_repo/has_namespaced_dep-1.0-1.src.rock new file mode 100644 index 00000000..c4d5f94a Binary files /dev/null and b/spec/fixtures/a_repo/has_namespaced_dep-1.0-1.src.rock differ diff --git a/spec/fixtures/a_repo/manifest b/spec/fixtures/a_repo/manifest new file mode 100644 index 00000000..ea198207 --- /dev/null +++ b/spec/fixtures/a_repo/manifest @@ -0,0 +1,14 @@ +commands = {} +modules = {} +repository = { + a_rock = { + ["1.0-1"] = { + { + arch = "src" + }, + { + arch = "rockspec" + } + } + } +} diff --git a/spec/fixtures/a_repo/manifest-5.1 b/spec/fixtures/a_repo/manifest-5.1 new file mode 100644 index 00000000..ea198207 --- /dev/null +++ b/spec/fixtures/a_repo/manifest-5.1 @@ -0,0 +1,14 @@ +commands = {} +modules = {} +repository = { + a_rock = { + ["1.0-1"] = { + { + arch = "src" + }, + { + arch = "rockspec" + } + } + } +} diff --git a/spec/fixtures/a_repo/manifest-5.2 b/spec/fixtures/a_repo/manifest-5.2 new file mode 100644 index 00000000..ea198207 --- /dev/null +++ b/spec/fixtures/a_repo/manifest-5.2 @@ -0,0 +1,14 @@ +commands = {} +modules = {} +repository = { + a_rock = { + ["1.0-1"] = { + { + arch = "src" + }, + { + arch = "rockspec" + } + } + } +} diff --git a/spec/fixtures/a_repo/manifest-5.3 b/spec/fixtures/a_repo/manifest-5.3 new file mode 100644 index 00000000..ea198207 --- /dev/null +++ b/spec/fixtures/a_repo/manifest-5.3 @@ -0,0 +1,14 @@ +commands = {} +modules = {} +repository = { + a_rock = { + ["1.0-1"] = { + { + arch = "src" + }, + { + arch = "rockspec" + } + } + } +} diff --git a/spec/fixtures/a_repo/manifests/a_user/a_rock-2.0-1.rockspec b/spec/fixtures/a_repo/manifests/a_user/a_rock-2.0-1.rockspec new file mode 100644 index 00000000..da5a9a10 --- /dev/null +++ b/spec/fixtures/a_repo/manifests/a_user/a_rock-2.0-1.rockspec @@ -0,0 +1,17 @@ +package = "a_rock" +version = "2.0-1" +source = { + url = "http://localhost:8080/file/a_rock.lua" +} +description = { + summary = "An example rockspec", +} +dependencies = { + "lua >= 5.1" +} +build = { + type = "builtin", + modules = { + build = "a_rock.lua" + }, +} diff --git a/spec/fixtures/a_repo/manifests/a_user/a_rock-2.0-1.src.rock b/spec/fixtures/a_repo/manifests/a_user/a_rock-2.0-1.src.rock new file mode 100644 index 00000000..8d10fac1 Binary files /dev/null and b/spec/fixtures/a_repo/manifests/a_user/a_rock-2.0-1.src.rock differ diff --git a/spec/fixtures/a_repo/manifests/a_user/manifest b/spec/fixtures/a_repo/manifests/a_user/manifest new file mode 100644 index 00000000..74b0c618 --- /dev/null +++ b/spec/fixtures/a_repo/manifests/a_user/manifest @@ -0,0 +1,14 @@ +commands = {} +modules = {} +repository = { + a_rock = { + ["2.0-1"] = { + { + arch = "rockspec" + }, + { + arch = "src" + } + } + } +} diff --git a/spec/fixtures/a_repo/manifests/a_user/manifest-5.1 b/spec/fixtures/a_repo/manifests/a_user/manifest-5.1 new file mode 100644 index 00000000..74b0c618 --- /dev/null +++ b/spec/fixtures/a_repo/manifests/a_user/manifest-5.1 @@ -0,0 +1,14 @@ +commands = {} +modules = {} +repository = { + a_rock = { + ["2.0-1"] = { + { + arch = "rockspec" + }, + { + arch = "src" + } + } + } +} diff --git a/spec/fixtures/a_repo/manifests/a_user/manifest-5.2 b/spec/fixtures/a_repo/manifests/a_user/manifest-5.2 new file mode 100644 index 00000000..74b0c618 --- /dev/null +++ b/spec/fixtures/a_repo/manifests/a_user/manifest-5.2 @@ -0,0 +1,14 @@ +commands = {} +modules = {} +repository = { + a_rock = { + ["2.0-1"] = { + { + arch = "rockspec" + }, + { + arch = "src" + } + } + } +} diff --git a/spec/fixtures/a_repo/manifests/a_user/manifest-5.3 b/spec/fixtures/a_repo/manifests/a_user/manifest-5.3 new file mode 100644 index 00000000..74b0c618 --- /dev/null +++ b/spec/fixtures/a_repo/manifests/a_user/manifest-5.3 @@ -0,0 +1,14 @@ +commands = {} +modules = {} +repository = { + a_rock = { + ["2.0-1"] = { + { + arch = "rockspec" + }, + { + arch = "src" + } + } + } +} diff --git a/spec/fixtures/a_repo/manifests/another_user/a_rock-3.0-1.rockspec b/spec/fixtures/a_repo/manifests/another_user/a_rock-3.0-1.rockspec new file mode 100644 index 00000000..628c5a43 --- /dev/null +++ b/spec/fixtures/a_repo/manifests/another_user/a_rock-3.0-1.rockspec @@ -0,0 +1,17 @@ +package = "a_rock" +version = "3.0-1" +source = { + url = "http://localhost:8080/file/a_rock.lua" +} +description = { + summary = "An example rockspec", +} +dependencies = { + "lua >= 5.1" +} +build = { + type = "builtin", + modules = { + a_rock = "a_rock.lua" + }, +} diff --git a/spec/fixtures/a_repo/manifests/another_user/a_rock-3.0-1.src.rock b/spec/fixtures/a_repo/manifests/another_user/a_rock-3.0-1.src.rock new file mode 100644 index 00000000..4c20afc4 Binary files /dev/null and b/spec/fixtures/a_repo/manifests/another_user/a_rock-3.0-1.src.rock differ diff --git a/spec/fixtures/a_repo/manifests/another_user/manifest b/spec/fixtures/a_repo/manifests/another_user/manifest new file mode 100644 index 00000000..185aed08 --- /dev/null +++ b/spec/fixtures/a_repo/manifests/another_user/manifest @@ -0,0 +1,14 @@ +commands = {} +modules = {} +repository = { + a_rock = { + ["3.0-1"] = { + { + arch = "src" + }, + { + arch = "rockspec" + } + } + } +} diff --git a/spec/fixtures/a_repo/manifests/another_user/manifest-5.1 b/spec/fixtures/a_repo/manifests/another_user/manifest-5.1 new file mode 100644 index 00000000..185aed08 --- /dev/null +++ b/spec/fixtures/a_repo/manifests/another_user/manifest-5.1 @@ -0,0 +1,14 @@ +commands = {} +modules = {} +repository = { + a_rock = { + ["3.0-1"] = { + { + arch = "src" + }, + { + arch = "rockspec" + } + } + } +} diff --git a/spec/fixtures/a_repo/manifests/another_user/manifest-5.2 b/spec/fixtures/a_repo/manifests/another_user/manifest-5.2 new file mode 100644 index 00000000..185aed08 --- /dev/null +++ b/spec/fixtures/a_repo/manifests/another_user/manifest-5.2 @@ -0,0 +1,14 @@ +commands = {} +modules = {} +repository = { + a_rock = { + ["3.0-1"] = { + { + arch = "src" + }, + { + arch = "rockspec" + } + } + } +} diff --git a/spec/fixtures/a_repo/manifests/another_user/manifest-5.3 b/spec/fixtures/a_repo/manifests/another_user/manifest-5.3 new file mode 100644 index 00000000..185aed08 --- /dev/null +++ b/spec/fixtures/a_repo/manifests/another_user/manifest-5.3 @@ -0,0 +1,14 @@ +commands = {} +modules = {} +repository = { + a_rock = { + ["3.0-1"] = { + { + arch = "src" + }, + { + arch = "rockspec" + } + } + } +} diff --git a/spec/install_spec.lua b/spec/install_spec.lua index d72d88ba..53c8f0d0 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua @@ -27,58 +27,66 @@ local extra_rocks = { "/sailor-0.5-4.src.rock", } -describe("LuaRocks install tests #blackbox #b_install", function() +describe("luarocks install #blackbox #b_install", function() before_each(function() test_env.setup_specs(extra_rocks) end) - describe("LuaRocks install - basic tests", function() - it("LuaRocks install with no flags/arguments", function() + describe("basic tests", function() + it("fails with no flags/arguments", function() assert.is_false(run.luarocks_bool("install")) end) - it("LuaRocks install with invalid argument", function() + it("fails with invalid argument", function() assert.is_false(run.luarocks_bool("install invalid")) end) - it("LuaRocks install invalid patch", function() + it("fails invalid patch", function() assert.is_false(run.luarocks_bool("install " .. testing_paths.fixtures_dir .. "/invalid_patch-0.1-1.rockspec")) end) - it("LuaRocks install invalid rock", function() + it("fails invalid rock", function() assert.is_false(run.luarocks_bool("install \"invalid.rock\" ")) end) - it("LuaRocks install with local flag as root #unix", function() + it("fails 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() + it("fails not a zip file", function() assert.is_false(run.luarocks_bool("install " .. testing_paths.fixtures_dir .. "/not_a_zipfile-1.0-1.src.rock")) end) - it("LuaRocks install only-deps of lxsh show there is no lxsh", function() + it("only-deps of lxsh show there is no lxsh", function() assert.is_true(run.luarocks_bool("install lxsh 0.8.6-2 --only-deps")) assert.is_false(run.luarocks_bool("show lxsh")) end) - it("LuaRocks install incompatible architecture", function() + it("fails with incompatible architecture", function() assert.is_false(run.luarocks_bool("install \"foo-1.0-1.impossible-x86.rock\" ")) end) - it("LuaRocks install wsapi with bin", function() - run.luarocks_bool("install wsapi") + it("installs a package with an executable", function() + assert(run.luarocks_bool("install wsapi")) end) - it("LuaRocks install luasec and show luasocket (dependency)", function() + it("installs a package with a dependency", function() assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) assert.is_true(run.luarocks_bool("show luasocket")) end) end) + + describe("#only namespaced packages", function() + it("installs a namespaced package from the command-line", function() + assert(run.luarocks_bool("install a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) + assert.is_false(run.luarocks_bool("show a_rock 1.0")) + assert(run.luarocks_bool("show a_rock 2.0")) + end) + end) - describe("LuaRocks install - more complex tests", function() - it('LuaRocks install luasec with skipping dependency checks', function() + describe("more complex tests", function() + it('luasec with skipping dependency checks', function() 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 @@ -88,7 +96,7 @@ describe("LuaRocks install tests #blackbox #b_install", function() assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/luasec")) end) - it('LuaRocks install - handle relative path in --tree #632', function() + it('handle relative path in --tree #632', function() local relative_path = "./temp_dir_"..math.random(100000) if test_env.TEST_TARGET_OS == "windows" then relative_path = relative_path:gsub("/", "\\") @@ -101,7 +109,7 @@ describe("LuaRocks install tests #blackbox #b_install", function() assert.is.falsy(lfs.attributes(relative_path)) end) - it('LuaRocks install - handle versioned modules when installing another version with --keep #268', function() + it('handle versioned modules when installing another version with --keep #268', function() assert.is_true(run.luarocks_bool("install luafilesystem")) assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/lfs."..test_env.lib_extension)) @@ -114,7 +122,7 @@ describe("LuaRocks install tests #blackbox #b_install", function() assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/lib/lua/"..env_variables.LUA_VERSION.."/luafilesystem_1_6_3_1-lfs."..test_env.lib_extension)) end) - it('LuaRocks install - handle versioned modules and commands from different files when upgrading #302', function() + it('handle versioned modules and commands from different files when upgrading #302', function() io.open(testing_paths.testing_sys_tree .. "/bin/luacheck"..test_env.wrapper_extension, "w"):close() assert.is_true(run.luarocks_bool("install luacheck 0.7.3 --deps-mode=none")) assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/luacheck.lua")) @@ -134,7 +142,7 @@ describe("LuaRocks install tests #blackbox #b_install", function() assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/bin/luacheck_0_7_3_1-luacheck"..test_env.wrapper_extension)) end) - it('LuaRocks install - handle non-Lua files in build.install.lua when upgrading sailorproject/sailor#138', function() + it('handle non-Lua files in build.install.lua when upgrading sailorproject/sailor#138', function() assert.is_true(run.luarocks_bool("install sailor 0.5-3 --deps-mode=none")) assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess")) assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess~")) @@ -144,21 +152,21 @@ describe("LuaRocks install tests #blackbox #b_install", function() assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess~")) end) - it("LuaRocks install only-deps of luasocket packed rock", function() + it("only-deps of luasocket packed rock", function() 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() + it("reinstall", function() 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() + it("binary rock of cprint", function() 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")) @@ -166,20 +174,20 @@ describe("LuaRocks install tests #blackbox #b_install", function() end) describe("New install functionality based on pull request 552", function() - it("LuaRocks install break dependencies warning", function() + it("break dependencies warning", 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.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1")) end) - it("LuaRocks install break dependencies force", function() + it("break dependencies force", function() assert.is_true(run.luarocks_bool("install say 1.2")) assert.is_true(run.luarocks_bool("install luassert")) local output = run.luarocks("install --force say 1.0") assert.is.truthy(output:find("Checking stability of dependencies")) assert.is.falsy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1")) end) - it("LuaRocks install break dependencies force fast", function() + it("break dependencies force fast", function() assert.is_true(run.luarocks_bool("install say 1.2")) assert.is_true(run.luarocks_bool("install luassert")) assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.2-1")) -- cgit v1.2.3-55-g6feb