From 9a68a4bd997b72cee4132459e0fd99eea0cdc627 Mon Sep 17 00:00:00 2001 From: William Boman Date: Sun, 23 Apr 2023 22:43:56 +0200 Subject: refactor(linker): copy_file instead of rename on Windows (#1254) Renaming the file will move it from its original installation directory. While reaching into package installation directories is unsupported and not recommended, it seems to be done pretty broadly. In order to avoid unnecessarily breaking people's configs we copy the file instead, for now. (tip: use the stable locations inside $MASON/share $MASON/opt $MASON/bin, if a package is missing a link please open an issue/PR). This will be reversed back to use uv_fs_rename() in 1.x.x. --- tests/mason-core/installer/linker_spec.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/mason-core/installer/linker_spec.lua b/tests/mason-core/installer/linker_spec.lua index 0a2b62ab..8bcf2607 100644 --- a/tests/mason-core/installer/linker_spec.lua +++ b/tests/mason-core/installer/linker_spec.lua @@ -152,7 +152,7 @@ describe("linker", function() end) ) - it("should rename share files on Windows", function() + it("should copy share files on Windows", function() platform.is.darwin = false platform.is.mac = false platform.is.linux = false @@ -163,7 +163,7 @@ describe("linker", function() stub(fs.async, "mkdirp") stub(fs.async, "dir_exists") stub(fs.async, "file_exists") - stub(fs.async, "rename") + stub(fs.async, "copy_file") -- mock non-existent dest files fs.async.file_exists.on_call_with(path.share_prefix "share-file").returns(false) @@ -187,13 +187,14 @@ describe("linker", function() assert.is_true(result:is_success()) - assert.spy(fs.async.rename).was_called(2) + assert.spy(fs.async.copy_file).was_called(2) assert - .spy(fs.async.rename) - .was_called_with(path.concat { dummy:get_install_path(), "share-file" }, path.share_prefix "share-file") - assert.spy(fs.async.rename).was_called_with( + .spy(fs.async.copy_file) + .was_called_with(path.concat { dummy:get_install_path(), "share-file" }, path.share_prefix "share-file", { excl = true }) + assert.spy(fs.async.copy_file).was_called_with( path.concat { dummy:get_install_path(), "nested", "path", "to", "share-file" }, - path.share_prefix "nested/path/share-file" + path.share_prefix "nested/path/share-file", + { excl = true } ) assert.spy(fs.async.mkdirp).was_called(2) -- cgit v1.2.3-70-g09d2