test: skip sea tests with more accurate available disk space estimation

PR-URL: https://github.com/nodejs/node/pull/53996
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Chengzhong Wu 2024-07-27 13:41:31 +01:00 committed by GitHub
parent 2d1b4a8cf7
commit 7a2f1b9738
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,7 +5,7 @@ const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir'); const tmpdir = require('../common/tmpdir');
const { inspect } = require('util'); const { inspect } = require('util');
const { readFileSync, copyFileSync } = require('fs'); const { readFileSync, copyFileSync, statSync } = require('fs');
const { const {
spawnSyncAndExitWithoutError, spawnSyncAndExitWithoutError,
} = require('../common/child_process'); } = require('../common/child_process');
@ -61,9 +61,12 @@ function skipIfSingleExecutableIsNotSupported() {
tmpdir.refresh(); tmpdir.refresh();
// The SEA tests involve making a copy of the executable and writing some fixtures // The SEA tests involve making a copy of the executable and writing some fixtures
// to the tmpdir. To be safe, ensure that at least 120MB disk space is available. // to the tmpdir. To be safe, ensure that the disk space has at least a copy of the
if (!tmpdir.hasEnoughSpace(120 * 1024 * 1024)) { // executable and some extra space for blobs and configs is available.
common.skip('Available disk space < 120MB'); const stat = statSync(process.execPath);
const expectedSpace = stat.size + 10 * 1024 * 1024;
if (!tmpdir.hasEnoughSpace(expectedSpace)) {
common.skip(`Available disk space < ${Math.floor(expectedSpace / 1024 / 1024)} MB`);
} }
} }