From a5634616e022f5923614f35729585aac19a5a543 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 15 Feb 2024 23:44:34 +0100 Subject: 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. --- srcinfo_spec.lua | 107 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 97 insertions(+), 10 deletions(-) (limited to 'srcinfo_spec.lua') 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) -- cgit v1.1