aboutsummaryrefslogtreecommitdiff
path: root/spec/pack_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spec/pack_spec.lua')
-rw-r--r--spec/pack_spec.lua56
1 files changed, 55 insertions, 1 deletions
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua
index 55071839..beab7e8a 100644
--- a/spec/pack_spec.lua
+++ b/spec/pack_spec.lua
@@ -2,6 +2,7 @@ local test_env = require("spec.util.test_env")
2local lfs = require("lfs") 2local lfs = require("lfs")
3local run = test_env.run 3local run = test_env.run
4local testing_paths = test_env.testing_paths 4local testing_paths = test_env.testing_paths
5local write_file = test_env.write_file
5 6
6test_env.unload_luarocks() 7test_env.unload_luarocks()
7 8
@@ -80,7 +81,60 @@ describe("luarocks pack #integration", function()
80 assert.is_truthy(lfs.attributes("a_rock-1.0-1.src.rock")) 81 assert.is_truthy(lfs.attributes("a_rock-1.0-1.src.rock"))
81 end) 82 end)
82 83
83 it("fails packing a rockspec into a .src.rock dir if doesn't exist", function() 84 it("can pack a rockspec with a bare file:// in the url", function()
85 test_env.run_in_tmp(function(tmpdir)
86 write_file("test-1.0-1.rockspec", [[
87 package = "test"
88 version = "1.0-1"
89 source = {
90 url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/test.lua"
91 }
92 dependencies = {
93 "a_rock 1.0"
94 }
95 build = {
96 type = "builtin",
97 modules = {
98 test = "test.lua"
99 }
100 }
101 ]], finally)
102 write_file("test.lua", "return {}", finally)
103
104 assert.is.truthy(run.luarocks_bool("pack test-1.0-1.rockspec"))
105 assert.is.truthy(lfs.attributes("test-1.0-1.src.rock"))
106
107 assert.is.truthy(run.luarocks_bool("unpack test-1.0-1.src.rock"))
108 assert.is.truthy(lfs.attributes("test-1.0-1/test.lua"))
109 end, finally)
110 end)
111
112 it("can pack a rockspec with a bare file:// fails if doesn't exist", function()
113 test_env.run_in_tmp(function(tmpdir)
114 write_file("test-1.0-1.rockspec", [[
115 package = "test"
116 version = "1.0-1"
117 source = {
118 url = "file://]] .. tmpdir:gsub("\\", "/") .. [[/test_doesnt_exist.lua"
119 }
120 dependencies = {
121 "a_rock 1.0"
122 }
123 build = {
124 type = "builtin",
125 modules = {
126 test = "test.lua"
127 }
128 }
129 ]], finally)
130
131 assert.is.falsy(run.luarocks_bool("pack test-1.0-1.rockspec"))
132 assert.is.falsy(lfs.attributes("test-1.0-1.src.rock"))
133 end, finally)
134 end)
135
136
137 it("fails packing a rockspec into a .src.rock if dir doesn't exist", function()
84 local output = run.luarocks("pack " .. testing_paths.fixtures_dir .. "/bad_pack-0.1-1.rockspec") 138 local output = run.luarocks("pack " .. testing_paths.fixtures_dir .. "/bad_pack-0.1-1.rockspec")
85 assert.match("Directory invalid_dir not found", output) 139 assert.match("Directory invalid_dir not found", output)
86 assert.is_falsy(lfs.attributes("bad_pack-0.1-1.src.rock")) 140 assert.is_falsy(lfs.attributes("bad_pack-0.1-1.src.rock"))