summaryrefslogtreecommitdiff
path: root/srcinfo_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'srcinfo_spec.lua')
-rw-r--r--srcinfo_spec.lua107
1 files changed, 97 insertions, 10 deletions
diff --git a/srcinfo_spec.lua b/srcinfo_spec.lua
index acc32df..3f6eee8 100644
--- a/srcinfo_spec.lua
+++ b/srcinfo_spec.lua
@@ -74,16 +74,18 @@ describe("Parses name-only .SRCINFO in", function()
end)
-it("Default mode is pkgname", function()
- local default = srcinfo(stx.dedent[[
- pkgbase = example
- pkgname = example
- ]])
- local explicit = srcinfo(stx.dedent[[
- pkgbase = example
- pkgname = example
- ]], {mode="pkgname"})
- assert.are.same(default, explicit)
+describe("Default mode is", function()
+ it("pkgname", function()
+ local default = srcinfo(stx.dedent[[
+ pkgbase = example
+ pkgname = example
+ ]])
+ local explicit = srcinfo(stx.dedent[[
+ pkgbase = example
+ pkgname = example
+ ]], {mode="pkgname"})
+ assert.are.same(default, explicit)
+ end)
end)
@@ -186,3 +188,88 @@ describe("Comments", function()
assert.are.same("I like #hiking", pkgs[1].base.pkgdesc)
end)
end)
+
+
+describe("Fields are parsed into", function()
+ it("simple values", function()
+ local pkgs = srcinfo(stx.dedent[[
+ pkgbase = example
+ pkgdesc = Example package
+ pkgver = 1.0.0
+ pkgrel = 1
+ arch = any
+
+ pkgname = example
+ ]])
+ assert.are.same("example", pkgs[1].base.name)
+ assert.are.same("Example package", pkgs[1].base.pkgdesc)
+ assert.are.same("1.0.0", pkgs[1].base.pkgver)
+ assert.are.same("1", pkgs[1].base.pkgrel)
+ assert.are.same("any", pkgs[1].base.arch)
+ end)
+
+ it("composite values", function()
+ local pkgs = srcinfo(stx.dedent[[
+ pkgbase = example
+ depends = library
+ depends = utility
+
+ pkgname = example
+ ]])
+ assert.are.same({"library", "utility"}, pkgs[1].base.depends)
+ end)
+end)
+
+
+describe("Packages can access base", function()
+ it("simple value fields", function()
+ local pkgs = srcinfo(stx.dedent[[
+ pkgbase = example
+ arch = any
+ pkgname = example
+ ]])
+ assert.are.same("any", pkgs[1].arch)
+ end)
+
+ it("composite value fields", function()
+ local pkgs = srcinfo(stx.dedent[[
+ pkgbase = example
+ depends = library
+ depends = utility
+ pkgname = example
+ ]])
+ assert.are.same({"library", "utility"}, pkgs[1].depends)
+ end)
+end)
+
+
+describe("Composite fields are", function()
+ it("extended", function()
+ local pkgs = srcinfo(stx.dedent[[
+ pkgbase = example
+ depends = library
+ pkgname = example
+ depends = utility
+ pkgname = example-b
+ depends = special
+ ]])
+ assert.are.same("library", pkgs[1].base.depends)
+ assert.are.same({"library", "utility"}, pkgs[1].depends)
+ assert.are.same({"library", "special"}, pkgs[2].depends)
+ end)
+
+ it("separeted", function()
+ local pkgs = srcinfo(stx.dedent[[
+ pkgbase = example
+ depends = library
+ depends = module
+ pkgname = example
+ depends = utility
+ pkgname = example-b
+ depends = special
+ ]])
+ assert.are.same({"library", "module"}, pkgs[1].base.depends)
+ assert.are.same({"library", "module", "utility"}, pkgs[1].depends)
+ assert.are.same({"library", "module", "special"}, pkgs[2].depends)
+ end)
+end)