summaryrefslogtreecommitdiff
path: root/srcinfo_spec.lua
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2024-02-15 23:44:34 +0100
committerAki <please@ignore.pl>2024-02-15 23:57:28 +0100
commita5634616e022f5923614f35729585aac19a5a543 (patch)
tree11ef2a0f2d74a231ed45b7c2291211d9855aa10a /srcinfo_spec.lua
parentadd28ed158e7f6992ad94b946e96ca44c36fbe2d (diff)
downloadlua-srcinfo-a5634616e022f5923614f35729585aac19a5a543.zip
lua-srcinfo-a5634616e022f5923614f35729585aac19a5a543.tar.gz
lua-srcinfo-a5634616e022f5923614f35729585aac19a5a543.tar.bz2
Packages now reference bases for missing simple fields
Extending composite value from base in a package propagates the change to the base because there is no special handling for it yet.
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)