Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: init-based Windows regressions use a real-path GBRAIN_HOME and print init stderr on failure

garrytane9119c2d3b94
diff --git a/test/auth-local-writer-dry-run.test.ts b/test/auth-local-writer-dry-run.test.ts
index 2ec3129b52..22b1db1e2e 100644
--- a/test/auth-local-writer-dry-run.test.ts
+++ b/test/auth-local-writer-dry-run.test.ts
@@ -8,12 +8,12 @@
*/
import { afterAll, expect, test } from 'bun:test';
import { spawnSync } from 'node:child_process';
-import { mkdtempSync, rmSync } from 'node:fs';
+import { mkdtempSync, realpathSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { validateCommandFlags } from '../src/cli.ts';
-const home = mkdtempSync(join(tmpdir(), 'gbrain-local-writer-dry-run-'));
+const home = realpathSync(mkdtempSync(join(tmpdir(), 'gbrain-local-writer-dry-run-')));
afterAll(() => rmSync(home, { recursive: true, force: true }));
const CLI = join(import.meta.dir, '..', 'src', 'cli.ts');
function gbrain(args: string[]) {
@@ -30,7 +30,8 @@ test('the validator accepts --dry-run on every auth subcommand that parses it',
});
test('auth local-writer register --replace --dry-run previews the regrant and changes nothing', () => {
- expect(gbrain(['init', '--pglite', '--non-interactive', '--no-embedding']).status).toBe(0);
+ const init = gbrain(['init', '--pglite', '--non-interactive', '--no-embedding']);
+ expect({ status: init.status, stderr: init.status === 0 ? '' : init.stderr }).toEqual({ status: 0, stderr: '' });
const before = JSON.parse(gbrain(['auth', 'local-writer', 'list', '--json']).stdout);
const preview = gbrain(['auth', 'local-writer', 'register', 'cli', '--source-ids', 'default', '--replace', '--dry-run', '--json']);
expect(preview.stderr).not.toContain('unknown flag');
diff --git a/test/init-packaged-skills-native.test.ts b/test/init-packaged-skills-native.test.ts
index deb1ea061d..0ef8acf471 100644
--- a/test/init-packaged-skills-native.test.ts
+++ b/test/init-packaged-skills-native.test.ts
@@ -8,11 +8,11 @@
*/
import { afterAll, expect, test } from 'bun:test';
import { spawnSync } from 'node:child_process';
-import { mkdtempSync, readdirSync, rmSync, statSync } from 'node:fs';
+import { mkdtempSync, realpathSync, readdirSync, rmSync, statSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
-const home = mkdtempSync(join(tmpdir(), 'gbrain-init-skills-'));
+const home = realpathSync(mkdtempSync(join(tmpdir(), 'gbrain-init-skills-')));
afterAll(() => rmSync(home, { recursive: true, force: true }));
function skillFiles(dir: string): string[] {
@@ -30,8 +30,7 @@ test('fresh PGLite init publishes the packaged memory skills on this platform',
for (const key of ['OPENAI_API_KEY', 'ANTHROPIC_API_KEY', 'VOYAGE_API_KEY', 'DATABASE_URL', 'GBRAIN_DATABASE_URL']) delete env[key];
const result = spawnSync(process.execPath, ['run', join(import.meta.dir, '..', 'src', 'cli.ts'), 'init', '--pglite', '--non-interactive', '--no-embedding'],
{ env, encoding: 'utf8', timeout: 120_000 });
- expect(`${result.stderr}`).not.toContain('Skill publication requires bounded regular files');
- expect(result.status).toBe(0);
+ expect({ status: result.status, stderr: result.status === 0 ? '' : result.stderr }).toEqual({ status: 0, stderr: '' });
const skills = skillFiles(join(home, '.gbrain', 'content')).map(path => path.split(/[\\/]/).at(-2)).sort();
expect(skills).toEqual(expect.arrayContaining(['memory-recall']));
}, 150_000);