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/install_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/install_spec.lua')
-rw-r--r-- | spec/install_spec.lua | 31 |
1 files changed, 29 insertions, 2 deletions
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 | ||