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/build_spec.lua | |
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/build_spec.lua')
-rw-r--r-- | spec/build_spec.lua | 35 |
1 files changed, 35 insertions, 0 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() |