diff options
| -rw-r--r-- | spec/fixtures/bad_pack-0.1-1.rockspec | 19 | ||||
| -rw-r--r-- | spec/pack_spec.lua | 6 | ||||
| -rw-r--r-- | src/luarocks/pack.lua | 8 |
3 files changed, 32 insertions, 1 deletions
diff --git a/spec/fixtures/bad_pack-0.1-1.rockspec b/spec/fixtures/bad_pack-0.1-1.rockspec new file mode 100644 index 00000000..23934244 --- /dev/null +++ b/spec/fixtures/bad_pack-0.1-1.rockspec | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | rockspec_format = "3.0" | ||
| 2 | package = "bad_pack" | ||
| 3 | version = "0.1-1" | ||
| 4 | source = { | ||
| 5 | url = "http://localhost:8080/file/busted_project-0.1.tar.gz", | ||
| 6 | dir = "invalid_dir", | ||
| 7 | } | ||
| 8 | description = { | ||
| 9 | summary = "A project that uses Busted tests", | ||
| 10 | } | ||
| 11 | build = { | ||
| 12 | type = "builtin", | ||
| 13 | modules = { | ||
| 14 | sum = "sum.lua", | ||
| 15 | } | ||
| 16 | } | ||
| 17 | test = { | ||
| 18 | type = "busted", | ||
| 19 | } | ||
diff --git a/spec/pack_spec.lua b/spec/pack_spec.lua index 0790c801..55071839 100644 --- a/spec/pack_spec.lua +++ b/spec/pack_spec.lua | |||
| @@ -80,6 +80,12 @@ describe("luarocks pack #integration", function() | |||
| 80 | assert.is_truthy(lfs.attributes("a_rock-1.0-1.src.rock")) | 80 | assert.is_truthy(lfs.attributes("a_rock-1.0-1.src.rock")) |
| 81 | end) | 81 | end) |
| 82 | 82 | ||
| 83 | it("fails packing a rockspec into a .src.rock dir if doesn't exist", function() | ||
| 84 | local output = run.luarocks("pack " .. testing_paths.fixtures_dir .. "/bad_pack-0.1-1.rockspec") | ||
| 85 | assert.match("Directory invalid_dir not found", output) | ||
| 86 | assert.is_falsy(lfs.attributes("bad_pack-0.1-1.src.rock")) | ||
| 87 | end) | ||
| 88 | |||
| 83 | describe("namespaced dependencies", function() | 89 | describe("namespaced dependencies", function() |
| 84 | it("can pack rockspec with namespaced dependencies", function() | 90 | it("can pack rockspec with namespaced dependencies", function() |
| 85 | finally(function() | 91 | finally(function() |
diff --git a/src/luarocks/pack.lua b/src/luarocks/pack.lua index 34268475..5d70a854 100644 --- a/src/luarocks/pack.lua +++ b/src/luarocks/pack.lua | |||
| @@ -35,7 +35,13 @@ function pack.pack_source_rock(rockspec_file) | |||
| 35 | local name_version = rockspec.name .. "-" .. rockspec.version | 35 | local name_version = rockspec.name .. "-" .. rockspec.version |
| 36 | local rock_file = fs.absolute_name(name_version .. ".src.rock") | 36 | local rock_file = fs.absolute_name(name_version .. ".src.rock") |
| 37 | 37 | ||
| 38 | local source_file, source_dir = fetch.fetch_sources(rockspec, false) | 38 | local temp_dir, err = fs.make_temp_dir("pack-"..name_version) |
| 39 | if not temp_dir then | ||
| 40 | return nil, "Failed creating temporary directory: "..err | ||
| 41 | end | ||
| 42 | util.schedule_function(fs.delete, temp_dir) | ||
| 43 | |||
| 44 | local source_file, source_dir = fetch.fetch_sources(rockspec, true, temp_dir) | ||
| 39 | if not source_file then | 45 | if not source_file then |
| 40 | return nil, source_dir | 46 | return nil, source_dir |
| 41 | end | 47 | end |
