File: expand_rockspec_spec.lua

package info (click to toggle)
luacheck 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,704 kB
  • sloc: sh: 106; makefile: 96; python: 35
file content (46 lines) | stat: -rw-r--r-- 1,481 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
local expand_rockspec = require "luacheck.expand_rockspec"
local fs = require "luacheck.fs"
local P = fs.normalize

describe("expand_rockspec", function()
   it("returns sorted array of lua files related to a rock", function()
      assert.same({
         "bar.lua",
         "baz.lua",
         "bin.lua",
         "foo.lua"
      }, expand_rockspec("spec/folder/rockspec"))
   end)

   it("autodetects modules for rockspecs without build table", function()
      assert.same({
         P"spec/rock/src/rock.lua",
         P"spec/rock/src/rock/mod.lua",
         P"spec/rock/bin/rock.lua"
      }, expand_rockspec("spec/rock/rock-dev-1.rockspec"))
   end)

   it("autodetects modules for rockspecs without build.modules table", function()
      assert.same({
         P"spec/rock2/mod.lua"
      }, expand_rockspec("spec/rock2/rock2-dev-1.rockspec"))
   end)

   it("returns nil, \"I/O\" for non-existent paths", function()
      local ok, err = expand_rockspec("spec/folder/non-existent")
      assert.is_nil(ok)
      assert.equal("I/O", err)
   end)

   it("returns nil, \"syntax\" for rockspecs with syntax errors", function()
      local ok, err = expand_rockspec("spec/folder/bad_config")
      assert.is_nil(ok)
      assert.equal("syntax", err)
   end)

   it("returns nil, \"runtime\" for rockspecs with run-time errors", function()
      local ok, err = expand_rockspec("spec/folder/bad_rockspec")
      assert.is_nil(ok)
      assert.equal("runtime", err)
   end)
end)