From 79bd1739d8ca004ddd0b2fa5e24da4a6f4b776fa Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 21 Feb 2024 22:30:40 -0300 Subject: tests: introduce quick tests --- spec/quick/build.q | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++ spec/quick/config.q | 17 +++++++ spec/quick/install.q | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++ spec/quick/list.q | 10 +++++ 4 files changed, 273 insertions(+) create mode 100644 spec/quick/build.q create mode 100644 spec/quick/config.q create mode 100644 spec/quick/install.q create mode 100644 spec/quick/list.q (limited to 'spec/quick') diff --git a/spec/quick/build.q b/spec/quick/build.q new file mode 100644 index 00000000..c6ca433c --- /dev/null +++ b/spec/quick/build.q @@ -0,0 +1,122 @@ +TEST: luarocks build: fails when given invalid argument +RUN: luarocks build aoesuthaoeusahtoeustnaou --only-server=localhost +EXIT: 1 +STDERR: +-------------------------------------------------------------------------------- +Could not find a result named aoesuthaoeusahtoeustnaou +-------------------------------------------------------------------------------- + + + +================================================================================ +TEST: luarocks build: with no arguments behaves as luarocks make + +FILE: c_module-1.0-1.rockspec +-------------------------------------------------------------------------------- +package = "c_module" +version = "1.0-1" +source = { + url = "http://example.com/c_module" +} +build = { + type = "builtin", + modules = { + c_module = { "c_module.c" } + } +} +-------------------------------------------------------------------------------- +FILE: c_module.c +-------------------------------------------------------------------------------- +#include +#include + +int luaopen_c_module(lua_State* L) { + lua_newtable(L); + lua_pushinteger(L, 1); + lua_setfield(L, -2, "c_module"); + return 1; +} +-------------------------------------------------------------------------------- +RUN: luarocks build +EXISTS: c_module.%{lib_extension} + + + +================================================================================ +TEST: luarocks build: defaults to builtin type + +FILE: a_rock-1.0-1.rockspec +-------------------------------------------------------------------------------- +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" + }, +} +-------------------------------------------------------------------------------- +RUN: luarocks build a_rock-1.0-1.rockspec +RUN: luarocks show a_rock +STDOUT: +-------------------------------------------------------------------------------- +a_rock 1.0 +-------------------------------------------------------------------------------- + + +================================================================================ +TEST: luarocks build: fails if no permissions to access the specified tree #unix + +RUN: luarocks build --tree=/usr ./a_rock-1.0.1-rockspec +EXIT: 4 +STDERR: +-------------------------------------------------------------------------------- +requires exclusive access +use --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: +-------------------------------------------------------------------------------- +requires exclusive access +failed to force the lock +-------------------------------------------------------------------------------- + +NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec + + + +================================================================================ +TEST: luarocks build: fails if no permissions to access the parent #unix + +RUN: luarocks build --tree=/usr/invalid ./a_rock-1.0.1-rockspec +EXIT: 4 +STDERR: +-------------------------------------------------------------------------------- +requires exclusive access +use --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 access +failed to force the lock +-------------------------------------------------------------------------------- + +NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1/a_rock-1.0-1.rockspec diff --git a/spec/quick/config.q b/spec/quick/config.q new file mode 100644 index 00000000..ec338f98 --- /dev/null +++ b/spec/quick/config.q @@ -0,0 +1,17 @@ +================================================================================ +TEST: luarocks config --system-config shows the path of the system config + +MKDIR: %{testing_lrprefix}/etc/luarocks + +FILE: %{testing_lrprefix}/etc/luarocks/config-%{LUA_VERSION}.lua +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- + +RUN: luarocks config --system-config + +STDOUT: +-------------------------------------------------------------------------------- +%{testing_lrprefix}/etc/luarocks/config-%{LUA_VERSION}.lua +-------------------------------------------------------------------------------- +#TODO: ^^^ %{path()} diff --git a/spec/quick/install.q b/spec/quick/install.q new file mode 100644 index 00000000..2bccf2f1 --- /dev/null +++ b/spec/quick/install.q @@ -0,0 +1,124 @@ +=============================================================================== +TEST: luarocks install: handle versioned modules when installing another version with --keep #268 + +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: rock.lua +-------------------------------------------------------------------------------- +return "hello" +-------------------------------------------------------------------------------- + +RUN: luarocks build myrock-1.0-1.rockspec +RUN: luarocks pack myrock +RUN: luarocks remove myrock + +RUN: luarocks build myrock-2.0-1.rockspec +RUN: luarocks pack myrock +RUN: luarocks remove myrock + +RUN: luarocks install ./myrock-2.0-1.all.rock + +EXISTS: %{testing_sys_tree}/share/lua/%{LUA_VERSION}/rock.lua + +RUN: luarocks install ./myrock-1.0-1.all.rock --keep + +EXISTS: %{testing_sys_tree}/share/lua/%{LUA_VERSION}/rock.lua +EXISTS: %{testing_sys_tree}/share/lua/%{LUA_VERSION}/myrock_1_0_1-rock.lua + +RUN: luarocks install ./myrock-2.0-1.all.rock + +EXISTS: %{testing_sys_tree}/share/lua/%{LUA_VERSION}/rock.lua +NOT_EXISTS: %{testing_sys_tree}/share/lua/%{LUA_VERSION}/myrock_1_0_1-rock.lua + + + +=============================================================================== +TEST: luarocks install: handle versioned libraries when installing another version with --keep #268 + +FILE: myrock-1.0-1.rockspec +-------------------------------------------------------------------------------- +rockspec_format = "3.0" +package = "myrock" +version = "1.0-1" +source = { + url = "file://%{url(tmpdir)}/c_module.c" +} +build = { + modules = { + c_module = { "c_module.c" } + } +} +-------------------------------------------------------------------------------- + +FILE: myrock-2.0-1.rockspec +-------------------------------------------------------------------------------- +rockspec_format = "3.0" +package = "myrock" +version = "2.0-1" +source = { + url = "file://%{url(tmpdir)}/c_module.c" +} +build = { + modules = { + c_module = { "c_module.c" } + } +} +-------------------------------------------------------------------------------- +FILE: c_module.c +-------------------------------------------------------------------------------- +#include +#include + +int luaopen_c_module(lua_State* L) { + lua_newtable(L); + lua_pushinteger(L, 1); + lua_setfield(L, -2, "c_module"); + return 1; +} +-------------------------------------------------------------------------------- + +RUN: luarocks build myrock-1.0-1.rockspec +RUN: luarocks pack myrock +RUN: luarocks remove myrock + +RUN: luarocks build myrock-2.0-1.rockspec +RUN: luarocks pack myrock +RUN: luarocks remove myrock + +RUN: luarocks install ./myrock-2.0-1.%{platform}.rock + +EXISTS: %{testing_sys_tree}/lib/lua/%{LUA_VERSION}/c_module.%{lib_extension} + +RUN: luarocks install ./myrock-1.0-1.%{platform}.rock --keep + +EXISTS: %{testing_sys_tree}/lib/lua/%{LUA_VERSION}/c_module.%{lib_extension} +EXISTS: %{testing_sys_tree}/lib/lua/%{LUA_VERSION}/myrock_1_0_1-c_module.%{lib_extension} + +RUN: luarocks install ./myrock-2.0-1.%{platform}.rock + +EXISTS: %{testing_sys_tree}/lib/lua/%{LUA_VERSION}/c_module.%{lib_extension} +NOT_EXISTS: %{testing_sys_tree}/lib/lua/%{LUA_VERSION}/myrock_1_0_1-c_module.%{lib_extension} diff --git a/spec/quick/list.q b/spec/quick/list.q new file mode 100644 index 00000000..7cbdee43 --- /dev/null +++ b/spec/quick/list.q @@ -0,0 +1,10 @@ +================================================================================ +TEST: luarocks list: invalid tree + +RUN: luarocks --tree=%{path(/some/invalid/tree)} list + +STDOUT: +-------------------------------------------------------------------------------- +Rocks installed for Lua %{lua_version} in /some/invalid/tree +-------------------------------------------------------------------------------- +#TODO: ^^^ %{path()} -- cgit v1.2.3-55-g6feb