diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2020-04-13 19:46:28 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2020-04-13 22:27:17 -0300 |
commit | 67ea6328e567fd224e7cd8ed23f55571928d7e1b (patch) | |
tree | c66d13e8fea685210f6051037bb760c0f5478297 /spec | |
parent | 312d7f495a1c187ce988d6e19a50c19328c11ed6 (diff) | |
download | luarocks-67ea6328e567fd224e7cd8ed23f55571928d7e1b.tar.gz luarocks-67ea6328e567fd224e7cd8ed23f55571928d7e1b.tar.bz2 luarocks-67ea6328e567fd224e7cd8ed23f55571928d7e1b.zip |
fix regression in dependency matching of luarocks.loader
Regression introduced in
https://github.com/luarocks/luarocks/commit/65c417e0ecda55f44c691df032163a8c08f0b52a
Thanks to @lhemkendreis for the detailed description and suggested
fix, which was applied here!
Added a regression test which exercises dependency matching.
Closes #1175.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/loader_spec.lua | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/spec/loader_spec.lua b/spec/loader_spec.lua index 0f946b72..35179080 100644 --- a/spec/loader_spec.lua +++ b/spec/loader_spec.lua | |||
@@ -1,5 +1,7 @@ | |||
1 | local test_env = require("spec.util.test_env") | 1 | local test_env = require("spec.util.test_env") |
2 | local run = test_env.run | 2 | local run = test_env.run |
3 | local testing_paths = test_env.testing_paths | ||
4 | local write_file = test_env.write_file | ||
3 | 5 | ||
4 | describe("luarocks.loader", function() | 6 | describe("luarocks.loader", function() |
5 | describe("#unit", function() | 7 | describe("#unit", function() |
@@ -7,4 +9,66 @@ describe("luarocks.loader", function() | |||
7 | assert(run.lua_bool([[-e "require 'luarocks.loader'; print(package.loaded['luarocks.loaded'])"]])) | 9 | assert(run.lua_bool([[-e "require 'luarocks.loader'; print(package.loaded['luarocks.loaded'])"]])) |
8 | end) | 10 | end) |
9 | end) | 11 | end) |
12 | |||
13 | describe("#integration", function() | ||
14 | it("respects version constraints", function() | ||
15 | test_env.run_in_tmp(function(tmpdir) | ||
16 | write_file("rock_b_01.lua", "print('ROCK B 0.1'); return {}", finally) | ||
17 | write_file("rock_b-0.1-1.rockspec", [[ | ||
18 | package = "rock_b" | ||
19 | version = "0.1-1" | ||
20 | source = { | ||
21 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/rock_b_01.lua" | ||
22 | } | ||
23 | build = { | ||
24 | type = "builtin", | ||
25 | modules = { | ||
26 | rock_b = "rock_b_01.lua" | ||
27 | } | ||
28 | } | ||
29 | ]], finally) | ||
30 | |||
31 | write_file("rock_b_10.lua", "print('ROCK B 1.0'); return {}", finally) | ||
32 | write_file("rock_b-1.0-1.rockspec", [[ | ||
33 | package = "rock_b" | ||
34 | version = "1.0-1" | ||
35 | source = { | ||
36 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/rock_b_10.lua" | ||
37 | } | ||
38 | build = { | ||
39 | type = "builtin", | ||
40 | modules = { | ||
41 | rock_b = "rock_b_10.lua" | ||
42 | } | ||
43 | } | ||
44 | ]], finally) | ||
45 | |||
46 | write_file("rock_a.lua", "require('rock_b'); return {}", finally) | ||
47 | write_file("rock_a-2.0-1.rockspec", [[ | ||
48 | package = "rock_a" | ||
49 | version = "2.0-1" | ||
50 | source = { | ||
51 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/rock_a.lua" | ||
52 | } | ||
53 | dependencies = { | ||
54 | "rock_b < 1.0", | ||
55 | } | ||
56 | build = { | ||
57 | type = "builtin", | ||
58 | modules = { | ||
59 | rock_a = "rock_a.lua" | ||
60 | } | ||
61 | } | ||
62 | ]], finally) | ||
63 | |||
64 | print(run.luarocks("make --server=" .. testing_paths.fixtures_dir .. "/a_repo --tree=" .. testing_paths.testing_tree .. " ./rock_b-0.1-1.rockspec")) | ||
65 | print(run.luarocks("make --server=" .. testing_paths.fixtures_dir .. "/a_repo --tree=" .. testing_paths.testing_tree .. " ./rock_b-1.0-1.rockspec --keep")) | ||
66 | print(run.luarocks("make --server=" .. testing_paths.fixtures_dir .. "/a_repo --tree=" .. testing_paths.testing_tree .. " ./rock_a-2.0-1.rockspec")) | ||
67 | |||
68 | local output = run.lua([[-e "require 'luarocks.loader'; require('rock_a')"]]) | ||
69 | |||
70 | assert.matches("ROCK B 0.1", output, 1, true) | ||
71 | end) | ||
72 | end) | ||
73 | end) | ||
10 | end) | 74 | end) |