diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-03-13 13:49:22 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-03-13 19:08:05 +0000 |
| commit | 7cafa62d20246ea17ff1d80bb75c930e8c44feef (patch) | |
| tree | 32a5392e5135d2ccf5470908159d2d4a2722b25b | |
| parent | 870948dd2d4e208dd98ada966a109cf7156b3e4d (diff) | |
| download | luarocks-7cafa62d20246ea17ff1d80bb75c930e8c44feef.tar.gz luarocks-7cafa62d20246ea17ff1d80bb75c930e8c44feef.tar.bz2 luarocks-7cafa62d20246ea17ff1d80bb75c930e8c44feef.zip | |
tests: replace new_version with quick tests
| -rw-r--r-- | spec/new_version_spec.lua | 85 | ||||
| -rw-r--r-- | spec/quick/new_version.q | 213 |
2 files changed, 213 insertions, 85 deletions
diff --git a/spec/new_version_spec.lua b/spec/new_version_spec.lua deleted file mode 100644 index 18271176..00000000 --- a/spec/new_version_spec.lua +++ /dev/null | |||
| @@ -1,85 +0,0 @@ | |||
| 1 | local test_env = require("spec.util.test_env") | ||
| 2 | local lfs = require("lfs") | ||
| 3 | local run = test_env.run | ||
| 4 | local testing_paths = test_env.testing_paths | ||
| 5 | |||
| 6 | local extra_rocks = { | ||
| 7 | "/abelhas-1.1-1.rockspec", | ||
| 8 | "/lpeg-${LPEG}.rockspec" | ||
| 9 | } | ||
| 10 | |||
| 11 | describe("luarocks new_version #integration", function() | ||
| 12 | |||
| 13 | lazy_setup(function() | ||
| 14 | test_env.setup_specs(extra_rocks) | ||
| 15 | end) | ||
| 16 | |||
| 17 | describe("basic tests", function() | ||
| 18 | it("with no flags/arguments", function() | ||
| 19 | finally(function() | ||
| 20 | lfs.chdir(testing_paths.testrun_dir) | ||
| 21 | test_env.remove_dir("empty") | ||
| 22 | end) | ||
| 23 | assert(lfs.mkdir("empty")) | ||
| 24 | assert(lfs.chdir("empty")) | ||
| 25 | assert.is_false(run.luarocks_bool("new_version")) | ||
| 26 | end) | ||
| 27 | |||
| 28 | it("with invalid", function() | ||
| 29 | assert.is_false(run.luarocks_bool("new_version invalid")) | ||
| 30 | end) | ||
| 31 | |||
| 32 | it("with invalid url", function() | ||
| 33 | assert.is_true(run.luarocks_bool("download --rockspec abelhas 1.1")) | ||
| 34 | assert.is_true(run.luarocks_bool("new_version abelhas-1.1-1.rockspec 1.1 http://luainvalid")) | ||
| 35 | assert.is.truthy(lfs.attributes("abelhas-1.1-1.rockspec")) | ||
| 36 | test_env.remove_files(lfs.currentdir(), "abelhas%-") | ||
| 37 | end) | ||
| 38 | end) | ||
| 39 | |||
| 40 | describe("more complex tests", function() | ||
| 41 | it("of luacov", function() | ||
| 42 | assert.is_true(run.luarocks_bool("download --rockspec luacov ${LUACOV_V}")) | ||
| 43 | assert.is_true(run.luarocks_bool("new_version luacov-${LUACOV}.rockspec 0.2")) | ||
| 44 | assert.is.truthy(lfs.attributes("luacov-0.2-1.rockspec")) | ||
| 45 | test_env.remove_files(lfs.currentdir(), "luacov%-") | ||
| 46 | end) | ||
| 47 | |||
| 48 | it("url of abelhas", function() | ||
| 49 | assert.is_true(run.luarocks_bool("download --rockspec abelhas 1.1")) | ||
| 50 | assert.is_true(run.luarocks_bool("new_version abelhas-1.1-1.rockspec 1.2 http://example.com/abelhas-1.2.tar.gz")) | ||
| 51 | assert.is.truthy(lfs.attributes("abelhas-1.2-1.rockspec")) | ||
| 52 | test_env.remove_files(lfs.currentdir(), "abelhas%-") | ||
| 53 | end) | ||
| 54 | |||
| 55 | it("of luacov with tag", function() | ||
| 56 | assert.is_true(run.luarocks_bool("download --rockspec luacov ${LUACOV_V}")) | ||
| 57 | assert.is_true(run.luarocks_bool("new_version luacov-${LUACOV}.rockspec --tag v0.3")) | ||
| 58 | assert.is.truthy(lfs.attributes("luacov-0.3-1.rockspec")) | ||
| 59 | test_env.remove_files(lfs.currentdir(), "luacov%-") | ||
| 60 | end) | ||
| 61 | |||
| 62 | it("updating md5", function() | ||
| 63 | assert.is_true(run.luarocks_bool("download --rockspec lpeg ${LPEG_V}")) | ||
| 64 | assert.is_true(run.luarocks_bool("new_version lpeg-${LPEG}.rockspec 0.2 https://luarocks.org/manifests/gvvaughan/lpeg-1.0.0-1.rockspec")) | ||
| 65 | test_env.remove_files(lfs.currentdir(), "lpeg%-") | ||
| 66 | end) | ||
| 67 | end) | ||
| 68 | |||
| 69 | describe("remote tests #mock", function() | ||
| 70 | lazy_setup(function() | ||
| 71 | test_env.setup_specs(extra_rocks, "mock") | ||
| 72 | test_env.mock_server_init() | ||
| 73 | end) | ||
| 74 | lazy_teardown(function() | ||
| 75 | test_env.mock_server_done() | ||
| 76 | end) | ||
| 77 | it("with remote spec", function() | ||
| 78 | assert.is_true(run.luarocks_bool("new_version http://localhost:8080/file/a_rock-1.0-1.rockspec")) | ||
| 79 | assert.is.truthy(lfs.attributes("a_rock-1.0-1.rockspec")) | ||
| 80 | assert.is.truthy(lfs.attributes("a_rock-1.0-2.rockspec")) | ||
| 81 | test_env.remove_files(lfs.currentdir(), "luasocket%-") | ||
| 82 | end) | ||
| 83 | end) | ||
| 84 | |||
| 85 | end) | ||
diff --git a/spec/quick/new_version.q b/spec/quick/new_version.q new file mode 100644 index 00000000..98426db4 --- /dev/null +++ b/spec/quick/new_version.q | |||
| @@ -0,0 +1,213 @@ | |||
| 1 | SUITE: luarocks new_version | ||
| 2 | |||
| 3 | ================================================================================ | ||
| 4 | TEST: fails without a context | ||
| 5 | |||
| 6 | RUN: luarocks new_version | ||
| 7 | EXIT: 1 | ||
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | ================================================================================ | ||
| 12 | TEST: fails with invalid arg | ||
| 13 | |||
| 14 | RUN: luarocks new_version i_dont_exist | ||
| 15 | EXIT: 1 | ||
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | ================================================================================ | ||
| 20 | TEST: updates a version | ||
| 21 | |||
| 22 | FILE: myexample-0.1-1.rockspec | ||
| 23 | -------------------------------------------------------------------------------- | ||
| 24 | package = "myexample" | ||
| 25 | version = "0.1-1" | ||
| 26 | source = { | ||
| 27 | url = "git+https://localhost/myexample.git", | ||
| 28 | tag = "v0.1" | ||
| 29 | } | ||
| 30 | description = { | ||
| 31 | summary = "xxx", | ||
| 32 | detailed = "xxx" | ||
| 33 | } | ||
| 34 | build = { | ||
| 35 | type = "builtin", | ||
| 36 | modules = { | ||
| 37 | foo = "src/foo.lua" | ||
| 38 | } | ||
| 39 | } | ||
| 40 | -------------------------------------------------------------------------------- | ||
| 41 | |||
| 42 | RUN: luarocks new_version myexample-0.1-1.rockspec 0.2 | ||
| 43 | |||
| 44 | FILE_CONTENTS: myexample-0.2-1.rockspec | ||
| 45 | -------------------------------------------------------------------------------- | ||
| 46 | package = "myexample" | ||
| 47 | version = "0.2-1" | ||
| 48 | source = { | ||
| 49 | url = "git+https://localhost/myexample.git", | ||
| 50 | tag = "v0.2" | ||
| 51 | } | ||
| 52 | description = { | ||
| 53 | summary = "xxx", | ||
| 54 | detailed = "xxx" | ||
| 55 | } | ||
| 56 | build = { | ||
| 57 | type = "builtin", | ||
| 58 | modules = { | ||
| 59 | foo = "src/foo.lua" | ||
| 60 | } | ||
| 61 | } | ||
| 62 | -------------------------------------------------------------------------------- | ||
| 63 | |||
| 64 | |||
| 65 | |||
| 66 | ================================================================================ | ||
| 67 | TEST: updates via tag | ||
| 68 | |||
| 69 | FILE: myexample-0.1-1.rockspec | ||
| 70 | -------------------------------------------------------------------------------- | ||
| 71 | package = "myexample" | ||
| 72 | version = "0.1-1" | ||
| 73 | source = { | ||
| 74 | url = "git+https://localhost/myexample.git", | ||
| 75 | tag = "v0.1" | ||
| 76 | } | ||
| 77 | description = { | ||
| 78 | summary = "xxx", | ||
| 79 | detailed = "xxx" | ||
| 80 | } | ||
| 81 | build = { | ||
| 82 | type = "builtin", | ||
| 83 | modules = { | ||
| 84 | foo = "src/foo.lua" | ||
| 85 | } | ||
| 86 | } | ||
| 87 | -------------------------------------------------------------------------------- | ||
| 88 | |||
| 89 | RUN: luarocks new_version myexample-0.1-1.rockspec --tag v0.2 | ||
| 90 | |||
| 91 | FILE_CONTENTS: myexample-0.2-1.rockspec | ||
| 92 | -------------------------------------------------------------------------------- | ||
| 93 | package = "myexample" | ||
| 94 | version = "0.2-1" | ||
| 95 | source = { | ||
| 96 | url = "git+https://localhost/myexample.git", | ||
| 97 | tag = "v0.2" | ||
| 98 | } | ||
| 99 | description = { | ||
| 100 | summary = "xxx", | ||
| 101 | detailed = "xxx" | ||
| 102 | } | ||
| 103 | build = { | ||
| 104 | type = "builtin", | ||
| 105 | modules = { | ||
| 106 | foo = "src/foo.lua" | ||
| 107 | } | ||
| 108 | } | ||
| 109 | -------------------------------------------------------------------------------- | ||
| 110 | |||
| 111 | |||
| 112 | |||
| 113 | ================================================================================ | ||
| 114 | TEST: updates URL | ||
| 115 | |||
| 116 | FILE: myexample-0.1-1.rockspec | ||
| 117 | -------------------------------------------------------------------------------- | ||
| 118 | package = "myexample" | ||
| 119 | version = "0.1-1" | ||
| 120 | source = { | ||
| 121 | url = "https://localhost/myexample-0.1.tar.gz", | ||
| 122 | } | ||
| 123 | description = { | ||
| 124 | summary = "xxx", | ||
| 125 | detailed = "xxx" | ||
| 126 | } | ||
| 127 | build = { | ||
| 128 | type = "builtin", | ||
| 129 | modules = { | ||
| 130 | foo = "src/foo.lua" | ||
| 131 | } | ||
| 132 | } | ||
| 133 | -------------------------------------------------------------------------------- | ||
| 134 | |||
| 135 | RUN: luarocks new_version myexample-0.1-1.rockspec 0.2 https://localhost/newpath/myexample-0.2.tar.gz | ||
| 136 | |||
| 137 | FILE_CONTENTS: myexample-0.2-1.rockspec | ||
| 138 | -------------------------------------------------------------------------------- | ||
| 139 | package = "myexample" | ||
| 140 | version = "0.2-1" | ||
| 141 | source = { | ||
| 142 | url = "https://localhost/newpath/myexample-0.2.tar.gz" | ||
| 143 | } | ||
| 144 | description = { | ||
| 145 | summary = "xxx", | ||
| 146 | detailed = "xxx" | ||
| 147 | } | ||
| 148 | build = { | ||
| 149 | type = "builtin", | ||
| 150 | modules = { | ||
| 151 | foo = "src/foo.lua" | ||
| 152 | } | ||
| 153 | } | ||
| 154 | -------------------------------------------------------------------------------- | ||
| 155 | |||
| 156 | |||
| 157 | |||
| 158 | ================================================================================ | ||
| 159 | TEST: updates MD5 | ||
| 160 | |||
| 161 | FILE: test-1.0-1.rockspec | ||
| 162 | -------------------------------------------------------------------------------- | ||
| 163 | package = "test" | ||
| 164 | version = "1.0-1" | ||
| 165 | source = { | ||
| 166 | url = "file://%{url(%{fixtures_dir})}/an_upstream_tarball-0.1.tar.gz", | ||
| 167 | md5 = "dca2ac30ce6c27cbd8dac4dd8f447630", | ||
| 168 | } | ||
| 169 | build = { | ||
| 170 | type = "builtin", | ||
| 171 | modules = { | ||
| 172 | my_module = "src/my_module.lua" | ||
| 173 | }, | ||
| 174 | install = { | ||
| 175 | bin = { | ||
| 176 | "src/my_module.lua" | ||
| 177 | } | ||
| 178 | } | ||
| 179 | } | ||
| 180 | -------------------------------------------------------------------------------- | ||
| 181 | |||
| 182 | RUN: luarocks new_version test-1.0-1.rockspec 2.0 file://%{url(%{fixtures_dir})}/busted_project-0.1.tar.gz | ||
| 183 | |||
| 184 | FILE_CONTENTS: test-2.0-1.rockspec | ||
| 185 | -------------------------------------------------------------------------------- | ||
| 186 | package = "test" | ||
| 187 | version = "2.0-1" | ||
| 188 | source = { | ||
| 189 | url = "file://%{url(%{fixtures_dir})}/busted_project-0.1.tar.gz", | ||
| 190 | md5 = "adfdfb8f1caa2b1f935a578fb07536eb", | ||
| 191 | } | ||
| 192 | build = { | ||
| 193 | type = "builtin", | ||
| 194 | modules = { | ||
| 195 | my_module = "src/my_module.lua" | ||
| 196 | }, | ||
| 197 | install = { | ||
| 198 | bin = { | ||
| 199 | "src/my_module.lua" | ||
| 200 | } | ||
| 201 | } | ||
| 202 | } | ||
| 203 | -------------------------------------------------------------------------------- | ||
| 204 | |||
| 205 | |||
| 206 | |||
| 207 | ================================================================================ | ||
| 208 | TEST: takes a URL, downloads and bumps revision by default | ||
| 209 | |||
| 210 | RUN: luarocks new_version file://%{url(%{fixtures_dir})}/a_rock-1.0-1.rockspec | ||
| 211 | |||
| 212 | EXISTS: a_rock-1.0-1.rockspec | ||
| 213 | EXISTS: a_rock-1.0-2.rockspec | ||
