diff options
| author | William Boman <william@redwill.se> | 2023-02-26 07:57:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-26 07:57:42 +0100 |
| commit | 2e83e412d877a7e6daf04b2b6359521f6fb8c20e (patch) | |
| tree | 5c9488569a0e8b9f2aa3d492c666aed4fb55b194 /tests | |
| parent | chore: autogenerate (#1028) (diff) | |
| download | mason-2e83e412d877a7e6daf04b2b6359521f6fb8c20e.tar mason-2e83e412d877a7e6daf04b2b6359521f6fb8c20e.tar.gz mason-2e83e412d877a7e6daf04b2b6359521f6fb8c20e.tar.bz2 mason-2e83e412d877a7e6daf04b2b6359521f6fb8c20e.tar.lz mason-2e83e412d877a7e6daf04b2b6359521f6fb8c20e.tar.xz mason-2e83e412d877a7e6daf04b2b6359521f6fb8c20e.tar.zst mason-2e83e412d877a7e6daf04b2b6359521f6fb8c20e.zip | |
refactor: simplify linker & receipt writing (#1033)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/mason-core/installer/installer_spec.lua | 23 | ||||
| -rw-r--r-- | tests/mason-core/installer/linker_spec.lua | 4 |
2 files changed, 21 insertions, 6 deletions
diff --git a/tests/mason-core/installer/installer_spec.lua b/tests/mason-core/installer/installer_spec.lua index 1092ebd1..094129f9 100644 --- a/tests/mason-core/installer/installer_spec.lua +++ b/tests/mason-core/installer/installer_spec.lua @@ -1,4 +1,3 @@ -local stub = require "luassert.stub" local spy = require "luassert.spy" local match = require "luassert.match" local stub = require "luassert.stub" @@ -64,8 +63,20 @@ describe("installer", function() ---@param ctx InstallContext handler.package.spec.install = function(ctx) ctx.receipt:with_primary_source { type = "source", metadata = {} } - ctx.fs:write_file("target", "script-contents") - ctx:link_bin("executable", "target") + + ctx.fs:write_file("target", "") + ctx.fs:write_file("file.jar", "") + ctx.fs:write_file("opt-cmd", "") + + ctx.links.bin = { + ["executable"] = "target", + } + ctx.links.share = { + ["package/file.jar"] = "file.jar", + } + ctx.links.opt = { + ["package/bin/opt-cmd"] = "opt-cmd", + } end installer.execute(handler, {}) assert.spy(fs.async.write_file).was_called_with( @@ -77,7 +88,11 @@ describe("installer", function() assert.same({ type = "source", metadata = {} }, receipt.primary_source) assert.same({}, receipt.secondary_sources) assert.same("1.1", receipt.schema_version) - assert.same({ bin = { executable = "target" }, share = {} }, receipt.links) + assert.same({ + bin = { executable = "target" }, + share = { ["package/file.jar"] = "file.jar" }, + opt = { ["package/bin/opt-cmd"] = "opt-cmd" }, + }, receipt.links) end) ) end) diff --git a/tests/mason-core/installer/linker_spec.lua b/tests/mason-core/installer/linker_spec.lua index 57dba607..cf8260c6 100644 --- a/tests/mason-core/installer/linker_spec.lua +++ b/tests/mason-core/installer/linker_spec.lua @@ -129,8 +129,8 @@ describe("linker", function() local handle = InstallHandleGenerator "dummy" local ctx = InstallContextGenerator(handle) - ctx:link_share("nested/path/share-file", path.concat { "nested", "path", "to", "share-file" }) - ctx:link_share("share-file", "share-file") + ctx.links.share["nested/path/share-file"] = path.concat { "nested", "path", "to", "share-file" } + ctx.links.share["share-file"] = "share-file" assert.is_true(linker.link(ctx):is_success()) assert.spy(fs.async.write_file).was_called(0) |
