test: add test should shim asars with different unpacked dirs (#125)
This commit is contained in:
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
@@ -15,6 +15,7 @@ jobs:
|
|||||||
test:
|
test:
|
||||||
name: Test
|
name: Test
|
||||||
strategy:
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
node-version:
|
node-version:
|
||||||
- '20.5'
|
- '20.5'
|
||||||
|
|||||||
@@ -273,6 +273,180 @@ exports[`makeUniversalApp asar mode should not inject ElectronAsarIntegrity into
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`makeUniversalApp asar mode should shim asars with different unpacked dirs 1`] = `
|
||||||
|
{
|
||||||
|
"files": {
|
||||||
|
"index.js": {
|
||||||
|
"integrity": {
|
||||||
|
"algorithm": "SHA256",
|
||||||
|
"blockSize": 4194304,
|
||||||
|
"blocks": [
|
||||||
|
"0f6311dac07f0876c436ce2be042eb88c96e17eaf140b39627cf720dd87ad5b8",
|
||||||
|
],
|
||||||
|
"hash": "0f6311dac07f0876c436ce2be042eb88c96e17eaf140b39627cf720dd87ad5b8",
|
||||||
|
},
|
||||||
|
"size": 66,
|
||||||
|
},
|
||||||
|
"package.json": {
|
||||||
|
"integrity": {
|
||||||
|
"algorithm": "SHA256",
|
||||||
|
"blockSize": 4194304,
|
||||||
|
"blocks": [
|
||||||
|
"d6226276d47adc7aa20e6c46e842e258f5157313074a035051a89612acdd6be3",
|
||||||
|
],
|
||||||
|
"hash": "d6226276d47adc7aa20e6c46e842e258f5157313074a035051a89612acdd6be3",
|
||||||
|
},
|
||||||
|
"size": 41,
|
||||||
|
},
|
||||||
|
"private": {
|
||||||
|
"files": {
|
||||||
|
"var": {
|
||||||
|
"files": {
|
||||||
|
"app": {
|
||||||
|
"files": {
|
||||||
|
"file.txt": {
|
||||||
|
"link": "private/var/file.txt",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"file.txt": {
|
||||||
|
"integrity": {
|
||||||
|
"algorithm": "SHA256",
|
||||||
|
"blockSize": 4194304,
|
||||||
|
"blocks": [
|
||||||
|
"b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
|
||||||
|
],
|
||||||
|
"hash": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
|
||||||
|
},
|
||||||
|
"size": 11,
|
||||||
|
"unpacked": true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"var": {
|
||||||
|
"link": "private/var",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`makeUniversalApp asar mode should shim asars with different unpacked dirs 2`] = `
|
||||||
|
{
|
||||||
|
"files": {
|
||||||
|
"index.js": {
|
||||||
|
"integrity": {
|
||||||
|
"algorithm": "SHA256",
|
||||||
|
"blockSize": 4194304,
|
||||||
|
"blocks": [
|
||||||
|
"0f6311dac07f0876c436ce2be042eb88c96e17eaf140b39627cf720dd87ad5b8",
|
||||||
|
],
|
||||||
|
"hash": "0f6311dac07f0876c436ce2be042eb88c96e17eaf140b39627cf720dd87ad5b8",
|
||||||
|
},
|
||||||
|
"size": 66,
|
||||||
|
},
|
||||||
|
"package.json": {
|
||||||
|
"integrity": {
|
||||||
|
"algorithm": "SHA256",
|
||||||
|
"blockSize": 4194304,
|
||||||
|
"blocks": [
|
||||||
|
"d6226276d47adc7aa20e6c46e842e258f5157313074a035051a89612acdd6be3",
|
||||||
|
],
|
||||||
|
"hash": "d6226276d47adc7aa20e6c46e842e258f5157313074a035051a89612acdd6be3",
|
||||||
|
},
|
||||||
|
"size": 41,
|
||||||
|
},
|
||||||
|
"private": {
|
||||||
|
"files": {
|
||||||
|
"var": {
|
||||||
|
"files": {
|
||||||
|
"app": {
|
||||||
|
"files": {
|
||||||
|
"file.txt": {
|
||||||
|
"link": "private/var/file.txt",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"file.txt": {
|
||||||
|
"integrity": {
|
||||||
|
"algorithm": "SHA256",
|
||||||
|
"blockSize": 4194304,
|
||||||
|
"blocks": [
|
||||||
|
"b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
|
||||||
|
],
|
||||||
|
"hash": "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9",
|
||||||
|
},
|
||||||
|
"size": 11,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"var": {
|
||||||
|
"link": "private/var",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`makeUniversalApp asar mode should shim asars with different unpacked dirs 3`] = `
|
||||||
|
{
|
||||||
|
"files": {
|
||||||
|
"index.js": {
|
||||||
|
"integrity": {
|
||||||
|
"algorithm": "SHA256",
|
||||||
|
"blockSize": 4194304,
|
||||||
|
"blocks": [
|
||||||
|
"b7e5f58d3c0fddc1a57d1279a7f19a34a01784f4036920d4b60a1e33f6d1635b",
|
||||||
|
],
|
||||||
|
"hash": "b7e5f58d3c0fddc1a57d1279a7f19a34a01784f4036920d4b60a1e33f6d1635b",
|
||||||
|
},
|
||||||
|
"size": 1068,
|
||||||
|
},
|
||||||
|
"package.json": {
|
||||||
|
"integrity": {
|
||||||
|
"algorithm": "SHA256",
|
||||||
|
"blockSize": 4194304,
|
||||||
|
"blocks": [
|
||||||
|
"2873266521e41d58d02e7acfbbbdb046edfa04b6ce262b8987de8e8548671fc7",
|
||||||
|
],
|
||||||
|
"hash": "2873266521e41d58d02e7acfbbbdb046edfa04b6ce262b8987de8e8548671fc7",
|
||||||
|
},
|
||||||
|
"size": 33,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`makeUniversalApp asar mode should shim asars with different unpacked dirs 4`] = `
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"content": "hello world",
|
||||||
|
"name": "private/var/file.txt",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`makeUniversalApp asar mode should shim asars with different unpacked dirs 5`] = `
|
||||||
|
{
|
||||||
|
"Contents/Info.plist": {
|
||||||
|
"Resources/app-arm64.asar": {
|
||||||
|
"algorithm": "SHA256",
|
||||||
|
"hash": "c7563e17e768e508045ffb888935d50dbf785bbba3ffb0068e5472fda4f6c199",
|
||||||
|
},
|
||||||
|
"Resources/app-x64.asar": {
|
||||||
|
"algorithm": "SHA256",
|
||||||
|
"hash": "7e6af4d00f4cc737eff922e2b386128a269f80887b79a011022f1276bdbe7832",
|
||||||
|
},
|
||||||
|
"Resources/app.asar": {
|
||||||
|
"algorithm": "SHA256",
|
||||||
|
"hash": "b62aaaed07ff72dc33da1720d900e0443c060285ef374ce1bdaef1d4f28b5fe4",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`makeUniversalApp force packages successfully if \`out\` bundle already exists and \`force\` is \`true\` 1`] = `
|
exports[`makeUniversalApp force packages successfully if \`out\` bundle already exists and \`force\` is \`true\` 1`] = `
|
||||||
{
|
{
|
||||||
"files": {
|
"files": {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as path from 'path';
|
|||||||
|
|
||||||
import { makeUniversalApp } from '../dist/cjs/index';
|
import { makeUniversalApp } from '../dist/cjs/index';
|
||||||
import { createTestApp, templateApp, VERIFY_APP_TIMEOUT, verifyApp } from './util';
|
import { createTestApp, templateApp, VERIFY_APP_TIMEOUT, verifyApp } from './util';
|
||||||
import { createPackage } from '@electron/asar';
|
import { createPackage, createPackageWithOptions } from '@electron/asar';
|
||||||
|
|
||||||
const appsPath = path.resolve(__dirname, 'fixtures', 'apps');
|
const appsPath = path.resolve(__dirname, 'fixtures', 'apps');
|
||||||
const appsOutPath = path.resolve(__dirname, 'fixtures', 'apps', 'out');
|
const appsOutPath = path.resolve(__dirname, 'fixtures', 'apps', 'out');
|
||||||
@@ -156,6 +156,41 @@ describe('makeUniversalApp', () => {
|
|||||||
},
|
},
|
||||||
VERIFY_APP_TIMEOUT,
|
VERIFY_APP_TIMEOUT,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it(
|
||||||
|
'should shim asars with different unpacked dirs',
|
||||||
|
async () => {
|
||||||
|
const arm64AppPath = await templateApp('UnpackedArm64.app', 'arm64', async (appPath) => {
|
||||||
|
const { testPath } = await createTestApp('UnpackedAppArm64');
|
||||||
|
await createPackageWithOptions(
|
||||||
|
testPath,
|
||||||
|
path.resolve(appPath, 'Contents', 'Resources', 'app.asar'),
|
||||||
|
{
|
||||||
|
unpackDir: 'var',
|
||||||
|
unpack: '*.txt',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const x64AppPath = await templateApp('UnpackedX64.app', 'x64', async (appPath) => {
|
||||||
|
const { testPath } = await createTestApp('UnpackedAppX64');
|
||||||
|
await createPackageWithOptions(
|
||||||
|
testPath,
|
||||||
|
path.resolve(appPath, 'Contents', 'Resources', 'app.asar'),
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const outAppPath = path.resolve(appsOutPath, 'UnpackedDir.app');
|
||||||
|
await makeUniversalApp({
|
||||||
|
x64AppPath,
|
||||||
|
arm64AppPath,
|
||||||
|
outAppPath,
|
||||||
|
});
|
||||||
|
await verifyApp(outAppPath);
|
||||||
|
},
|
||||||
|
VERIFY_APP_TIMEOUT,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('no asar mode', () => {
|
describe('no asar mode', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user