diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-04-05 15:50:45 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-04-11 14:38:06 -0300 |
| commit | 835d21e98e95e0ed2b6b028ddb06fe87427e5488 (patch) | |
| tree | 1873e77e938a013b60ef106e1fa063f41ce159c2 /spec | |
| parent | 660f088cf936dcaa65a1c7eb2793df78777ad924 (diff) | |
| download | luarocks-835d21e98e95e0ed2b6b028ddb06fe87427e5488.tar.gz luarocks-835d21e98e95e0ed2b6b028ddb06fe87427e5488.tar.bz2 luarocks-835d21e98e95e0ed2b6b028ddb06fe87427e5488.zip | |
Add support for namespaces.
For details of the new feature, see
https://github.com/luarocks/luarocks/wiki/Namespaces
This ended up being a huge commit because of some major refactoring
motivated by the new feature:
* new modules for some object types:
* `luarocks.queries` - all functions that look for rocks in local or
remote repositories now use objects constructed by this module:
query objects contain the name, namespace and query constraints.
Dependencies in a rockspec are also stored as query objects.
* `luarocks.results` - all individual results produces from queries
are returned in this format: result objects contain the name,
namespace, version, arch and repo.
* the `results` object was renamed to `result_tree`, to better
reflect that it is not an array of `result` objects.
* `luarocks.vers` was removed, its functionality was moved to better locations.
Specifically on namespaces:
* Commands that take a rock `name` can now take `namespace/name`
(and alternately `--flags=namespace` so that URLs can be
also installed with a nominal namespace).
* Rocks installed from a namespace now create a `rock_namespace`
file alongside `rock_manifest`, which is used when matching
namespaced dependencies against locally-installed rocks.
* Using namespaced dependencies in a rockspec, requires
`rockspec_format = "3.0"`.
* Tests under the `#namespaces` hashtag, all using a local repository.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/build_spec.lua | 35 | ||||
| -rw-r--r-- | spec/doc_spec.lua | 8 | ||||
| -rw-r--r-- | spec/download_spec.lua | 21 | ||||
| -rw-r--r-- | spec/fetch_spec.lua | 7 | ||||
| -rw-r--r-- | spec/fixtures/a_repo/manifest | 20 | ||||
| -rw-r--r-- | spec/fixtures/a_repo/manifest-5.1 | 20 | ||||
| -rw-r--r-- | spec/fixtures/a_repo/manifest-5.2 | 20 | ||||
| -rw-r--r-- | spec/fixtures/a_repo/manifest-5.3 | 20 | ||||
| -rw-r--r-- | spec/install_spec.lua | 31 | ||||
| -rw-r--r-- | spec/list_spec.lua | 4 | ||||
| -rw-r--r-- | spec/pack_spec.lua | 76 | ||||
| -rw-r--r-- | spec/show_spec.lua | 2 | ||||
| -rw-r--r-- | spec/util/mock-server.lua | 3 | ||||
| -rw-r--r-- | spec/util/test_env.lua | 2 | ||||
| -rw-r--r-- | spec/write_rockspec_spec.lua | 10 |
15 files changed, 242 insertions, 37 deletions
diff --git a/spec/build_spec.lua b/spec/build_spec.lua index 2de05879..ed36dbd2 100644 --- a/spec/build_spec.lua +++ b/spec/build_spec.lua | |||
| @@ -62,6 +62,7 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
| 62 | end) | 62 | end) |
| 63 | 63 | ||
| 64 | it("LuaRocks build lpeg branch=master", function() | 64 | it("LuaRocks build lpeg branch=master", function() |
| 65 | -- FIXME should use dev package | ||
| 65 | assert.is_true(run.luarocks_bool("build --branch=master lpeg")) | 66 | assert.is_true(run.luarocks_bool("build --branch=master lpeg")) |
| 66 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) | 67 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_rocks .. "/lpeg/1.0.0-1/lpeg-1.0.0-1.rockspec")) |
| 67 | end) | 68 | end) |
| @@ -137,6 +138,40 @@ describe("LuaRocks build tests #blackbox #b_build", function() | |||
| 137 | end) | 138 | end) |
| 138 | end) | 139 | end) |
| 139 | 140 | ||
| 141 | describe("#namespaces", function() | ||
| 142 | it("builds a namespaced package from the command-line", function() | ||
| 143 | assert(run.luarocks_bool("build a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 144 | assert.is_false(run.luarocks_bool("show a_rock 1.0")) | ||
| 145 | assert(run.luarocks_bool("show a_rock 2.0")) | ||
| 146 | assert(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/2.0-1/rock_namespace")) | ||
| 147 | end) | ||
| 148 | |||
| 149 | it("builds a package with a namespaced dependency", function() | ||
| 150 | assert(run.luarocks_bool("build has_namespaced_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 151 | assert(run.luarocks_bool("show has_namespaced_dep")) | ||
| 152 | assert.is_false(run.luarocks_bool("show a_rock 1.0")) | ||
| 153 | assert(run.luarocks_bool("show a_rock 2.0")) | ||
| 154 | end) | ||
| 155 | |||
| 156 | it("builds a package reusing a namespaced dependency", function() | ||
| 157 | assert(run.luarocks_bool("build a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 158 | assert(run.luarocks_bool("show a_rock 2.0")) | ||
| 159 | assert(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/2.0-1/rock_namespace")) | ||
| 160 | local output = run.luarocks("build has_namespaced_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ) | ||
| 161 | assert.has.no.match("Missing dependencies", output) | ||
| 162 | end) | ||
| 163 | |||
| 164 | it("builds a package considering namespace of locally installed package", function() | ||
| 165 | assert(run.luarocks_bool("build a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 166 | assert(run.luarocks_bool("show a_rock 2.0")) | ||
| 167 | assert(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/2.0-1/rock_namespace")) | ||
| 168 | local output = run.luarocks("build has_another_namespaced_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ) | ||
| 169 | assert.has.match("Missing dependencies", output) | ||
| 170 | print(output) | ||
| 171 | assert(run.luarocks_bool("show a_rock 3.0")) | ||
| 172 | end) | ||
| 173 | end) | ||
| 174 | |||
| 140 | describe("LuaRocks build - more complex tests", function() | 175 | describe("LuaRocks build - more complex tests", function() |
| 141 | if test_env.TYPE_TEST_ENV == "full" then | 176 | if test_env.TYPE_TEST_ENV == "full" then |
| 142 | it("LuaRocks build luacheck show downloads test_config", function() | 177 | it("LuaRocks build luacheck show downloads test_config", function() |
diff --git a/spec/doc_spec.lua b/spec/doc_spec.lua index 5f503af2..6d91fc00 100644 --- a/spec/doc_spec.lua +++ b/spec/doc_spec.lua | |||
| @@ -38,6 +38,14 @@ describe("LuaRocks doc tests #blackbox #b_doc", function() | |||
| 38 | assert.is.truthy(output:find("Local documentation directory not found")) | 38 | assert.is.truthy(output:find("Local documentation directory not found")) |
| 39 | end) | 39 | end) |
| 40 | end) | 40 | end) |
| 41 | |||
| 42 | describe("#namespaces", function() | ||
| 43 | it("retrieves docs for a namespaced package from the command-line", function() | ||
| 44 | assert(run.luarocks_bool("build a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 45 | assert(run.luarocks_bool("build a_rock --keep --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 46 | assert.match("a_rock 2.0", run.luarocks("doc a_user/a_rock")) | ||
| 47 | end) | ||
| 48 | end) | ||
| 41 | 49 | ||
| 42 | describe("LuaRocks doc tests with flags", function() | 50 | describe("LuaRocks doc tests with flags", function() |
| 43 | it("LuaRocks doc of installed luarepl", function() | 51 | it("LuaRocks doc of installed luarepl", function() |
diff --git a/spec/download_spec.lua b/spec/download_spec.lua index 64443922..152470a5 100644 --- a/spec/download_spec.lua +++ b/spec/download_spec.lua | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | local test_env = require("spec.util.test_env") | 1 | local test_env = require("spec.util.test_env") |
| 2 | local lfs = require("lfs") | 2 | local lfs = require("lfs") |
| 3 | local run = test_env.run | 3 | local run = test_env.run |
| 4 | local testing_paths = test_env.testing_paths | ||
| 4 | 5 | ||
| 5 | test_env.unload_luarocks() | 6 | test_env.unload_luarocks() |
| 6 | 7 | ||
| @@ -33,4 +34,24 @@ describe("LuaRocks download tests #blackbox #b_download", function() | |||
| 33 | assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec")) | 34 | assert.is.truthy(lfs.attributes("validate-args-1.5.4-1.rockspec")) |
| 34 | test_env.remove_files(lfs.currentdir(), "validate--args--") | 35 | test_env.remove_files(lfs.currentdir(), "validate--args--") |
| 35 | end) | 36 | end) |
| 37 | |||
| 38 | describe("#namespaces", function() | ||
| 39 | it("retrieves namespaced rockspec", function() | ||
| 40 | finally(function() | ||
| 41 | os.remove("a_rock-2.0-1.rockspec") | ||
| 42 | end) | ||
| 43 | assert(run.luarocks_bool("download a_user/a_rock --rockspec --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 44 | assert(lfs.attributes("a_rock-2.0-1.rockspec")) | ||
| 45 | end) | ||
| 46 | |||
| 47 | it("retrieves namespaced rock", function() | ||
| 48 | finally(function() | ||
| 49 | os.remove("a_rock-2.0-1.src.rock") | ||
| 50 | end) | ||
| 51 | assert(run.luarocks_bool("download a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 52 | assert(lfs.attributes("a_rock-2.0-1.src.rock")) | ||
| 53 | end) | ||
| 54 | end) | ||
| 55 | |||
| 56 | |||
| 36 | end) | 57 | end) |
diff --git a/spec/fetch_spec.lua b/spec/fetch_spec.lua index 5f518e4d..79b160c1 100644 --- a/spec/fetch_spec.lua +++ b/spec/fetch_spec.lua | |||
| @@ -3,7 +3,6 @@ local git_repo = require("spec.util.git_repo") | |||
| 3 | 3 | ||
| 4 | test_env.unload_luarocks() | 4 | test_env.unload_luarocks() |
| 5 | local fetch = require("luarocks.fetch") | 5 | local fetch = require("luarocks.fetch") |
| 6 | local vers = require("luarocks.vers") | ||
| 7 | 6 | ||
| 8 | describe("Luarocks fetch test #whitebox #w_fetch", function() | 7 | describe("Luarocks fetch test #whitebox #w_fetch", function() |
| 9 | it("Fetch url to base dir", function() | 8 | it("Fetch url to base dir", function() |
| @@ -30,12 +29,14 @@ describe("Luarocks fetch test #whitebox #w_fetch", function() | |||
| 30 | 29 | ||
| 31 | it("from #git", function() | 30 | it("from #git", function() |
| 32 | local rockspec = { | 31 | local rockspec = { |
| 33 | format_is_at_least = vers.format_is_at_least, | 32 | format_is_at_least = function() |
| 33 | return true | ||
| 34 | end, | ||
| 34 | name = "testrock", | 35 | name = "testrock", |
| 35 | version = "dev-1", | 36 | version = "dev-1", |
| 36 | source = { | 37 | source = { |
| 37 | protocol = "git", | 38 | protocol = "git", |
| 38 | url = "git://localhost:20000/testrock", | 39 | url = "git://localhost/testrock", |
| 39 | }, | 40 | }, |
| 40 | variables = { | 41 | variables = { |
| 41 | GIT = "git", | 42 | GIT = "git", |
diff --git a/spec/fixtures/a_repo/manifest b/spec/fixtures/a_repo/manifest index ea198207..141dafb5 100644 --- a/spec/fixtures/a_repo/manifest +++ b/spec/fixtures/a_repo/manifest | |||
| @@ -10,5 +10,25 @@ repository = { | |||
| 10 | arch = "rockspec" | 10 | arch = "rockspec" |
| 11 | } | 11 | } |
| 12 | } | 12 | } |
| 13 | }, | ||
| 14 | has_another_namespaced_dep = { | ||
| 15 | ["1.0-1"] = { | ||
| 16 | { | ||
| 17 | arch = "rockspec" | ||
| 18 | }, | ||
| 19 | { | ||
| 20 | arch = "src" | ||
| 21 | } | ||
| 22 | } | ||
| 23 | }, | ||
| 24 | has_namespaced_dep = { | ||
| 25 | ["1.0-1"] = { | ||
| 26 | { | ||
| 27 | arch = "rockspec" | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | arch = "src" | ||
| 31 | } | ||
| 32 | } | ||
| 13 | } | 33 | } |
| 14 | } | 34 | } |
diff --git a/spec/fixtures/a_repo/manifest-5.1 b/spec/fixtures/a_repo/manifest-5.1 index ea198207..141dafb5 100644 --- a/spec/fixtures/a_repo/manifest-5.1 +++ b/spec/fixtures/a_repo/manifest-5.1 | |||
| @@ -10,5 +10,25 @@ repository = { | |||
| 10 | arch = "rockspec" | 10 | arch = "rockspec" |
| 11 | } | 11 | } |
| 12 | } | 12 | } |
| 13 | }, | ||
| 14 | has_another_namespaced_dep = { | ||
| 15 | ["1.0-1"] = { | ||
| 16 | { | ||
| 17 | arch = "rockspec" | ||
| 18 | }, | ||
| 19 | { | ||
| 20 | arch = "src" | ||
| 21 | } | ||
| 22 | } | ||
| 23 | }, | ||
| 24 | has_namespaced_dep = { | ||
| 25 | ["1.0-1"] = { | ||
| 26 | { | ||
| 27 | arch = "rockspec" | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | arch = "src" | ||
| 31 | } | ||
| 32 | } | ||
| 13 | } | 33 | } |
| 14 | } | 34 | } |
diff --git a/spec/fixtures/a_repo/manifest-5.2 b/spec/fixtures/a_repo/manifest-5.2 index ea198207..141dafb5 100644 --- a/spec/fixtures/a_repo/manifest-5.2 +++ b/spec/fixtures/a_repo/manifest-5.2 | |||
| @@ -10,5 +10,25 @@ repository = { | |||
| 10 | arch = "rockspec" | 10 | arch = "rockspec" |
| 11 | } | 11 | } |
| 12 | } | 12 | } |
| 13 | }, | ||
| 14 | has_another_namespaced_dep = { | ||
| 15 | ["1.0-1"] = { | ||
| 16 | { | ||
| 17 | arch = "rockspec" | ||
| 18 | }, | ||
| 19 | { | ||
| 20 | arch = "src" | ||
| 21 | } | ||
| 22 | } | ||
| 23 | }, | ||
| 24 | has_namespaced_dep = { | ||
| 25 | ["1.0-1"] = { | ||
| 26 | { | ||
| 27 | arch = "rockspec" | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | arch = "src" | ||
| 31 | } | ||
| 32 | } | ||
| 13 | } | 33 | } |
| 14 | } | 34 | } |
diff --git a/spec/fixtures/a_repo/manifest-5.3 b/spec/fixtures/a_repo/manifest-5.3 index ea198207..141dafb5 100644 --- a/spec/fixtures/a_repo/manifest-5.3 +++ b/spec/fixtures/a_repo/manifest-5.3 | |||
| @@ -10,5 +10,25 @@ repository = { | |||
| 10 | arch = "rockspec" | 10 | arch = "rockspec" |
| 11 | } | 11 | } |
| 12 | } | 12 | } |
| 13 | }, | ||
| 14 | has_another_namespaced_dep = { | ||
| 15 | ["1.0-1"] = { | ||
| 16 | { | ||
| 17 | arch = "rockspec" | ||
| 18 | }, | ||
| 19 | { | ||
| 20 | arch = "src" | ||
| 21 | } | ||
| 22 | } | ||
| 23 | }, | ||
| 24 | has_namespaced_dep = { | ||
| 25 | ["1.0-1"] = { | ||
| 26 | { | ||
| 27 | arch = "rockspec" | ||
| 28 | }, | ||
| 29 | { | ||
| 30 | arch = "src" | ||
| 31 | } | ||
| 32 | } | ||
| 13 | } | 33 | } |
| 14 | } | 34 | } |
diff --git a/spec/install_spec.lua b/spec/install_spec.lua index 53c8f0d0..4043af35 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua | |||
| @@ -77,11 +77,38 @@ describe("luarocks install #blackbox #b_install", function() | |||
| 77 | end) | 77 | end) |
| 78 | end) | 78 | end) |
| 79 | 79 | ||
| 80 | describe("#only namespaced packages", function() | 80 | describe("#namespaces", function() |
| 81 | it("installs a namespaced package from the command-line", function() | 81 | it("installs a namespaced package from the command-line", function() |
| 82 | assert(run.luarocks_bool("install a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | 82 | assert(run.luarocks_bool("install a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) |
| 83 | assert.is_false(run.luarocks_bool("show a_rock 1.0")) | 83 | assert.is_false(run.luarocks_bool("show a_rock 1.0")) |
| 84 | assert(run.luarocks_bool("show a_rock 2.0")) | 84 | assert(run.luarocks_bool("show a_rock 2.0")) |
| 85 | assert(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/2.0-1/rock_namespace")) | ||
| 86 | end) | ||
| 87 | |||
| 88 | it("installs a package with a namespaced dependency", function() | ||
| 89 | assert(run.luarocks_bool("install has_namespaced_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 90 | assert(run.luarocks_bool("show has_namespaced_dep")) | ||
| 91 | assert.is_false(run.luarocks_bool("show a_rock 1.0")) | ||
| 92 | assert(run.luarocks_bool("show a_rock 2.0")) | ||
| 93 | assert(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/2.0-1/rock_namespace")) | ||
| 94 | end) | ||
| 95 | |||
| 96 | it("installs a package reusing a namespaced dependency", function() | ||
| 97 | assert(run.luarocks_bool("install a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 98 | assert(run.luarocks_bool("show a_rock 2.0")) | ||
| 99 | assert(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/2.0-1/rock_namespace")) | ||
| 100 | local output = run.luarocks("install has_namespaced_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ) | ||
| 101 | assert.has.no.match("Missing dependencies", output) | ||
| 102 | end) | ||
| 103 | |||
| 104 | it("installs a package considering namespace of locally installed package", function() | ||
| 105 | assert(run.luarocks_bool("install a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 106 | assert(run.luarocks_bool("show a_rock 2.0")) | ||
| 107 | assert(lfs.attributes(testing_paths.testing_sys_rocks .. "/a_rock/2.0-1/rock_namespace")) | ||
| 108 | local output = run.luarocks("install has_another_namespaced_dep --server=" .. testing_paths.fixtures_dir .. "/a_repo" ) | ||
| 109 | assert.has.match("Missing dependencies", output) | ||
| 110 | print(output) | ||
| 111 | assert(run.luarocks_bool("show a_rock 3.0")) | ||
| 85 | end) | 112 | end) |
| 86 | end) | 113 | end) |
| 87 | 114 | ||
| @@ -155,7 +182,7 @@ describe("luarocks install #blackbox #b_install", function() | |||
| 155 | it("only-deps of luasocket packed rock", function() | 182 | it("only-deps of luasocket packed rock", function() |
| 156 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) | 183 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) |
| 157 | local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock") | 184 | local output = run.luarocks("install --only-deps " .. "luasocket-3.0rc1-2." .. test_env.platform .. ".rock") |
| 158 | assert.are.same(output, "Successfully installed dependencies for luasocket 3.0rc1-2") | 185 | assert.are.same("Successfully installed dependencies for luasocket 3.0rc1-2", output:gsub("\n", "")) |
| 159 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) | 186 | assert.is_true(os.remove("luasocket-3.0rc1-2." .. test_env.platform .. ".rock")) |
| 160 | end) | 187 | end) |
| 161 | 188 | ||
diff --git a/spec/list_spec.lua b/spec/list_spec.lua index 07d60bf0..d6aeef38 100644 --- a/spec/list_spec.lua +++ b/spec/list_spec.lua | |||
| @@ -17,7 +17,7 @@ describe("LuaRocks list tests #blackbox #b_list", function() | |||
| 17 | 17 | ||
| 18 | it("LuaRocks list with no flags/arguments", function() | 18 | it("LuaRocks list with no flags/arguments", function() |
| 19 | local output = run.luarocks("list") | 19 | local output = run.luarocks("list") |
| 20 | assert.is.truthy(output:find("luacov")) | 20 | assert.match("luacov", output) |
| 21 | end) | 21 | end) |
| 22 | 22 | ||
| 23 | it("LuaRocks list porcelain", function() | 23 | it("LuaRocks list porcelain", function() |
| @@ -33,6 +33,6 @@ describe("LuaRocks list tests #blackbox #b_list", function() | |||
| 33 | 33 | ||
| 34 | it("LuaRocks list invalid tree", function() | 34 | it("LuaRocks list invalid tree", function() |
| 35 | local output = run.luarocks("--tree=/some/invalid/tree list") | 35 | local output = run.luarocks("--tree=/some/invalid/tree list") |
| 36 | assert(output:find("Installed rocks for Lua "..test_env.lua_version..":----------------", 1, true)) | 36 | assert(output:find("Installed rocks for Lua "..test_env.lua_version, 1, true)) |
| 37 | end) | 37 | end) |
| 38 | end) | 38 | end) |
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index 86b4e2b2..54d139e0 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua | |||
| @@ -5,57 +5,89 @@ local testing_paths = test_env.testing_paths | |||
| 5 | 5 | ||
| 6 | test_env.unload_luarocks() | 6 | test_env.unload_luarocks() |
| 7 | 7 | ||
| 8 | local extra_rocks = { | 8 | local extra_rocks = test_env.mock_server_extra_rocks({ |
| 9 | "/luasec-0.6-1.rockspec", | 9 | "/luasec-0.6-1.rockspec", |
| 10 | "/luassert-1.7.0-1.src.rock", | 10 | "/luassert-1.7.0-1.src.rock", |
| 11 | "/luasocket-3.0rc1-2.src.rock", | 11 | "/luasocket-3.0rc1-2.src.rock", |
| 12 | "/luasocket-3.0rc1-2.rockspec", | 12 | "/luasocket-3.0rc1-2.rockspec", |
| 13 | "/say-1.2-1.src.rock", | 13 | "/say-1.2-1.src.rock", |
| 14 | "/say-1.0-1.src.rock" | 14 | "/say-1.0-1.src.rock" |
| 15 | } | 15 | }) |
| 16 | 16 | ||
| 17 | describe("LuaRocks pack tests #blackbox #b_pack", function() | 17 | describe("LuaRocks pack #blackbox #b_pack", function() |
| 18 | 18 | ||
| 19 | before_each(function() | 19 | before_each(function() |
| 20 | test_env.setup_specs(extra_rocks) | 20 | test_env.setup_specs(extra_rocks) |
| 21 | end) | 21 | end) |
| 22 | 22 | ||
| 23 | it("LuaRocks pack with no flags/arguments", function() | 23 | it("with no flags/arguments", function() |
| 24 | assert.is_false(run.luarocks_bool("pack")) | 24 | assert.is_false(run.luarocks_bool("pack")) |
| 25 | end) | 25 | end) |
| 26 | 26 | ||
| 27 | it("LuaRocks pack basic", function() | 27 | it("basic", function() |
| 28 | assert.is_true(run.luarocks_bool("pack luacov")) | 28 | assert(run.luarocks_bool("pack luacov")) |
| 29 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luacov%-")) | 29 | assert(test_env.remove_files(lfs.currentdir(), "luacov%-")) |
| 30 | end) | 30 | end) |
| 31 | 31 | ||
| 32 | it("LuaRocks pack invalid rockspec", function() | 32 | it("invalid rockspec", function() |
| 33 | assert.is_false(run.luarocks_bool("pack " .. testing_paths.fixtures_dir .. "/invaild_validate-args-1.5.4-1.rockspec")) | 33 | assert.is_false(run.luarocks_bool("pack " .. testing_paths.fixtures_dir .. "/invalid_validate-args-1.5.4-1.rockspec")) |
| 34 | end) | 34 | end) |
| 35 | 35 | ||
| 36 | it("LuaRocks pack not installed rock", function() | 36 | it("not installed rock", function() |
| 37 | assert.is_false(run.luarocks_bool("pack cjson")) | 37 | assert.is_false(run.luarocks_bool("pack cjson")) |
| 38 | end) | 38 | end) |
| 39 | 39 | ||
| 40 | it("LuaRocks pack not installed rock from non existing manifest", function() | 40 | it("not installed rock from non existing manifest", function() |
| 41 | assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif")) | 41 | assert.is_false(run.luarocks_bool("pack /non/exist/temp.manif")) |
| 42 | end) | 42 | end) |
| 43 | 43 | ||
| 44 | it("LuaRocks pack detects latest version version of rock", function() | 44 | it("detects latest version version of rock", function() |
| 45 | assert.is_true(run.luarocks_bool("install say 1.2")) | 45 | assert(run.luarocks_bool("install say 1.2")) |
| 46 | assert.is_true(run.luarocks_bool("install luassert")) | 46 | assert(run.luarocks_bool("install luassert")) |
| 47 | assert.is_true(run.luarocks_bool("install say 1.0")) | 47 | assert(run.luarocks_bool("install say 1.0")) |
| 48 | assert.is_true(run.luarocks_bool("pack say")) | 48 | assert(run.luarocks_bool("pack say")) |
| 49 | assert.is_truthy(lfs.attributes("say-1.2-1.all.rock")) | 49 | assert.is_truthy(lfs.attributes("say-1.2-1.all.rock")) |
| 50 | assert.is_true(test_env.remove_files(lfs.currentdir(), "say%-")) | 50 | assert(test_env.remove_files(lfs.currentdir(), "say%-")) |
| 51 | end) | 51 | end) |
| 52 | 52 | ||
| 53 | it("LuaRocks pack src", function() | 53 | it("src", function() |
| 54 | assert.is_true(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) | 54 | assert(run.luarocks_bool("install luasec " .. test_env.OPENSSL_DIRS)) |
| 55 | assert.is_true(run.luarocks_bool("download --rockspec luasocket 3.0rc1-2")) | 55 | assert(run.luarocks_bool("download --rockspec luasocket 3.0rc1-2")) |
| 56 | assert.is_true(run.luarocks_bool("pack luasocket-3.0rc1-2.rockspec")) | 56 | assert(run.luarocks_bool("pack luasocket-3.0rc1-2.rockspec")) |
| 57 | assert.is_true(test_env.remove_files(lfs.currentdir(), "luasocket%-")) | 57 | assert(test_env.remove_files(lfs.currentdir(), "luasocket%-")) |
| 58 | end) | 58 | end) |
| 59 | |||
| 60 | describe("#mock namespaced dependencies", function() | ||
| 61 | |||
| 62 | setup(function() | ||
| 63 | test_env.mock_server_init() | ||
| 64 | end) | ||
| 65 | |||
| 66 | teardown(function() | ||
| 67 | test_env.mock_server_done() | ||
| 68 | end) | ||
| 69 | |||
| 70 | it("can pack rockspec with namespaced dependencies", function() | ||
| 71 | finally(function() | ||
| 72 | os.remove("has_namespaced_dep-1.0-1.src.rock") | ||
| 73 | end) | ||
| 74 | assert(run.luarocks_bool("pack " .. testing_paths.fixtures_dir .. "/a_repo/has_namespaced_dep-1.0-1.rockspec")) | ||
| 75 | assert.is_truthy(lfs.attributes("has_namespaced_dep-1.0-1.src.rock")) | ||
| 76 | end) | ||
| 77 | end) | ||
| 78 | |||
| 79 | describe("#namespaces", function() | ||
| 80 | it("packs a namespaced rock", function() | ||
| 81 | finally(function() | ||
| 82 | os.remove("a_rock-2.0-1.all.rock") | ||
| 83 | end) | ||
| 84 | assert(run.luarocks_bool("build a_user/a_rock --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 85 | assert(run.luarocks_bool("build a_rock --keep --server=" .. testing_paths.fixtures_dir .. "/a_repo" )) | ||
| 86 | assert(run.luarocks_bool("pack a_user/a_rock" )) | ||
| 87 | assert(lfs.attributes("a_rock-2.0-1.all.rock")) | ||
| 88 | end) | ||
| 89 | end) | ||
| 90 | |||
| 59 | end) | 91 | end) |
| 60 | 92 | ||
| 61 | 93 | ||
diff --git a/spec/show_spec.lua b/spec/show_spec.lua index d572be9b..234a8a33 100644 --- a/spec/show_spec.lua +++ b/spec/show_spec.lua | |||
| @@ -30,7 +30,7 @@ describe("LuaRocks show tests #blackbox #b_show", function() | |||
| 30 | 30 | ||
| 31 | it("LuaRocks show modules of luacov", function() | 31 | it("LuaRocks show modules of luacov", function() |
| 32 | local output = run.luarocks("show --modules luacov") | 32 | local output = run.luarocks("show --modules luacov") |
| 33 | assert.is.truthy(output:match("luacovluacov.defaultsluacov.reporterluacov.reporter.defaultluacov.runnerluacov.statsluacov.tick")) | 33 | assert.match("luacov.*luacov.defaults.*luacov.reporter.*luacov.reporter.default.*luacov.runner.*luacov.stats.*luacov.tick", output) |
| 34 | end) | 34 | end) |
| 35 | 35 | ||
| 36 | it("LuaRocks show dependencies of luacov", function() | 36 | it("LuaRocks show dependencies of luacov", function() |
diff --git a/spec/util/mock-server.lua b/spec/util/mock-server.lua index 77d32927..30586c98 100644 --- a/spec/util/mock-server.lua +++ b/spec/util/mock-server.lua | |||
| @@ -70,7 +70,8 @@ server:add_resource("/file/{name:[^/]+}", { | |||
| 70 | path = "/", | 70 | path = "/", |
| 71 | produces = "text/plain", | 71 | produces = "text/plain", |
| 72 | handler = function(query, name) | 72 | handler = function(query, name) |
| 73 | local fd = io.open("../spec/fixtures/"..name, "r") | 73 | local basedir = arg[1] or "../spec/fixtures" |
| 74 | local fd = io.open(basedir .. "/" .. name, "r") | ||
| 74 | if not fd then | 75 | if not fd then |
| 75 | return restserver.response():status(404) | 76 | return restserver.response():status(404) |
| 76 | end | 77 | end |
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua index 23ca5c77..94008913 100644 --- a/spec/util/test_env.lua +++ b/spec/util/test_env.lua | |||
| @@ -175,7 +175,7 @@ local function execute_output(command, print_command, env_variables) | |||
| 175 | local file = assert(io.popen(command)) | 175 | local file = assert(io.popen(command)) |
| 176 | local output = file:read('*all') | 176 | local output = file:read('*all') |
| 177 | file:close() | 177 | file:close() |
| 178 | return output:gsub("\n","") -- output adding new line, need to be removed | 178 | return (output:gsub("\r\n", "\n"):gsub("\n$", "")) -- remove final newline |
| 179 | end | 179 | end |
| 180 | 180 | ||
| 181 | --- Set test_env.LUA_V or test_env.LUAJIT_V based | 181 | --- Set test_env.LUA_V or test_env.LUAJIT_V based |
diff --git a/spec/write_rockspec_spec.lua b/spec/write_rockspec_spec.lua index e4a7fa73..0a0988d0 100644 --- a/spec/write_rockspec_spec.lua +++ b/spec/write_rockspec_spec.lua | |||
| @@ -42,27 +42,27 @@ describe("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() | |||
| 42 | 42 | ||
| 43 | it("runs", function() | 43 | it("runs", function() |
| 44 | finally(function() os.remove("testrock-dev-1.rockspec") end) | 44 | finally(function() os.remove("testrock-dev-1.rockspec") end) |
| 45 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost:20000/testrock")) | 45 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock")) |
| 46 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) | 46 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) |
| 47 | end) | 47 | end) |
| 48 | 48 | ||
| 49 | it("runs with --tag", function() | 49 | it("runs with --tag", function() |
| 50 | finally(function() os.remove("testrock-2.3.0-1.rockspec") end) | 50 | finally(function() os.remove("testrock-2.3.0-1.rockspec") end) |
| 51 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost:20000/testrock --tag=v2.3.0")) | 51 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --tag=v2.3.0")) |
| 52 | assert.is.truthy(lfs.attributes("testrock-2.3.0-1.rockspec")) | 52 | assert.is.truthy(lfs.attributes("testrock-2.3.0-1.rockspec")) |
| 53 | -- TODO check contents | 53 | -- TODO check contents |
| 54 | end) | 54 | end) |
| 55 | 55 | ||
| 56 | it("runs with format flag", function() | 56 | it("runs with format flag", function() |
| 57 | finally(function() os.remove("testrock-dev-1.rockspec") end) | 57 | finally(function() os.remove("testrock-dev-1.rockspec") end) |
| 58 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost:20000/testrock --rockspec-format=1.1 --lua-version=5.1,5.2")) | 58 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --rockspec-format=1.1 --lua-version=5.1,5.2")) |
| 59 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) | 59 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) |
| 60 | -- TODO check contents | 60 | -- TODO check contents |
| 61 | end) | 61 | end) |
| 62 | 62 | ||
| 63 | it("runs with full flags", function() | 63 | it("runs with full flags", function() |
| 64 | finally(function() os.remove("testrock-dev-1.rockspec") end) | 64 | finally(function() os.remove("testrock-dev-1.rockspec") end) |
| 65 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost:20000/testrock --lua-version=5.1,5.2 --license=\"MIT/X11\" " | 65 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --lua-version=5.1,5.2 --license=\"MIT/X11\" " |
| 66 | .. " --homepage=\"http://www.luarocks.org\" --summary=\"A package manager for Lua modules\" ")) | 66 | .. " --homepage=\"http://www.luarocks.org\" --summary=\"A package manager for Lua modules\" ")) |
| 67 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) | 67 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) |
| 68 | -- TODO check contents | 68 | -- TODO check contents |
| @@ -70,7 +70,7 @@ describe("LuaRocks write_rockspec tests #blackbox #b_write_rockspec", function() | |||
| 70 | 70 | ||
| 71 | it("with various flags", function() | 71 | it("with various flags", function() |
| 72 | finally(function() os.remove("testrock-dev-1.rockspec") end) | 72 | finally(function() os.remove("testrock-dev-1.rockspec") end) |
| 73 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost:20000/testrock --lib=fcgi --license=\"3-clause BSD\" " .. "--lua-version=5.1,5.2")) | 73 | assert.is_true(run.luarocks_bool("write_rockspec git://localhost/testrock --lib=fcgi --license=\"3-clause BSD\" " .. "--lua-version=5.1,5.2")) |
| 74 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) | 74 | assert.is.truthy(lfs.attributes("testrock-dev-1.rockspec")) |
| 75 | -- TODO check contents | 75 | -- TODO check contents |
| 76 | end) | 76 | end) |
