G6: gstack-ios-qa-daemon --help prints usage instead of starting the daemon (#1932)

Co-authored-by: maxpetrusenkoagent <max.petrusenko.agent@gmail.com>
This commit is contained in:
garrytanandmaxpetrusenkoagent committed 2026-10-03 21:12:37 +00:00
1 parent 5bcc4b5d2c
commit 2ffeba529b
2 files changed
+67

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
/**
* G6 rider (#1932): `gstack-ios-qa-daemon --help` started the daemon (it
* exec'd bun with every argument). Help must print and exit without ever
* reaching the runtime. A stub `bun` first on PATH records any launch.
*/
import { describe, expect, test } from 'bun:test';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
const ROOT = path.resolve(import.meta.dir, '..');
const DAEMON = `${ROOT}/bin/gstack-ios-qa-daemon`;
describe('gstack-ios-qa-daemon --help', () => {
for (const flag of ['--help', '-h']) {
test(`${flag} prints usage and never starts the daemon`, () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'ios-qa-daemon-help-'));
try {
const marker = path.join(dir, 'daemon-started');
fs.writeFileSync(path.join(dir, 'bun'), `#!/usr/bin/env bash\necho started > "${marker}"\n`, { mode: 0o755 });
const r = Bun.spawnSync(['bash', DAEMON, flag], {
env: { ...process.env, PATH: `${dir}${path.delimiter}${process.env.PATH ?? ''}`, HOME: dir },
stdout: 'pipe',
stderr: 'pipe',
timeout: 10_000,
});
expect(r.exitCode).toBe(0);
const out = r.stdout.toString();
expect(out).toContain('Usage:');
expect(out).toContain('--tailnet');
expect(out).toContain('GSTACK_IOS_DAEMON_PORT');
expect(fs.existsSync(marker)).toBe(false);
} finally {
fs.rmSync(dir, { recursive: true, force: true });
}
});
}
});