From f76b7a2b13e411df2e696146bb0a6396781acd92 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 29 Feb 2024 00:46:06 -0300 Subject: tests: speed up and simplify --- spec/quick/admin_make_manifest.q | 46 +++++++++++++++++ spec/quick/build.q | 103 +++++++++++++++++++++++++++++++++++++-- spec/quick/doc.q | 13 +++++ spec/quick/install.q | 60 +++++++++++++++++++++++ spec/quick/list.q | 37 +++++++++++++- spec/quick/make.q | 51 +++++++++++++++++++ spec/quick/purge.q | 103 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 407 insertions(+), 6 deletions(-) create mode 100644 spec/quick/admin_make_manifest.q create mode 100644 spec/quick/doc.q create mode 100644 spec/quick/make.q create mode 100644 spec/quick/purge.q (limited to 'spec/quick') diff --git a/spec/quick/admin_make_manifest.q b/spec/quick/admin_make_manifest.q new file mode 100644 index 00000000..da203a05 --- /dev/null +++ b/spec/quick/admin_make_manifest.q @@ -0,0 +1,46 @@ +SUITE: luarocks-admin make_manifest + +================================================================================ +TEST: runs + +FILE: test-1.0-1.rockspec +-------------------------------------------------------------------------------- +package = "test" +version = "1.0-1" +source = { + url = "file://%{url(tmpdir)}/test.lua" +} +build = { + type = "builtin", + modules = { + test = "test.lua" + } +} +-------------------------------------------------------------------------------- + +FILE: test.lua +-------------------------------------------------------------------------------- +return {} +-------------------------------------------------------------------------------- + +RUN: luarocks make --pack-binary-rock ./test-1.0-1.rockspec + +RUN: luarocks-admin make_manifest . + +FILE_CONTENTS: ./manifest-%{lua_version} +-------------------------------------------------------------------------------- +commands = {} +modules = {} +repository = { + test = { + ["1.0-1"] = { + { + arch = "all" + }, + { + arch = "rockspec" + } + } + } +} +-------------------------------------------------------------------------------- diff --git a/spec/quick/build.q b/spec/quick/build.q index a1731da2..ee519adf 100644 --- a/spec/quick/build.q +++ b/spec/quick/build.q @@ -1,4 +1,7 @@ -TEST: luarocks build: fails when given invalid argument +SUITE: luarocks build + +================================================================================ +TEST: fails when given invalid argument RUN: luarocks build aoesuthaoeusahtoeustnaou --only-server=localhost EXIT: 1 STDERR: @@ -9,7 +12,7 @@ Could not find a result named aoesuthaoeusahtoeustnaou ================================================================================ -TEST: luarocks build: with no arguments behaves as luarocks make +TEST: with no arguments behaves as luarocks make FILE: c_module-1.0-1.rockspec -------------------------------------------------------------------------------- @@ -43,7 +46,7 @@ EXISTS: c_module.%{lib_extension} ================================================================================ -TEST: luarocks build: defaults to builtin type +TEST: defaults to builtin type FILE: a_rock-1.0-1.rockspec -------------------------------------------------------------------------------- @@ -74,7 +77,7 @@ a_rock 1.0 ================================================================================ -TEST: luarocks build: fails if no permissions to access the specified tree #unix +TEST: fails if no permissions to access the specified tree #unix RUN: luarocks build --tree=/usr ./a_rock-1.0.1-rockspec EXIT: 4 @@ -99,7 +102,7 @@ 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 +TEST: fails if no permissions to access the parent #unix RUN: luarocks build --tree=/usr/invalid ./a_rock-1.0.1-rockspec EXIT: 4 @@ -160,3 +163,93 @@ STDOUT: a_rock 1.0-1 is already installed Use --force to reinstall -------------------------------------------------------------------------------- + + + +================================================================================ +TEST: supports --pin #pinning + +FILE: test-1.0-1.rockspec +-------------------------------------------------------------------------------- +package = "test" +version = "1.0-1" +source = { + url = "file://%{url(tmpdir)}/test.lua" +} +dependencies = { + "a_rock >= 0.8" +} +build = { + type = "builtin", + modules = { + test = "test.lua" + } +} +-------------------------------------------------------------------------------- + +FILE: test.lua +-------------------------------------------------------------------------------- +return {} +-------------------------------------------------------------------------------- + +RUN: luarocks build --only-server=%{fixtures_dir}/a_repo test-1.0-1.rockspec --pin --tree=lua_modules + +EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/test/1.0-1/test-1.0-1.rockspec +EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/a_rock/2.0-1/a_rock-2.0-1.rockspec + +EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/test/1.0-1/luarocks.lock + +FILE_CONTENTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/test/1.0-1/luarocks.lock +-------------------------------------------------------------------------------- +return { + dependencies = { + a_rock = "2.0-1", + lua = "%{lua_version}-1" + } +} +-------------------------------------------------------------------------------- + + + +================================================================================ +TEST: supports --pin --only-deps #pinning + +FILE: test-1.0-1.rockspec +-------------------------------------------------------------------------------- +package = "test" +version = "1.0-1" +source = { + url = "file://%{url(tmpdir)}/test.lua" +} +dependencies = { + "a_rock >= 0.8" +} +build = { + type = "builtin", + modules = { + test = "test.lua" + } +} +-------------------------------------------------------------------------------- + +FILE: test.lua +-------------------------------------------------------------------------------- +return {} +-------------------------------------------------------------------------------- + +RUN: luarocks build --only-server=%{fixtures_dir}/a_repo test-1.0-1.rockspec --pin --only-deps --tree=lua_modules + +NOT_EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/test/1.0-1/test-1.0-1.rockspec +EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/a_rock/2.0-1/a_rock-2.0-1.rockspec + +EXISTS: ./luarocks.lock + +FILE_CONTENTS: ./luarocks.lock +-------------------------------------------------------------------------------- +return { + dependencies = { + a_rock = "2.0-1", + lua = "%{lua_version}-1" + } +} +-------------------------------------------------------------------------------- diff --git a/spec/quick/doc.q b/spec/quick/doc.q new file mode 100644 index 00000000..4c71f838 --- /dev/null +++ b/spec/quick/doc.q @@ -0,0 +1,13 @@ +SUITE: luarocks doc + +================================================================================ +TEST: --local + +RUN: luarocks install --local --only-server=%{fixtures_dir}/a_repo a_rock + +RUN: luarocks doc a_rock --local + +STDOUT: +-------------------------------------------------------------------------------- +opening http://www.example.com +-------------------------------------------------------------------------------- diff --git a/spec/quick/install.q b/spec/quick/install.q index 503aaacc..72795504 100644 --- a/spec/quick/install.q +++ b/spec/quick/install.q @@ -415,3 +415,63 @@ STDOUT: myrock 1.0-1 is already installed Use --force to reinstall -------------------------------------------------------------------------------- + + + +================================================================================ +TEST: installation rolls back on failure + +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 = { + ["folder.rock"] = "rock.lua", + ["xyz"] = "xyz.lua", + }, +} +-------------------------------------------------------------------------------- + +FILE: rock.lua +-------------------------------------------------------------------------------- +return {} +-------------------------------------------------------------------------------- + +FILE: xyz.lua +-------------------------------------------------------------------------------- +return {} +-------------------------------------------------------------------------------- + +RUN: luarocks make --pack-binary-rock ./myrock-1.0-1.rockspec + +FILE: %{testing_sys_tree}/share/lua/%{lua_version}/folder +-------------------------------------------------------------------------------- +a file where a folder should be +-------------------------------------------------------------------------------- + +Try to install and fail because the file is in the folder's spot: + +RUN: luarocks install ./myrock-1.0-1.all.rock +EXIT: 1 + +EXISTS: %{testing_sys_tree}/share/lua/%{lua_version}/folder + +No leftovers from the failed installation: + +NOT_EXISTS: %{testing_sys_tree}/share/lua/%{lua_version}/xyz.lua + +Now we remove the file... + +RM: %{testing_sys_tree}/share/lua/%{lua_version}/folder + +Try again and succeed: + +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 diff --git a/spec/quick/list.q b/spec/quick/list.q index fbb3f557..a40f37ef 100644 --- a/spec/quick/list.q +++ b/spec/quick/list.q @@ -1,5 +1,7 @@ +SUITE: luarocks list + ================================================================================ -TEST: luarocks list: invalid tree +TEST: invalid tree RUN: luarocks --tree=%{path(/some/invalid/tree)} list @@ -8,3 +10,36 @@ STDOUT: Rocks installed for Lua %{lua_version} in %{path(/some/invalid/tree)} -------------------------------------------------------------------------------- + + +================================================================================ +TEST: --porcelain + +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 list --porcelain + +STDOUT: +-------------------------------------------------------------------------------- +a_rock 1.0-1 installed %{testing_sys_rocks} +-------------------------------------------------------------------------------- diff --git a/spec/quick/make.q b/spec/quick/make.q new file mode 100644 index 00000000..c77bb499 --- /dev/null +++ b/spec/quick/make.q @@ -0,0 +1,51 @@ +SUITE: luarocks make + +================================================================================ +TEST: overrides luarocks.lock with --pin #pinning + +FILE: test-2.0-1.rockspec +-------------------------------------------------------------------------------- +package = "test" +version = "2.0-1" +source = { + url = "file://%{path(tmpdir)}/test.lua" +} +dependencies = { + "a_rock >= 0.8" +} +build = { + type = "builtin", + modules = { + test = "test.lua" + } +} +-------------------------------------------------------------------------------- + +FILE: test.lua +-------------------------------------------------------------------------------- +return {} +-------------------------------------------------------------------------------- + +FILE: luarocks.lock +-------------------------------------------------------------------------------- +return { + dependencies = { + ["a_rock"] = "1.0-1", + } +} +-------------------------------------------------------------------------------- + +RUN: luarocks make --only-server=%{fixtures_dir}/a_repo --pin --tree=lua_modules + +EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/test/2.0-1/test-2.0-1.rockspec +EXISTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/a_rock/2.0-1/a_rock-2.0-1.rockspec + +FILE_CONTENTS: ./lua_modules/lib/luarocks/rocks-%{lua_version}/test/2.0-1/luarocks.lock +-------------------------------------------------------------------------------- +return { + dependencies = { + a_rock = "2.0-1", + lua = "%{lua_version}-1" + } +} +-------------------------------------------------------------------------------- diff --git a/spec/quick/purge.q b/spec/quick/purge.q new file mode 100644 index 00000000..a3f24b99 --- /dev/null +++ b/spec/quick/purge.q @@ -0,0 +1,103 @@ +SUITE: luarocks purge + +================================================================================ +TEST: needs a --tree argument +RUN: luarocks purge +EXIT: 1 + +================================================================================ +TEST: missing tree +RUN: luarocks purge --tree=missing-tree +EXIT: 1 + +================================================================================ +TEST: missing --tree argument +RUN: luarocks purge --tree= +EXIT: 1 + + +================================================================================ +TEST: runs + +FILE: testrock-1.0-1.rockspec +-------------------------------------------------------------------------------- +package = "testrock" +version = "1.0-1" +source = { + url = "file://%{url(tmpdir)}/testrock.lua" +} +dependencies = { + "a_rock >= 0.8" +} +build = { + type = "builtin", + modules = { + testrock = "testrock.lua" + } +} +-------------------------------------------------------------------------------- + +FILE: testrock.lua +-------------------------------------------------------------------------------- +return {} +-------------------------------------------------------------------------------- + +RUN: luarocks build --only-server=%{fixtures_dir}/a_repo testrock-1.0-1.rockspec + +EXISTS: %{testing_sys_rocks}/testrock +EXISTS: %{testing_sys_rocks}/a_rock + +RUN: luarocks purge --tree=%{testing_sys_tree} + +NOT_EXISTS: %{testing_sys_rocks}/testrock +NOT_EXISTS: %{testing_sys_rocks}/a_rock + + + +================================================================================ +TEST: works with missing files + +FILE: testrock-1.0-1.rockspec +-------------------------------------------------------------------------------- +package = "testrock" +version = "1.0-1" +source = { + url = "file://%{url(tmpdir)}/testrock.lua" +} +dependencies = { + "a_rock >= 0.8" +} +build = { + type = "builtin", + modules = { + testrock = "testrock.lua" + } +} +-------------------------------------------------------------------------------- + +FILE: testrock.lua +-------------------------------------------------------------------------------- +return {} +-------------------------------------------------------------------------------- + +RUN: luarocks build --only-server=%{fixtures_dir}/a_repo testrock-1.0-1.rockspec + +RMDIR: %{testing_sys_tree}/share/lua/%{lua_version}/testrock + +RUN: luarocks purge --tree=%{testing_sys_tree} + +NOT_EXISTS: %{testing_sys_rocks}/testrock +NOT_EXISTS: %{testing_sys_rocks}/a_rock + + + +================================================================================ +TEST: --old-versions + +RUN: luarocks install --only-server=%{fixtures_dir}/a_repo a_rock 2.0 +RUN: luarocks install --only-server=%{fixtures_dir}/a_repo a_rock 1.0 --keep + +RUN: luarocks purge --old-versions --tree=%{testing_sys_tree} + +EXISTS: %{testing_sys_rocks}/a_rock/2.0-1 +NOT_EXISTS: %{testing_sys_rocks}/a_rock/1.0-1 -- cgit v1.2.3-55-g6feb