diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/loader_spec.lua | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/spec/loader_spec.lua b/spec/loader_spec.lua index 35179080..c8526117 100644 --- a/spec/loader_spec.lua +++ b/spec/loader_spec.lua | |||
| @@ -4,10 +4,21 @@ local testing_paths = test_env.testing_paths | |||
| 4 | local write_file = test_env.write_file | 4 | local write_file = test_env.write_file |
| 5 | 5 | ||
| 6 | describe("luarocks.loader", function() | 6 | describe("luarocks.loader", function() |
| 7 | |||
| 8 | before_each(function() | ||
| 9 | test_env.setup_specs() | ||
| 10 | end) | ||
| 11 | |||
| 7 | describe("#unit", function() | 12 | describe("#unit", function() |
| 8 | it("starts", function() | 13 | it("starts", function() |
| 9 | assert(run.lua_bool([[-e "require 'luarocks.loader'; print(package.loaded['luarocks.loaded'])"]])) | 14 | assert(run.lua_bool([[-e "require 'luarocks.loader'; print(package.loaded['luarocks.loaded'])"]])) |
| 10 | end) | 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) | ||
| 11 | end) | 22 | end) |
| 12 | 23 | ||
| 13 | describe("#integration", function() | 24 | describe("#integration", function() |
| @@ -21,13 +32,13 @@ describe("luarocks.loader", function() | |||
| 21 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/rock_b_01.lua" | 32 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/rock_b_01.lua" |
| 22 | } | 33 | } |
| 23 | build = { | 34 | build = { |
| 24 | type = "builtin", | 35 | type = "builtin", |
| 25 | modules = { | 36 | modules = { |
| 26 | rock_b = "rock_b_01.lua" | 37 | rock_b = "rock_b_01.lua" |
| 27 | } | 38 | } |
| 28 | } | 39 | } |
| 29 | ]], finally) | 40 | ]], finally) |
| 30 | 41 | ||
| 31 | write_file("rock_b_10.lua", "print('ROCK B 1.0'); return {}", finally) | 42 | write_file("rock_b_10.lua", "print('ROCK B 1.0'); return {}", finally) |
| 32 | write_file("rock_b-1.0-1.rockspec", [[ | 43 | write_file("rock_b-1.0-1.rockspec", [[ |
| 33 | package = "rock_b" | 44 | package = "rock_b" |
| @@ -36,13 +47,13 @@ describe("luarocks.loader", function() | |||
| 36 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/rock_b_10.lua" | 47 | url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/rock_b_10.lua" |
| 37 | } | 48 | } |
| 38 | build = { | 49 | build = { |
| 39 | type = "builtin", | 50 | type = "builtin", |
| 40 | modules = { | 51 | modules = { |
| 41 | rock_b = "rock_b_10.lua" | 52 | rock_b = "rock_b_10.lua" |
| 42 | } | 53 | } |
| 43 | } | 54 | } |
| 44 | ]], finally) | 55 | ]], finally) |
| 45 | 56 | ||
| 46 | write_file("rock_a.lua", "require('rock_b'); return {}", finally) | 57 | write_file("rock_a.lua", "require('rock_b'); return {}", finally) |
| 47 | write_file("rock_a-2.0-1.rockspec", [[ | 58 | write_file("rock_a-2.0-1.rockspec", [[ |
| 48 | package = "rock_a" | 59 | package = "rock_a" |
| @@ -54,7 +65,7 @@ describe("luarocks.loader", function() | |||
| 54 | "rock_b < 1.0", | 65 | "rock_b < 1.0", |
| 55 | } | 66 | } |
| 56 | build = { | 67 | build = { |
| 57 | type = "builtin", | 68 | type = "builtin", |
| 58 | modules = { | 69 | modules = { |
| 59 | rock_a = "rock_a.lua" | 70 | rock_a = "rock_a.lua" |
| 60 | } | 71 | } |
| @@ -64,9 +75,9 @@ describe("luarocks.loader", function() | |||
| 64 | print(run.luarocks("make --server=" .. testing_paths.fixtures_dir .. "/a_repo --tree=" .. testing_paths.testing_tree .. " ./rock_b-0.1-1.rockspec")) | 75 | 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")) | 76 | 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")) | 77 | print(run.luarocks("make --server=" .. testing_paths.fixtures_dir .. "/a_repo --tree=" .. testing_paths.testing_tree .. " ./rock_a-2.0-1.rockspec")) |
| 67 | 78 | ||
| 68 | local output = run.lua([[-e "require 'luarocks.loader'; require('rock_a')"]]) | 79 | local output = run.lua([[-e "require 'luarocks.loader'; require('rock_a')"]]) |
| 69 | 80 | ||
| 70 | assert.matches("ROCK B 0.1", output, 1, true) | 81 | assert.matches("ROCK B 0.1", output, 1, true) |
| 71 | end) | 82 | end) |
| 72 | end) | 83 | end) |
