From 6ff678c5a5e9161c40d151cb7392b1de14f077f6 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Wed, 6 Dec 2023 21:55:08 -0500 Subject: [PATCH] test: verify symlinks are created for macos build --- test/fixture/cacheDir/nw | 0 test/get.js | 88 ++++++++++++++++++++++++++++++++++++++++ test/index.js | 6 ++- 3 files changed, 92 insertions(+), 2 deletions(-) delete mode 100644 test/fixture/cacheDir/nw create mode 100644 test/get.js diff --git a/test/fixture/cacheDir/nw b/test/fixture/cacheDir/nw deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/get.js b/test/get.js new file mode 100644 index 000000000..e7122b26d --- /dev/null +++ b/test/get.js @@ -0,0 +1,88 @@ +import assert from "node:assert"; +import fsm from "node:fs/promises"; +import path from "node:path"; + +import { describe, it } from "node:test"; + +import get from "../src/get.js"; + +describe("get mode", function () { + it("decompresses file and preserves symlinks on macos", async () => { + const options = { + version: "0.82.0", + flavor: "sdk", + platform: "osx", + arch: "x64", + downloadUrl: "https://dl.nwjs.io", + cacheDir: "./test/fixture/cache", + cache: true, + ffmpeg: false, + nativeAddon: false, + }; + + await get(options); + + const nwDir = path.resolve( + options.cacheDir, + `nwjs${options.flavor === "sdk" ? "-sdk" : ""}-v${options.version}-${options.platform}-${options.arch}`, + ); + + const helpersPath = await fsm.stat( + path.resolve( + nwDir, + "nwjs.app", + "Contents", + "Frameworks", + "nwjs Framework.framework", + "Helpers" + ) + ); + const librariesPath = await fsm.stat( + path.resolve( + nwDir, + "nwjs.app", + "Contents", + "Frameworks", + "nwjs Framework.framework", + "Libraries" + ) + ); + const frameworkPath = await fsm.stat( + path.resolve( + nwDir, + "nwjs.app", + "Contents", + "Frameworks", + "nwjs Framework.framework", + "nwjs Framework" + ) + ); + const resourcesPath = await fsm.stat( + path.resolve( + nwDir, + "nwjs.app", + "Contents", + "Frameworks", + "nwjs Framework.framework", + "Resources" + ) + ); + const versionCurrentPath = await fsm.stat( + path.resolve( + nwDir, + "nwjs.app", + "Contents", + "Frameworks", + "nwjs Framework.framework", + "Versions", + "Current" + ) + ); + + assert.strictEqual(helpersPath.isSymbolicLink(), true); + assert.strictEqual(librariesPath.isSymbolicLink(), true); + assert.strictEqual(frameworkPath.isSymbolicLink(), true); + assert.strictEqual(resourcesPath.isSymbolicLink(), true); + assert.strictEqual(versionCurrentPath.isSymbolicLink(), true); + }); +}); \ No newline at end of file diff --git a/test/index.js b/test/index.js index ae9d3d1d4..9346ef796 100644 --- a/test/index.js +++ b/test/index.js @@ -1,5 +1,7 @@ // import * as addonTests from "./addon.js"; -import * as modeTests from "./mode.js"; +import * as getTests from "./get.js"; +// import * as modeTests from "./mode.js"; // addonTests; -modeTests; +getTests; +// modeTests;