diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-03-04 12:17:56 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-03-05 15:58:45 +0000 |
| commit | 78d40e304be182b7e07be449ebda668b8b9d0fcd (patch) | |
| tree | 4df133a573797e77dc1eab3f47d6a42b37a9f91f /spec | |
| parent | 527b112738ce17fe93289ed879a2b84437fc5c40 (diff) | |
| download | luarocks-78d40e304be182b7e07be449ebda668b8b9d0fcd.tar.gz luarocks-78d40e304be182b7e07be449ebda668b8b9d0fcd.tar.bz2 luarocks-78d40e304be182b7e07be449ebda668b8b9d0fcd.zip | |
fix: check permissions before trying to lock
This should provide a better error message.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/quick/build.q | 76 |
1 files changed, 52 insertions, 24 deletions
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 | |||
| 79 | ================================================================================ | 79 | ================================================================================ |
| 80 | TEST: fails if no permissions to access the specified tree #unix | 80 | TEST: fails if no permissions to access the specified tree #unix |
| 81 | 81 | ||
| 82 | RUN: luarocks build --tree=/usr ./a_rock-1.0.1-rockspec | 82 | RUN: luarocks build --tree=/usr ./a_rock-1.0-1.rockspec |
| 83 | EXIT: 4 | 83 | EXIT: 2 |
| 84 | STDERR: | 84 | STDERR: |
| 85 | -------------------------------------------------------------------------------- | 85 | -------------------------------------------------------------------------------- |
| 86 | requires exclusive write access | 86 | You may want to run as a privileged user, |
| 87 | or use --local to install into your local tree | ||
| 88 | or run 'luarocks config local_by_default true' to make --local the default. | ||
| 89 | |||
| 90 | (You may need to configure your Lua package paths | ||
| 91 | to use the local tree, see 'luarocks path --help') | ||
| 87 | -------------------------------------------------------------------------------- | 92 | -------------------------------------------------------------------------------- |
| 88 | 93 | ||
| 89 | We show the OS permission denied error, so we don't show the --force-lock | 94 | We show the OS permission denied error, so we don't show the --force-lock |
| @@ -96,33 +101,66 @@ try --force-lock | |||
| 96 | 101 | ||
| 97 | NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec | 102 | NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec |
| 98 | 103 | ||
| 99 | RUN: luarocks build --tree=/usr ./a_rock-1.0.1-rockspec --force-lock | 104 | |
| 100 | EXIT: 4 | 105 | |
| 101 | STDERR: | 106 | ================================================================================ |
| 107 | TEST: fails if tree is locked, --force-lock overrides #unix | ||
| 108 | |||
| 109 | FILE: a_rock-1.0-1.rockspec | ||
| 102 | -------------------------------------------------------------------------------- | 110 | -------------------------------------------------------------------------------- |
| 103 | requires exclusive write access | 111 | rockspec_format = "3.0" |
| 112 | package = "a_rock" | ||
| 113 | version = "1.0-1" | ||
| 114 | source = { | ||
| 115 | url = "file://%{url(%{fixtures_dir})}/a_rock.lua" | ||
| 116 | } | ||
| 117 | description = { | ||
| 118 | summary = "An example rockspec", | ||
| 119 | } | ||
| 120 | dependencies = { | ||
| 121 | "lua >= 5.1" | ||
| 122 | } | ||
| 123 | build = { | ||
| 124 | modules = { | ||
| 125 | build = "a_rock.lua" | ||
| 126 | }, | ||
| 127 | } | ||
| 104 | -------------------------------------------------------------------------------- | 128 | -------------------------------------------------------------------------------- |
| 105 | 129 | ||
| 106 | We show the OS permission denied error, so we don't show the --force-lock | 130 | FILE: %{testing_tree}/lockfile.lfs |
| 107 | message. | 131 | -------------------------------------------------------------------------------- |
| 132 | dummy lock file for testing | ||
| 133 | -------------------------------------------------------------------------------- | ||
| 108 | 134 | ||
| 109 | NOT_STDERR: | 135 | RUN: luarocks build --tree=%{testing_tree} ./a_rock-1.0-1.rockspec |
| 136 | EXIT: 4 | ||
| 137 | STDERR: | ||
| 110 | -------------------------------------------------------------------------------- | 138 | -------------------------------------------------------------------------------- |
| 139 | requires exclusive write access | ||
| 111 | try --force-lock | 140 | try --force-lock |
| 112 | -------------------------------------------------------------------------------- | 141 | -------------------------------------------------------------------------------- |
| 113 | 142 | ||
| 114 | NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec | 143 | RUN: luarocks build --tree=%{testing_tree} ./a_rock-1.0-1.rockspec --force-lock |
| 144 | EXIT: 0 | ||
| 115 | 145 | ||
| 116 | 146 | ||
| 117 | 147 | ||
| 118 | ================================================================================ | 148 | ================================================================================ |
| 119 | TEST: fails if no permissions to access the parent #unix | 149 | TEST: fails if no permissions to access the parent #unix |
| 120 | 150 | ||
| 121 | RUN: luarocks build --tree=/usr/invalid ./a_rock-1.0.1-rockspec | 151 | RUN: luarocks build --tree=/usr/invalid ./a_rock-1.0-1.rockspec |
| 122 | EXIT: 4 | 152 | EXIT: 2 |
| 123 | STDERR: | 153 | STDERR: |
| 124 | -------------------------------------------------------------------------------- | 154 | -------------------------------------------------------------------------------- |
| 125 | requires exclusive write access | 155 | Error: /usr/invalid/lib/luarocks/rocks-%{lua_version} does not exist |
| 156 | and your user does not have write permissions in /usr | ||
| 157 | |||
| 158 | You may want to run as a privileged user, | ||
| 159 | or use --local to install into your local tree | ||
| 160 | or run 'luarocks config local_by_default true' to make --local the default. | ||
| 161 | |||
| 162 | (You may need to configure your Lua package paths | ||
| 163 | to use the local tree, see 'luarocks path --help') | ||
| 126 | -------------------------------------------------------------------------------- | 164 | -------------------------------------------------------------------------------- |
| 127 | 165 | ||
| 128 | We show the OS permission denied error, so we don't show the --force-lock | 166 | We show the OS permission denied error, so we don't show the --force-lock |
| @@ -135,16 +173,6 @@ try --force-lock | |||
| 135 | 173 | ||
| 136 | NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec | 174 | NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec |
| 137 | 175 | ||
| 138 | RUN: luarocks build --tree=/usr/invalid ./a_rock-1.0.1-rockspec --force-lock | ||
| 139 | EXIT: 4 | ||
| 140 | STDERR: | ||
| 141 | -------------------------------------------------------------------------------- | ||
| 142 | requires exclusive write access | ||
| 143 | failed to force the lock | ||
| 144 | -------------------------------------------------------------------------------- | ||
| 145 | |||
| 146 | NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec | ||
| 147 | |||
| 148 | 176 | ||
| 149 | 177 | ||
| 150 | ================================================================================ | 178 | ================================================================================ |
