From 78d40e304be182b7e07be449ebda668b8b9d0fcd Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 4 Mar 2024 12:17:56 -0300 Subject: fix: check permissions before trying to lock This should provide a better error message. --- spec/quick/build.q | 76 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 24 deletions(-) (limited to 'spec') diff --git a/spec/quick/build.q b/spec/quick/build.q index 55bb7519..7cbc526b 100644 --- a/spec/quick/build.q +++ b/spec/quick/build.q @@ -79,11 +79,16 @@ a_rock 1.0 ================================================================================ TEST: fails if no permissions to access the specified tree #unix -RUN: luarocks build --tree=/usr ./a_rock-1.0.1-rockspec -EXIT: 4 +RUN: luarocks build --tree=/usr ./a_rock-1.0-1.rockspec +EXIT: 2 STDERR: -------------------------------------------------------------------------------- -requires exclusive write access +You may want to run as a privileged user, +or use --local to install into your local tree +or run 'luarocks config local_by_default true' to make --local the default. + +(You may need to configure your Lua package paths +to use the local tree, see 'luarocks path --help') -------------------------------------------------------------------------------- We show the OS permission denied error, so we don't show the --force-lock @@ -96,33 +101,66 @@ try --force-lock NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec -RUN: luarocks build --tree=/usr ./a_rock-1.0.1-rockspec --force-lock -EXIT: 4 -STDERR: + + +================================================================================ +TEST: fails if tree is locked, --force-lock overrides #unix + +FILE: a_rock-1.0-1.rockspec -------------------------------------------------------------------------------- -requires exclusive write access +rockspec_format = "3.0" +package = "a_rock" +version = "1.0-1" +source = { + url = "file://%{url(%{fixtures_dir})}/a_rock.lua" +} +description = { + summary = "An example rockspec", +} +dependencies = { + "lua >= 5.1" +} +build = { + modules = { + build = "a_rock.lua" + }, +} -------------------------------------------------------------------------------- -We show the OS permission denied error, so we don't show the --force-lock -message. +FILE: %{testing_tree}/lockfile.lfs +-------------------------------------------------------------------------------- +dummy lock file for testing +-------------------------------------------------------------------------------- -NOT_STDERR: +RUN: luarocks build --tree=%{testing_tree} ./a_rock-1.0-1.rockspec +EXIT: 4 +STDERR: -------------------------------------------------------------------------------- +requires exclusive write access try --force-lock -------------------------------------------------------------------------------- -NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec +RUN: luarocks build --tree=%{testing_tree} ./a_rock-1.0-1.rockspec --force-lock +EXIT: 0 ================================================================================ TEST: fails if no permissions to access the parent #unix -RUN: luarocks build --tree=/usr/invalid ./a_rock-1.0.1-rockspec -EXIT: 4 +RUN: luarocks build --tree=/usr/invalid ./a_rock-1.0-1.rockspec +EXIT: 2 STDERR: -------------------------------------------------------------------------------- -requires exclusive write access +Error: /usr/invalid/lib/luarocks/rocks-%{lua_version} does not exist +and your user does not have write permissions in /usr + +You may want to run as a privileged user, +or use --local to install into your local tree +or run 'luarocks config local_by_default true' to make --local the default. + +(You may need to configure your Lua package paths +to use the local tree, see 'luarocks path --help') -------------------------------------------------------------------------------- We show the OS permission denied error, so we don't show the --force-lock @@ -135,16 +173,6 @@ try --force-lock NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec -RUN: luarocks build --tree=/usr/invalid ./a_rock-1.0.1-rockspec --force-lock -EXIT: 4 -STDERR: --------------------------------------------------------------------------------- -requires exclusive write access -failed to force the lock --------------------------------------------------------------------------------- - -NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec - ================================================================================ -- cgit v1.2.3-55-g6feb