test: add tests for electron fuses (#42147)

* spec: add tests for electron fuses

Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>

* spec: fix tests for windows

Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>

* spec: handle weird crash codes on win32

Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>

* spec: disable fuse tests on arm64 windows

Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>
This commit is contained in:
trop[bot] 2024-05-13 13:36:03 -07:00 committed by GitHub
parent 7294c766ac
commit ea3001dd39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 1080 additions and 38 deletions

View file

@ -4,10 +4,11 @@ import * as fs from 'fs-extra';
import * as path from 'node:path';
import * as util from 'node:util';
import { getRemoteContext, ifdescribe, ifit, itremote, useRemoteContext } from './lib/spec-helpers';
import { copyApp, getCodesignIdentity, shouldRunCodesignTests, signApp, spawn, withTempDirectory } from './lib/codesign-helpers';
import { copyMacOSFixtureApp, getCodesignIdentity, shouldRunCodesignTests, signApp, spawn } from './lib/codesign-helpers';
import { webContents } from 'electron/main';
import { EventEmitter } from 'node:stream';
import { once } from 'node:events';
import { withTempDirectory } from './lib/fs-helpers';
const mainFixturesPath = path.resolve(__dirname, 'fixtures');
@ -683,7 +684,7 @@ describe('node feature', () => {
it('is disabled when invoked by other apps in ELECTRON_RUN_AS_NODE mode', async () => {
await withTempDirectory(async (dir) => {
const appPath = await copyApp(dir);
const appPath = await copyMacOSFixtureApp(dir);
await signApp(appPath, identity);
// Invoke Electron by using the system node binary as middle layer, so
// the check of NODE_OPTIONS will think the process is started by other
@ -696,7 +697,7 @@ describe('node feature', () => {
it('is disabled when invoked by alien binary in app bundle in ELECTRON_RUN_AS_NODE mode', async function () {
await withTempDirectory(async (dir) => {
const appPath = await copyApp(dir);
const appPath = await copyMacOSFixtureApp(dir);
await signApp(appPath, identity);
// Find system node and copy it to app bundle.
const nodePath = process.env.PATH?.split(path.delimiter).find(dir => fs.existsSync(path.join(dir, 'node')));
@ -715,7 +716,7 @@ describe('node feature', () => {
it('is respected when invoked from self', async () => {
await withTempDirectory(async (dir) => {
const appPath = await copyApp(dir, null);
const appPath = await copyMacOSFixtureApp(dir, null);
await signApp(appPath, identity);
const appExePath = path.join(appPath, 'Contents/MacOS/Electron');
const { code, out } = await spawn(appExePath, [script, appExePath]);