test: add tests for electron fuses (#42129)
* spec: add tests for electron fuses * spec: fix tests for windows * spec: handle weird crash codes on win32 * spec: disable fuse tests on arm64 windows
This commit is contained in:
parent
c56e1dffb0
commit
e19754d7fd
9 changed files with 1080 additions and 38 deletions
40
spec/lib/fs-helpers.ts
Normal file
40
spec/lib/fs-helpers.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import * as cp from 'node:child_process';
|
||||
import * as fs from 'original-fs';
|
||||
import * as fsExtra from 'fs-extra';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
|
||||
export async function copyApp (targetDir: string): Promise<string> {
|
||||
// On macOS we can just copy the app bundle, easier too because of symlinks
|
||||
if (process.platform === 'darwin') {
|
||||
const appBundlePath = path.resolve(process.execPath, '../../..');
|
||||
const newPath = path.resolve(targetDir, 'Electron.app');
|
||||
cp.spawnSync('cp', ['-R', appBundlePath, path.dirname(newPath)]);
|
||||
return newPath;
|
||||
}
|
||||
|
||||
// On windows and linux we should read the zip manifest files and then copy each of those files
|
||||
// one by one
|
||||
const baseDir = path.dirname(process.execPath);
|
||||
const zipManifestPath = path.resolve(__dirname, '..', '..', 'script', 'zip_manifests', `dist_zip.${process.platform === 'win32' ? 'win' : 'linux'}.${process.arch}.manifest`);
|
||||
const filesToCopy = (fs.readFileSync(zipManifestPath, 'utf-8')).split('\n').filter(f => f !== 'LICENSE' && f !== 'LICENSES.chromium.html' && f !== 'version' && f.trim());
|
||||
await Promise.all(
|
||||
filesToCopy.map(async rel => {
|
||||
await fsExtra.mkdirp(path.dirname(path.resolve(targetDir, rel)));
|
||||
fs.copyFileSync(path.resolve(baseDir, rel), path.resolve(targetDir, rel));
|
||||
})
|
||||
);
|
||||
|
||||
return path.resolve(targetDir, path.basename(process.execPath));
|
||||
}
|
||||
|
||||
export async function withTempDirectory (fn: (dir: string) => Promise<void>, autoCleanUp = true) {
|
||||
const dir = await fsExtra.mkdtemp(path.resolve(os.tmpdir(), 'electron-update-spec-'));
|
||||
try {
|
||||
await fn(dir);
|
||||
} finally {
|
||||
if (autoCleanUp) {
|
||||
cp.spawnSync('rm', ['-r', dir]);
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue