diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-03-13 15:32:35 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-03-13 19:08:05 +0000 |
| commit | 4117ad5045b310a7902edb6a78c1c1386ddeaea0 (patch) | |
| tree | e96d515f1d2646817bad41307770c1f56f3066db | |
| parent | 1829ba36d0764c3210766bd0bc878695282114aa (diff) | |
| download | luarocks-4117ad5045b310a7902edb6a78c1c1386ddeaea0.tar.gz luarocks-4117ad5045b310a7902edb6a78c1c1386ddeaea0.tar.bz2 luarocks-4117ad5045b310a7902edb6a78c1c1386ddeaea0.zip | |
tests: convert most pack tests
| -rw-r--r-- | spec/pack_spec.lua | 67 | ||||
| -rw-r--r-- | spec/quick/pack.q | 128 | ||||
| -rw-r--r-- | spec/quick_spec.lua | 4 | ||||
| -rw-r--r-- | spec/util/quick.lua | 2 |
4 files changed, 135 insertions, 66 deletions
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index 20a2b3ef..2a2fb3a5 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua | |||
| @@ -4,60 +4,10 @@ local run = test_env.run | |||
| 4 | local testing_paths = test_env.testing_paths | 4 | local testing_paths = test_env.testing_paths |
| 5 | local write_file = test_env.write_file | 5 | local write_file = test_env.write_file |
| 6 | 6 | ||
| 7 | local extra_rocks = { | ||
| 8 | "/luassert-1.7.0-1.src.rock", | ||
| 9 | "/luasocket-${LUASOCKET}.src.rock", | ||
| 10 | "/luasocket-${LUASOCKET}.rockspec", | ||
| 11 | "/say-1.2-1.src.rock", | ||
| 12 | "/say-1.0-1.src.rock" | ||
| 13 | } | ||
| 14 | |||
| 15 | describe("luarocks pack #integration", function() | 7 | describe("luarocks pack #integration", function() |
| 16 | 8 | ||
| 17 | before_each(function() | 9 | lazy_setup(function() |
| 18 | test_env.setup_specs(extra_rocks) | 10 | test_env.setup_specs() |
| 19 | end) | ||
| 20 | |||
| 21 | it("with no flags/arguments", function() | ||
| 22 | assert.is_false(run.luarocks_bool("pack")) | ||
| 23 | end) | ||
| 24 | |||
| 25 | it("basic", function() | ||
| 26 | assert(run.luarocks_bool("pack luacov")) | ||
| 27 | assert(test_env.remove_files(lfs.currentdir(), "luacov%-")) | ||
| 28 | end) | ||
| 29 | |||
| 30 | it("invalid rockspec", function() | ||
| 31 | assert.is_false(run.luarocks_bool("pack " .. testing_paths.fixtures_dir .. "/invalid_say-1.3-1.rockspec")) | ||
| 32 | end) | ||
| 33 | |||
| 34 | it("not installed rock", function() | ||
| 35 | assert.is_false(run.luarocks_bool("pack cjson")) | ||
| 36 | end) | ||
| 37 | |||
| 38 | it("not installed rock from non existing manifest", function() | ||
| 39 | assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif")) | ||
| 40 | end) | ||
| 41 | |||
| 42 | it("detects latest version version of rock", function() | ||
| 43 | assert(run.luarocks_bool("install say 1.2")) | ||
| 44 | assert(run.luarocks_bool("install luassert")) | ||
| 45 | assert(run.luarocks_bool("install say 1.0")) | ||
| 46 | assert(run.luarocks_bool("pack say")) | ||
| 47 | assert.is_truthy(lfs.attributes("say-1.2-1.all.rock")) | ||
| 48 | assert(test_env.remove_files(lfs.currentdir(), "say%-")) | ||
| 49 | end) | ||
| 50 | |||
| 51 | pending("#gpg --sign", function() | ||
| 52 | assert(run.luarocks_bool("install say 1.2")) | ||
| 53 | assert(run.luarocks_bool("install luassert")) | ||
| 54 | assert(run.luarocks_bool("install say 1.0")) | ||
| 55 | os.delete("say-1.2-1.all.rock") | ||
| 56 | os.delete("say-1.2-1.all.rock.asc") | ||
| 57 | assert(run.luarocks_bool("pack say --sign")) | ||
| 58 | assert.is_truthy(lfs.attributes("say-1.2-1.all.rock")) | ||
| 59 | assert.is_truthy(lfs.attributes("say-1.2-1.all.rock.asc")) | ||
| 60 | assert(test_env.remove_files(lfs.currentdir(), "say%-")) | ||
| 61 | end) | 11 | end) |
| 62 | 12 | ||
| 63 | describe("#mock", function() | 13 | describe("#mock", function() |
| @@ -149,17 +99,4 @@ describe("luarocks pack #integration", function() | |||
| 149 | end) | 99 | end) |
| 150 | end) | 100 | end) |
| 151 | end) | 101 | end) |
| 152 | |||
| 153 | describe("#namespaces", function() | ||
| 154 | it("packs a namespaced rock", function() | ||
| 155 | finally(function() | ||
| 156 | os.remove("a_rock-2.0-1.all.rock") | ||
| 157 | end) | ||
| 158 | assert(run.luarocks_bool("build a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 159 | assert(run.luarocks_bool("build a_rock --keep --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 160 | assert(run.luarocks_bool("pack a_user/a_rock" )) | ||
| 161 | assert(lfs.attributes("a_rock-2.0-1.all.rock")) | ||
| 162 | end) | ||
| 163 | end) | ||
| 164 | |||
| 165 | end) | 102 | end) |
diff --git a/spec/quick/pack.q b/spec/quick/pack.q new file mode 100644 index 00000000..ee44a45f --- /dev/null +++ b/spec/quick/pack.q | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | SUITE: luarocks pack | ||
| 2 | |||
| 3 | ================================================================================ | ||
| 4 | TEST: fails no arguments | ||
| 5 | |||
| 6 | RUN: luarocks pack | ||
| 7 | EXIT: 1 | ||
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | ================================================================================ | ||
| 12 | TEST: fails with invalid rockspec | ||
| 13 | |||
| 14 | RUN: luarocks pack $%{fixtures_dir}/invalid_say-1.3-1.rockspec | ||
| 15 | EXIT: 1 | ||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | ================================================================================ | ||
| 20 | TEST: fails with rock that is not installed | ||
| 21 | |||
| 22 | RUN: luarocks pack notinstalled | ||
| 23 | EXIT: 1 | ||
| 24 | |||
| 25 | |||
| 26 | |||
| 27 | ================================================================================ | ||
| 28 | TEST: fails with non existing path | ||
| 29 | |||
| 30 | RUN: luarocks pack /notexists/notinstalled | ||
| 31 | EXIT: 1 | ||
| 32 | |||
| 33 | |||
| 34 | |||
| 35 | ================================================================================ | ||
| 36 | TEST: packs latest version version of rock | ||
| 37 | |||
| 38 | FILE: myrock-1.0-1.rockspec | ||
| 39 | -------------------------------------------------------------------------------- | ||
| 40 | rockspec_format = "3.0" | ||
| 41 | package = "myrock" | ||
| 42 | version = "1.0-1" | ||
| 43 | source = { | ||
| 44 | url = "file://%{url(%{tmpdir})}/rock.lua" | ||
| 45 | } | ||
| 46 | build = { | ||
| 47 | modules = { rock = "rock.lua" } | ||
| 48 | } | ||
| 49 | -------------------------------------------------------------------------------- | ||
| 50 | |||
| 51 | FILE: myrock-2.0-1.rockspec | ||
| 52 | -------------------------------------------------------------------------------- | ||
| 53 | rockspec_format = "3.0" | ||
| 54 | package = "myrock" | ||
| 55 | version = "2.0-1" | ||
| 56 | source = { | ||
| 57 | url = "file://%{url(%{tmpdir})}/rock.lua" | ||
| 58 | } | ||
| 59 | build = { | ||
| 60 | modules = { rock = "rock.lua" } | ||
| 61 | } | ||
| 62 | -------------------------------------------------------------------------------- | ||
| 63 | |||
| 64 | FILE: rock.lua | ||
| 65 | -------------------------------------------------------------------------------- | ||
| 66 | return "hello" | ||
| 67 | -------------------------------------------------------------------------------- | ||
| 68 | |||
| 69 | RUN: luarocks build myrock-1.0-1.rockspec | ||
| 70 | RUN: luarocks build myrock-2.0-1.rockspec --keep | ||
| 71 | RUN: luarocks pack myrock | ||
| 72 | |||
| 73 | EXISTS: myrock-2.0-1.all.rock | ||
| 74 | |||
| 75 | |||
| 76 | |||
| 77 | ================================================================================ | ||
| 78 | TEST: --sign #gpg | ||
| 79 | PENDING: true | ||
| 80 | |||
| 81 | FILE: myrock-1.0-1.rockspec | ||
| 82 | -------------------------------------------------------------------------------- | ||
| 83 | rockspec_format = "3.0" | ||
| 84 | package = "myrock" | ||
| 85 | version = "1.0-1" | ||
| 86 | source = { | ||
| 87 | url = "file://%{url(%{tmpdir})}/rock.lua" | ||
| 88 | } | ||
| 89 | build = { | ||
| 90 | modules = { rock = "rock.lua" } | ||
| 91 | } | ||
| 92 | -------------------------------------------------------------------------------- | ||
| 93 | |||
| 94 | FILE: myrock-2.0-1.rockspec | ||
| 95 | -------------------------------------------------------------------------------- | ||
| 96 | rockspec_format = "3.0" | ||
| 97 | package = "myrock" | ||
| 98 | version = "2.0-1" | ||
| 99 | source = { | ||
| 100 | url = "file://%{url(%{tmpdir})}/rock.lua" | ||
| 101 | } | ||
| 102 | build = { | ||
| 103 | modules = { rock = "rock.lua" } | ||
| 104 | } | ||
| 105 | -------------------------------------------------------------------------------- | ||
| 106 | |||
| 107 | FILE: rock.lua | ||
| 108 | -------------------------------------------------------------------------------- | ||
| 109 | return "hello" | ||
| 110 | -------------------------------------------------------------------------------- | ||
| 111 | |||
| 112 | RUN: luarocks build myrock-1.0-1.rockspec | ||
| 113 | RUN: luarocks build myrock-2.0-1.rockspec --keep | ||
| 114 | RUN: luarocks pack myrock --sign | ||
| 115 | |||
| 116 | EXISTS: myrock-2.0-1.all.rock | ||
| 117 | EXISTS: myrock-2.0-1.all.rock.asc | ||
| 118 | |||
| 119 | |||
| 120 | |||
| 121 | ================================================================================ | ||
| 122 | TEST: packs a namespaced rock #namespaces | ||
| 123 | |||
| 124 | RUN: luarocks build a_user/a_rock --server=%{fixtures_dir}/a_repo | ||
| 125 | RUN: luarocks build a_rock --keep --server=%{fixtures_dir}/a_repo | ||
| 126 | RUN: luarocks pack a_user/a_rock | ||
| 127 | |||
| 128 | EXISTS: a_rock-2.0-1.all.rock | ||
diff --git a/spec/quick_spec.lua b/spec/quick_spec.lua index 8b8206cf..c2d8bb59 100644 --- a/spec/quick_spec.lua +++ b/spec/quick_spec.lua | |||
| @@ -12,7 +12,9 @@ describe("quick tests: #quick", function() | |||
| 12 | if f:match("%.q$") then | 12 | if f:match("%.q$") then |
| 13 | local tests = quick.compile(spec_quick .. "/" .. f, getfenv and getfenv() or _ENV) | 13 | local tests = quick.compile(spec_quick .. "/" .. f, getfenv and getfenv() or _ENV) |
| 14 | for _, t in ipairs(tests) do | 14 | for _, t in ipairs(tests) do |
| 15 | it(t.name, t.fn) | 15 | if not t.pending then |
| 16 | it(t.name, t.fn) | ||
| 17 | end | ||
| 16 | end | 18 | end |
| 17 | end | 19 | end |
| 18 | end | 20 | end |
diff --git a/spec/util/quick.lua b/spec/util/quick.lua index 80c75848..257f570e 100644 --- a/spec/util/quick.lua +++ b/spec/util/quick.lua | |||
| @@ -245,6 +245,8 @@ local function parse(filename) | |||
| 245 | block_start_arg("STDOUT", cur_op, "stdout") | 245 | block_start_arg("STDOUT", cur_op, "stdout") |
| 246 | elseif cmd == "NOT_STDOUT" then | 246 | elseif cmd == "NOT_STDOUT" then |
| 247 | block_start_arg("NOT_STDOUT", cur_op, "not_stdout") | 247 | block_start_arg("NOT_STDOUT", cur_op, "not_stdout") |
| 248 | elseif cmd == "PENDING" then | ||
| 249 | bool_arg("PENDING", cur_test, "pending", arg) | ||
| 248 | elseif cmd == "TEST" then | 250 | elseif cmd == "TEST" then |
| 249 | table.remove(stack) | 251 | table.remove(stack) |
| 250 | start_test(arg) | 252 | start_test(arg) |
