Add a smoke test runner, a shared harness, and safer build scripts

- pnpm smoke runs tests/smoke/ in parallel. It starts Vite when nothing
  serves SMOKE_URL, finds an installed Chrome when Playwright has no
  Chromium, and skips a test with a reason when a requirement that the
  test declares with "// @requires" is missing. Logs go to
  output/smoke/logs/.
- tests/smoke/_harness/ holds the Playwright launch, page error
  collection, the Tauri IPC mock with an in-memory workspace, and output
  folders. tabs/order uses it as the first converted test.
- Pin Playwright 1.63.0, the version that browser-runtime uses.
- RUNESTONE_PLUGIN_REPOS names the folder of the sibling plugin
  checkouts for buildPlugins, the menu audit, and the smoke tests.
- buildInstaller restores the version fields after Ctrl+C, keeps the
  backups of each attempt, stops when the browser runtime is not staged,
  and writes the file name instead of absolute paths to host.json.
- buildPlugins clears the staged Table Formulas package before copying.
- plugins/choiceMenus used the wrong Local Autocomplete folder name.
This commit is contained in:
Knotty Wyvern
2026-10-27 19:55:49 -07:00
parent e433bed28e
commit c66ea1ce83
20 changed files with 479 additions and 69 deletions
+12 -2
View File
@@ -23,6 +23,9 @@ if (config.bundle?.windows?.allowDowngrades === true) throw Error('Downgrade pro
const platformConfig = JSON.parse(await fs.readFile(path.join(root, 'src-tauri/tauri.windows.conf.json'), 'utf8'));
if (platformConfig.bundle.windows.allowDowngrades !== false) throw Error('Downgrade protection must remain enabled.');
if (process.platform !== 'win32') throw Error('Build the Windows installer on Windows.');
if (!(await exists(path.join(root, 'src-tauri/browser-engine/RuneStone-Browser.exe')))) {
throw Error('The browser runtime is not staged. Run pnpm browser:stage first. See docs/development.md#built-in-browser-runtime.');
}
const artifactDir = path.join(root, 'src-tauri/target/release/bundle/nsis');
const artifact = path.join(artifactDir, `RuneStone_${next.version}_x64-setup.exe`);
const internalArtifact = path.join(artifactDir, `RuneStone_${next.toolchain}_x64-setup.exe`);
@@ -30,7 +33,8 @@ const releaseDir = path.join(root, 'releases', next.version);
const releaseArtifact = path.join(releaseDir, path.basename(artifact));
const metadataPath = path.join(releaseDir, 'host.json');
for (const file of new Set([artifact, internalArtifact, releaseArtifact, metadataPath])) if (await exists(file)) throw Error('The release file already exists: ' + file);
const staging = path.join(root, 'output/installer-build', next.version);
// Each attempt keeps its own backups, so a later attempt cannot replace them.
const staging = path.join(root, 'output/installer-build', next.version, new Date().toISOString().replaceAll(':', '-'));
await fs.mkdir(staging, { recursive: true });
for (let i = 0; i < files.length; i++) await fs.writeFile(path.join(staging, path.basename(files[i]) + '.before'), before[i]);
let template = await fs.readFile(path.join(root, 'src-tauri/windows/installer.nsi'), 'utf8');
@@ -53,12 +57,17 @@ if (/\[package\.metadata\.runestone\]/.test(cargo)) {
const lock = before[3].replace(/(name = "runestone"\r?\nversion = ")[^"]+"/, `$1${next.toolchain}"`);
const updated = [JSON.stringify(packageJson, null, 2) + '\n', JSON.stringify(config, null, 2) + '\n', cargo, lock];
const env = { ...process.env, GIT_CONFIG_COUNT: '1', GIT_CONFIG_KEY_0: 'safe.directory', GIT_CONFIG_VALUE_0: root.replaceAll('\\', '/') };
// Ctrl+C also stops the child build. Keep this process alive so that the version files are restored.
let interrupted = false;
for (const signal of ['SIGINT', 'SIGTERM', 'SIGHUP']) process.on(signal, () => { interrupted = true; process.exitCode = 130; });
async function run(command, parameters) {
if (interrupted) throw Error('The build was interrupted.');
console.log(command + ' ' + parameters.join(' '));
const code = await new Promise((resolve, reject) => {
const child = spawn(command, parameters, { cwd: root, env, stdio: 'inherit', windowsHide: true });
child.on('error', reject); child.on('exit', resolve);
});
if (interrupted) throw Error('The build was interrupted.');
if (code !== 0) throw Error('The build command failed with exit code ' + code);
}
let complete = false;
@@ -75,7 +84,7 @@ try {
await fs.copyFile(artifact, releaseArtifact, 1);
const bytes = await fs.readFile(releaseArtifact);
const metadata = { version: next.version, toolchainVersion: next.toolchain, windowsVersion: next.windows,
source: releaseArtifact, path: releaseArtifact, bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') };
file: path.basename(releaseArtifact), bytes: bytes.length, sha256: createHash('sha256').update(bytes).digest('hex') };
await fs.writeFile(metadataPath, JSON.stringify(metadata, null, 2) + '\n', { flag: 'wx' });
await fs.unlink(artifact);
complete = true;
@@ -83,6 +92,7 @@ try {
} finally {
if (!complete) {
for (let i = 0; i < files.length; i++) await fs.writeFile(files[i], before[i]);
console.error('The build did not complete. The version fields are restored. Backups: ' + staging);
for (const file of new Set([artifact, internalArtifact, releaseArtifact, metadataPath])) {
if (await exists(file)) await fs.rename(file, path.join(staging, path.basename(file) + '.failed-' + Date.now()));
}