aboutsummaryrefslogtreecommitdiff
path: root/spec/loader_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/loader_spec.lua')
-rw-r--r--spec/loader_spec.lua26
1 files changed, 7 insertions, 19 deletions
diff --git a/spec/loader_spec.lua b/spec/loader_spec.lua
index c8526117..bd95a292 100644
--- a/spec/loader_spec.lua
+++ b/spec/loader_spec.lua
@@ -9,22 +9,10 @@ describe("luarocks.loader", function()
9 test_env.setup_specs() 9 test_env.setup_specs()
10 end) 10 end)
11 11
12 describe("#unit", function()
13 it("starts", function()
14 assert(run.lua_bool([[-e "require 'luarocks.loader'; print(package.loaded['luarocks.loaded'])"]]))
15 end)
16
17 describe("which", function()
18 it("finds modules using package.path", function()
19 assert(run.lua_bool([[-e "loader = require 'luarocks.loader'; local x,y,z,p = loader.which('luarocks.loader', 'p'); assert(p == 'p')"]]))
20 end)
21 end)
22 end)
23
24 describe("#integration", function() 12 describe("#integration", function()
25 it("respects version constraints", function() 13 it("respects version constraints", function()
26 test_env.run_in_tmp(function(tmpdir) 14 test_env.run_in_tmp(function(tmpdir)
27 write_file("rock_b_01.lua", "print('ROCK B 0.1'); return {}", finally) 15 write_file("rock_b_01.lua", "print('ROCK B 0.1'); return {}")
28 write_file("rock_b-0.1-1.rockspec", [[ 16 write_file("rock_b-0.1-1.rockspec", [[
29 package = "rock_b" 17 package = "rock_b"
30 version = "0.1-1" 18 version = "0.1-1"
@@ -37,9 +25,9 @@ describe("luarocks.loader", function()
37 rock_b = "rock_b_01.lua" 25 rock_b = "rock_b_01.lua"
38 } 26 }
39 } 27 }
40 ]], finally) 28 ]])
41 29
42 write_file("rock_b_10.lua", "print('ROCK B 1.0'); return {}", finally) 30 write_file("rock_b_10.lua", "print('ROCK B 1.0'); return {}")
43 write_file("rock_b-1.0-1.rockspec", [[ 31 write_file("rock_b-1.0-1.rockspec", [[
44 package = "rock_b" 32 package = "rock_b"
45 version = "1.0-1" 33 version = "1.0-1"
@@ -52,9 +40,9 @@ describe("luarocks.loader", function()
52 rock_b = "rock_b_10.lua" 40 rock_b = "rock_b_10.lua"
53 } 41 }
54 } 42 }
55 ]], finally) 43 ]])
56 44
57 write_file("rock_a.lua", "require('rock_b'); return {}", finally) 45 write_file("rock_a.lua", "require('rock_b'); return {}")
58 write_file("rock_a-2.0-1.rockspec", [[ 46 write_file("rock_a-2.0-1.rockspec", [[
59 package = "rock_a" 47 package = "rock_a"
60 version = "2.0-1" 48 version = "2.0-1"
@@ -70,7 +58,7 @@ describe("luarocks.loader", function()
70 rock_a = "rock_a.lua" 58 rock_a = "rock_a.lua"
71 } 59 }
72 } 60 }
73 ]], finally) 61 ]])
74 62
75 print(run.luarocks("make --server=" .. testing_paths.fixtures_dir .. "/a_repo --tree=" .. testing_paths.testing_tree .. " ./rock_b-0.1-1.rockspec")) 63 print(run.luarocks("make --server=" .. testing_paths.fixtures_dir .. "/a_repo --tree=" .. testing_paths.testing_tree .. " ./rock_b-0.1-1.rockspec"))
76 print(run.luarocks("make --server=" .. testing_paths.fixtures_dir .. "/a_repo --tree=" .. testing_paths.testing_tree .. " ./rock_b-1.0-1.rockspec --keep")) 64 print(run.luarocks("make --server=" .. testing_paths.fixtures_dir .. "/a_repo --tree=" .. testing_paths.testing_tree .. " ./rock_b-1.0-1.rockspec --keep"))
@@ -79,7 +67,7 @@ describe("luarocks.loader", function()
79 local output = run.lua([[-e "require 'luarocks.loader'; require('rock_a')"]]) 67 local output = run.lua([[-e "require 'luarocks.loader'; require('rock_a')"]])
80 68
81 assert.matches("ROCK B 0.1", output, 1, true) 69 assert.matches("ROCK B 0.1", output, 1, true)
82 end) 70 end, finally)
83 end) 71 end)
84 end) 72 end)
85end) 73end)