node/test/sea/test-single-executable-application-assets-nonexistent-file.js
Joyee Cheung 20b62ff488
test: use fixture directories for sea tests
Instead of copying and writing files on the fly for SEA tests,
put the fixtures into a directory and copy them into tmpdir
for testing. This allows easier reproduction and debugging
when they do fail - we can just copy the entire fixture directory
and test directly from there.

PR-URL: https://github.com/nodejs/node/pull/61167
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2026-01-22 23:32:44 +01:00

35 lines
869 B
JavaScript

'use strict';
// Test that nonexistent asset file is rejected.
const common = require('../common'); // eslint-disable-line no-unused-vars
const {
spawnSyncAndExit,
} = require('../common/child_process');
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
const { copyFileSync } = require('fs');
tmpdir.refresh();
// Copy the fixture files to tmpdir
copyFileSync(
fixtures.path('sea', 'assets-nonexistent-file', 'sea-config.json'),
tmpdir.resolve('sea-config.json'),
);
copyFileSync(
fixtures.path('sea', 'assets-nonexistent-file', 'sea.js'),
tmpdir.resolve('sea.js'),
);
spawnSyncAndExit(
process.execPath,
['--experimental-sea-config', 'sea-config.json'],
{
cwd: tmpdir.path,
},
{
status: 1,
signal: null,
stderr: /Cannot read asset nonexistent\.txt: no such file or directory/,
});