Skip to content

Commit

Permalink
adding test case for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaietta committed Nov 12, 2024
1 parent 2ba954c commit eb70817
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
68 changes: 40 additions & 28 deletions test/cli-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,40 +190,52 @@ describe('command line interface', function () {
});
it('should unpack static framework with all underlying symlinks unpacked', async () => {
await execAsar(
'p test/input/packthis-with-symlink/ tmp/packthis-with-symlink.asar --unpack *.txt --unpack-dir "{dir2/subdir,Hello.framework}" --exclude-hidden',
'p test/input/packthis-with-symlink/ tmp/packthis-with-symlink.asar --unpack *.txt --unpack-dir "{dir2/subdir,Hello.framework,WindowsMklink}" --exclude-hidden',
);
// actual files
assert.ok(fs.existsSync('tmp/packthis-with-symlink.asar.unpacked/real.txt'));
assert.ok(fs.existsSync('tmp/packthis-with-symlink.asar.unpacked/A/real.txt'));
assert.ok(
fs.existsSync('tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Versions/A/Hello'),
);
assert.ok(fs.existsSync('tmp/packthis-with-symlink.asar.unpacked/WindowsMklink/Test/test.txt'));

// unpacked symlinks
assert.equal(
fs.readlinkSync('tmp/packthis-with-symlink.asar.unpacked/real.txt'),
'Current/real.txt',
);

assert.equal(
fs.readlinkSync('tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Hello'),
'Versions/Current/Hello',
);
assert.ok(
fs
.realpathSync(
'tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Versions/Current/Hello',
)
.endsWith('tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Versions/A/Hello'),
);

assert.equal(
fs.readlinkSync('tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Headers'),
'Versions/Current/Headers',
);
assert.ok(
fs
.realpathSync('tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Headers')
.endsWith('tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Versions/A/Headers'),
);
// symlinks in Hello.framework can only be "followed" on mac/linux, so we have separate Windows-created symlinks via `mklink` as another test (WindowsMklink folder)
if (process.platform !== 'win32') {
assert.equal(
fs.readlinkSync('tmp/packthis-with-symlink.asar.unpacked/real.txt'),
'Current/real.txt',
);
assert.equal(
fs.readlinkSync('tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Hello'),
'Versions/Current/Hello',
);
assert.ok(
fs
.realpathSync(
'tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Versions/Current/Hello',
)
.endsWith('tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Versions/A/Hello'),
);
assert.equal(
fs.readlinkSync('tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Headers'),
'Versions/Current/Headers',
);
assert.ok(
fs
.realpathSync('tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Headers')
.endsWith('tmp/packthis-with-symlink.asar.unpacked/Hello.framework/Versions/A/Headers'),
);
} else {
assert.strictEqual(
fs.readlinkSync('tmp/packthis-with-symlink.asar.unpacked/WindowsMklink/SymlinkedDir'),
'Test',
);
assert.ok(
fs
.realpathSync('tmp/packthis-with-symlink.asar.unpacked/WindowsMklink/SymlinkedDir/test.txt')
.endsWith(path.normalize('tmp/packthis-with-symlink.asar.unpacked/WindowsMklink/Test/test.txt')),
);
}
});
});
Empty file.

0 comments on commit eb70817

Please sign in to comment.