refactor(test): first runBin migration batch (3 of ~36 run() duplicates)

explain-level-config, benchmark-cli, evidence move onto the shared
helper; each file's remaining special-case spawnSync sites (raw-buffer
probes, env-scrub probes) stay put deliberately. 55/55 green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-08-29 05:31:02 +00:00
co-authored by Claude Fable 5
parent 1055561cae
commit 6ef8aaba65
3 changed files with 15 additions and 25 deletions
+5 -14
View File
@@ -12,7 +12,8 @@ import { describe, test, expect, beforeEach, afterEach } from 'bun:test';
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';
import { spawnSync } from 'child_process';
import { runBin } from './helpers/run-bin';
const ROOT = path.resolve(import.meta.dir, '..');
const BIN_CONFIG = path.join(ROOT, 'bin', 'gstack-config');
@@ -28,19 +29,9 @@ afterEach(() => {
});
function run(...args: string[]): { stdout: string; stderr: string; status: number } {
// gstack-config precedence is `${GSTACK_HOME:-${GSTACK_STATE_DIR:-$HOME/.gstack}}`,
// so GSTACK_HOME from the developer's parent env wins over the test's
// GSTACK_STATE_DIR. Override both to isolate from the real ~/.gstack.
const res = spawnSync(BIN_CONFIG, args, {
env: { ...process.env, GSTACK_STATE_DIR: tmpHome, GSTACK_HOME: tmpHome },
encoding: 'utf-8',
cwd: ROOT,
});
return {
stdout: (res.stdout ?? '').trim(),
stderr: (res.stderr ?? '').trim(),
status: res.status ?? -1,
};
// runBin's gstackHome sets GSTACK_HOME + GSTACK_STATE_DIR together — the
// config-precedence isolation this file used to document by hand.
return runBin(BIN_CONFIG, args, { gstackHome: tmpHome, cwd: ROOT, trim: true });
}
describe('gstack-config explain_level', () => {