fix(runtime): synchronize lockfile after builtin plugin migration
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdtempSync, mkdirSync, readFileSync, writeFileSync, rmSync } from 'node:fs';
|
||||
import { mkdtempSync, mkdirSync, readFileSync, writeFileSync, rmSync, existsSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
|
||||
for (const status of ['0', '23', '124', '137', 'empty']) {
|
||||
test('runtime prestart status ' + status, () => {
|
||||
for (const pending of [false, true]) {
|
||||
test('runtime prestart status ' + status + ', pending migration ' + pending, () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'dsh-prestart-'));
|
||||
try {
|
||||
if (status !== 'empty') {
|
||||
mkdirSync(join(dir, 'profiles/web'), { recursive: true, mode: 0o700 });
|
||||
writeFileSync(join(dir, 'profiles/web/package.json'), '{}', { mode: 0o600 });
|
||||
if (pending) writeFileSync(join(dir, 'profiles/web/.dsh-lockfile-pending'), 'pending');
|
||||
}
|
||||
const scripts = {
|
||||
node: `#!/bin/bash
|
||||
@@ -28,7 +30,7 @@ exec "$@"
|
||||
printf 'dsh %s\n' "$*" >> "$TRACE"
|
||||
test "$npm_config_ignore_scripts:$npm_config_ignore_pnpmfile" = true:true || exit 91
|
||||
if [ "$1" = plugin ]; then
|
||||
test "$*" = "plugin --profile web install --ignore-scripts" || exit 92
|
||||
test "$*" = "plugin --profile web install --ignore-scripts$EXPECTED_ARGS" || exit 92
|
||||
exit "$PLUGIN_STATUS"
|
||||
fi
|
||||
exit 0
|
||||
@@ -42,7 +44,7 @@ sleep 0.1
|
||||
writeFileSync(join(dir, name), script, { mode: 0o700 });
|
||||
}
|
||||
const result = spawnSync('bash', [fileURLToPath(new URL('./entrypoint.sh', import.meta.url)), 'web', '--no-open', '--port', '3080'], {
|
||||
env: { ...process.env, PATH: dir + ':' + process.env.PATH, DSH_HOME: dir, TRACE: join(dir, 'trace'), PLUGIN_STATUS: status },
|
||||
env: { ...process.env, PATH: dir + ':' + process.env.PATH, DSH_HOME: dir, TRACE: join(dir, 'trace'), PLUGIN_STATUS: status, EXPECTED_ARGS: pending ? ' --no-frozen-lockfile' : '' },
|
||||
encoding: 'utf8', timeout: 5000,
|
||||
});
|
||||
assert.ifError(result.error);
|
||||
@@ -55,6 +57,7 @@ sleep 0.1
|
||||
return;
|
||||
}
|
||||
assert.match(trace, /dsh plugin --profile web install --ignore-scripts/);
|
||||
assert.equal(existsSync(join(dir, 'profiles/web/.dsh-lockfile-pending')), pending && status !== '0');
|
||||
if (status === '0') {
|
||||
assert.match(output, /reconciliation complete/);
|
||||
assert.match(trace, /dsh web/);
|
||||
@@ -66,6 +69,7 @@ sleep 0.1
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test('runtime pins pnpm and uses nonroot with tini process-group forwarding', () => {
|
||||
|
||||
Reference in New Issue
Block a user