From 84b55ad2186d3243bc6d1f7c449268d03ee02d4c Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 13 Mar 2024 15:42:33 -0300 Subject: tests: convert some install tests --- spec/install_spec.lua | 26 ------- spec/quick/install.q | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++ spec/util/quick.lua | 2 +- 3 files changed, 212 insertions(+), 27 deletions(-) (limited to 'spec') diff --git a/spec/install_spec.lua b/spec/install_spec.lua index df70ed23..e6b1ad03 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua @@ -13,8 +13,6 @@ local extra_rocks = { "/luassert-1.7.0-1.src.rock", "/luasocket-${LUASOCKET}.src.rock", "/lxsh-${LXSH}.src.rock", - "/say-1.2-1.src.rock", - "/say-1.0-1.src.rock", "/luafilesystem-${LUAFILESYSTEM}.src.rock", "/luafilesystem-${LUAFILESYSTEM_OLD}.src.rock", "spec/fixtures/a_repo/has_build_dep-1.0-1.all.rock", @@ -155,30 +153,6 @@ describe("luarocks install #integration", function() end) end) - describe("New install functionality based on pull request 552", 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("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("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")) - local output = run.luarocks("install --force-fast say 1.0") - assert.is.falsy(output:find("Checking stability of dependencies")) - assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/say/1.0-1")) - end) - end) - describe("#build_dependencies", function() it("install does not install a build dependency", function() assert(run.luarocks_bool("install has_build_dep")) diff --git a/spec/quick/install.q b/spec/quick/install.q index 31544470..e2df4283 100644 --- a/spec/quick/install.q +++ b/spec/quick/install.q @@ -475,3 +475,214 @@ RUN: luarocks install ./myrock-1.0-1.all.rock EXISTS: %{testing_sys_tree}/share/lua/%{lua_version}/folder/rock.lua EXISTS: %{testing_sys_tree}/share/lua/%{lua_version}/xyz.lua + + + +================================================================================ +TEST: new install functionality based on #552: break dependencies warning + +FILE: myrock-1.0-1.rockspec +-------------------------------------------------------------------------------- +rockspec_format = "3.0" +package = "myrock" +version = "1.0-1" +source = { + url = "file://%{url(%{tmpdir})}/rock.lua" +} +build = { + modules = { rock = "rock.lua" } +} +-------------------------------------------------------------------------------- + +FILE: myrock-2.0-1.rockspec +-------------------------------------------------------------------------------- +rockspec_format = "3.0" +package = "myrock" +version = "2.0-1" +source = { + url = "file://%{url(%{tmpdir})}/rock.lua" +} +build = { + modules = { rock = "rock.lua" } +} +-------------------------------------------------------------------------------- + +FILE: hasdep-1.0-1.rockspec +-------------------------------------------------------------------------------- +rockspec_format = "3.0" +package = "hasdep" +version = "1.0-1" +source = { + url = "file://%{url(%{tmpdir})}/hasdep.lua" +} +dependencies = { + "myrock >= 2.0", +} +build = { + modules = { hasdep = "hasdep.lua" } +} +-------------------------------------------------------------------------------- + +FILE: rock.lua +-------------------------------------------------------------------------------- +return "hello" +-------------------------------------------------------------------------------- + +FILE: hasdep.lua +-------------------------------------------------------------------------------- +return "hasdep" +-------------------------------------------------------------------------------- + +RUN: luarocks build myrock-2.0-1.rockspec +RUN: luarocks build hasdep-1.0-1.rockspec +RUN: luarocks build myrock-1.0-1.rockspec + +STDERR: +-------------------------------------------------------------------------------- +Will not remove myrock 2.0 +Removing it would break dependencies for +hasdep 1.0 +-------------------------------------------------------------------------------- + +EXISTS: %{testing_sys_rocks}/myrock/1.0-1 +EXISTS: %{testing_sys_rocks}/myrock/2.0-1 + + + +================================================================================ +TEST: new install functionality based on #552: break dependencies with --force + +FILE: myrock-1.0-1.rockspec +-------------------------------------------------------------------------------- +rockspec_format = "3.0" +package = "myrock" +version = "1.0-1" +source = { + url = "file://%{url(%{tmpdir})}/rock.lua" +} +build = { + modules = { rock = "rock.lua" } +} +-------------------------------------------------------------------------------- + +FILE: myrock-2.0-1.rockspec +-------------------------------------------------------------------------------- +rockspec_format = "3.0" +package = "myrock" +version = "2.0-1" +source = { + url = "file://%{url(%{tmpdir})}/rock.lua" +} +build = { + modules = { rock = "rock.lua" } +} +-------------------------------------------------------------------------------- + +FILE: hasdep-1.0-1.rockspec +-------------------------------------------------------------------------------- +rockspec_format = "3.0" +package = "hasdep" +version = "1.0-1" +source = { + url = "file://%{url(%{tmpdir})}/hasdep.lua" +} +dependencies = { + "myrock >= 2.0", +} +build = { + modules = { hasdep = "hasdep.lua" } +} +-------------------------------------------------------------------------------- + +FILE: rock.lua +-------------------------------------------------------------------------------- +return "hello" +-------------------------------------------------------------------------------- + +FILE: hasdep.lua +-------------------------------------------------------------------------------- +return "hasdep" +-------------------------------------------------------------------------------- + +RUN: luarocks build myrock-2.0-1.rockspec +RUN: luarocks build hasdep-1.0-1.rockspec +RUN: luarocks build myrock-1.0-1.rockspec --force + +STDERR: +-------------------------------------------------------------------------------- +The following packages may be broken by this forced removal +hasdep 1.0 +-------------------------------------------------------------------------------- + +NOT_EXISTS: %{testing_sys_rocks}/myrock/2.0-1 +EXISTS: %{testing_sys_rocks}/myrock/1.0-1 + + + +================================================================================ +TEST: new install functionality based on #552: break dependencies with --force-fast + +FILE: myrock-1.0-1.rockspec +-------------------------------------------------------------------------------- +rockspec_format = "3.0" +package = "myrock" +version = "1.0-1" +source = { + url = "file://%{url(%{tmpdir})}/rock.lua" +} +build = { + modules = { rock = "rock.lua" } +} +-------------------------------------------------------------------------------- + +FILE: myrock-2.0-1.rockspec +-------------------------------------------------------------------------------- +rockspec_format = "3.0" +package = "myrock" +version = "2.0-1" +source = { + url = "file://%{url(%{tmpdir})}/rock.lua" +} +build = { + modules = { rock = "rock.lua" } +} +-------------------------------------------------------------------------------- + +FILE: hasdep-1.0-1.rockspec +-------------------------------------------------------------------------------- +rockspec_format = "3.0" +package = "hasdep" +version = "1.0-1" +source = { + url = "file://%{url(%{tmpdir})}/hasdep.lua" +} +dependencies = { + "myrock >= 2.0", +} +build = { + modules = { hasdep = "hasdep.lua" } +} +-------------------------------------------------------------------------------- + +FILE: rock.lua +-------------------------------------------------------------------------------- +return "hello" +-------------------------------------------------------------------------------- + +FILE: hasdep.lua +-------------------------------------------------------------------------------- +return "hasdep" +-------------------------------------------------------------------------------- + +RUN: luarocks build myrock-2.0-1.rockspec +RUN: luarocks build hasdep-1.0-1.rockspec +RUN: luarocks build myrock-1.0-1.rockspec --force-fast + +NOT_STDERR: +-------------------------------------------------------------------------------- +The following packages may be broken by this forced removal +hasdep 1.0 +-------------------------------------------------------------------------------- + +NOT_EXISTS: %{testing_sys_rocks}/myrock/2.0-1 +EXISTS: %{testing_sys_rocks}/myrock/1.0-1 diff --git a/spec/util/quick.lua b/spec/util/quick.lua index 257f570e..b2683ac6 100644 --- a/spec/util/quick.lua +++ b/spec/util/quick.lua @@ -468,7 +468,7 @@ function quick.compile(filename, env) for i, line in ipairs(op.not_stderr.data) do write(([=[ line = %q ]=]):format(line)) write(([=[ s = string.find(stderr_data, line, block_at, true) ]=])) - write(([=[ assert(not s, error_message(%d, "NOT_STDERR did match unwanted output: " .. line, stderr_data)) ]=]):format(op.stderr.start + i)) + write(([=[ assert(not s, error_message(%d, "NOT_STDERR did match unwanted output: " .. line, stderr_data)) ]=]):format(op.not_stderr.start + i)) end write([=[ end ]=]) end -- cgit v1.2.3-55-g6feb