The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Revert "test(lib): extract shared mini test runner for coordination tests"
t0kubetsub757873fb197
diff --git a/tests/lib/github-coordination-branches.test.js b/tests/lib/github-coordination-branches.test.jsindex 75c84836e..5dbae1c43 100644--- a/tests/lib/github-coordination-branches.test.js+++ b/tests/lib/github-coordination-branches.test.js@@ -25,14 +25,24 @@ const {verifyDependenciesClosed,} = require('../../scripts/lib/github-coordination/state');-const { test, banner, section, summary } = require('./helpers/mini-test-runner');+function test(name, fn) {+ try {+ fn();+ console.log(` ✓ ${name}`);+ return true;+ } catch (err) {+ console.log(` ✗ ${name}`);+ console.log(` Error: ${err.message}`);+ return false;+ }+}let passed = 0;let failed = 0;-banner('parsing.js — uncovered branches');+console.log('\n=== parsing.js — uncovered branches ===\n');-section('normalizeBodyForComparison:');+console.log('normalizeBodyForComparison:');if (test('handles null body (uses empty string fallback)', () => {const result = normalizeBodyForComparison(null);@@ -51,7 +61,7 @@ if (test('normalizes lastSyncAt timestamps in body text', () => {assert.ok(!result.includes('2024-01-01'));})) passed++; else failed++;-section('parseStringList:');+console.log('\nparseStringList:');if (test('returns empty array for null', () => {assert.deepStrictEqual(parseStringList(null), []);@@ -73,7 +83,7 @@ if (test('filters out empty parts from double-commas', () => {assert.deepStrictEqual(parseStringList('a,,b'), ['a', 'b']);})) passed++; else failed++;-section('mergeIssueBody — empty body branch:');+console.log('\nmergeIssueBody — empty body branch:');if (test('returns rendered state when issue body is empty string', () => {const state = { status: 'available', schemaVersion: 'v1', kind: 'epic', owner: null, branch: null, validation: 'pending', review: 'not-requested', project: { state: 'backlog', fields: {} }, dependencies: [], tasks: [], labels: [], lastAction: 'sync' };@@ -87,9 +97,9 @@ if (test('returns rendered state when issue body is null', () => {assert.ok(result.includes('ecc-coordination:start'));})) passed++; else failed++;-banner('state.js — uncovered branches');+console.log('\n=== state.js — uncovered branches ===\n');-section('buildIssueStateFromAction — options absent (false branches):');+console.log('buildIssueStateFromAction — options absent (false branches):');const baseIssue = { number: 1, labels: [], body: '' };const baseState = {@@ -123,7 +133,7 @@ if (test('buildIssueStateFromAction — currentState.tasks not array → re-extrassert.ok(Array.isArray(result.tasks));})) passed++; else failed++;-section('desiredLabelsForState — uncovered status/review/validation branches:');+console.log('\ndesiredLabelsForState — uncovered status/review/validation branches:');if (test('includes published label for status "published"', () => {const labels = desiredLabelsForState({ status: 'published' });@@ -150,7 +160,7 @@ if (test('includes review-changes-requested label for review "changes-requested"assert.ok(labels.includes('coordination:review-changes-requested'));})) passed++; else failed++;-section('mapStateToWorkItemStatus — uncovered switch cases:');+console.log('\nmapStateToWorkItemStatus — uncovered switch cases:');if (test('"validated" → "in-progress"', () => {assert.strictEqual(mapStateToWorkItemStatus('validated'), 'in-progress');@@ -172,7 +182,7 @@ if (test('"unknown-state" → "open" (default)', () => {assert.strictEqual(mapStateToWorkItemStatus('unknown-state'), 'open');})) passed++; else failed++;-section('assertIssueClaimable:');+console.log('\nassertIssueClaimable:');if (test('throws when issue is not open', () => {assert.throws(@@ -194,7 +204,7 @@ if (test('does not throw for open, unclaimed issue', () => {});})) passed++; else failed++;-section('verifyDependenciesClosed:');+console.log('\nverifyDependenciesClosed:');if (test('returns empty array when dependencyNumbers is not an array', () => {const result = verifyDependenciesClosed('r/r', null, {}, []);@@ -230,7 +240,7 @@ if (test('warns via stderr and skips when dependency issue is not in allIssues lassert.ok(stderrOutput.includes('dependency issue #5 not found'), `expected stderr warning, got: ${stderrOutput}`);})) passed++; else failed++;-section('defaultCoordinationState — edge branches:');+console.log('\ndefaultCoordinationState — edge branches:');if (test('owner is null when issue has no author', () => {const result = defaultCoordinationState({ number: 1, labels: [] });@@ -254,4 +264,5 @@ if (test('handles null issue', () => {assert.deepStrictEqual(result.tasks, []);})) passed++; else failed++;-summary(passed, failed);+console.log(`\n Results: ${passed} passed, ${failed} failed`);+if (failed > 0) process.exit(1);diff --git a/tests/lib/github-coordination-policy.test.js b/tests/lib/github-coordination-policy.test.jsindex 0420789ef..2143548be 100644--- a/tests/lib/github-coordination-policy.test.js+++ b/tests/lib/github-coordination-policy.test.js@@ -19,7 +19,17 @@ const {DEFAULT_SECTION_MARKER,} = require('../../scripts/lib/github-coordination/policy');-const { test, banner, section, summary } = require('./helpers/mini-test-runner');+function test(name, fn) {+ try {+ fn();+ console.log(` ✓ ${name}`);+ return true;+ } catch (err) {+ console.log(` ✗ ${name}`);+ console.log(` Error: ${err.message}`);+ return false;+ }+}function withTempDir(fn) {const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ecc-policy-test-'));@@ -41,9 +51,9 @@ function writeConfig(tmpDir, content) {let passed = 0;let failed = 0;-banner('Testing github-coordination/policy.js');+console.log('\n=== Testing github-coordination/policy.js ===\n');-section('loadPolicy — no config file:');+console.log('loadPolicy — no config file:');if (test('returns default policy when no config file exists in rootDir', () => {withTempDir(tmpDir => {@@ -64,7 +74,7 @@ if (test('returns default policy when custom configPath does not exist', () => {});})) passed++; else failed++;-section('loadPolicy — configPath argument:');+console.log('\nloadPolicy — configPath argument:');if (test('uses configPath when explicitly provided', () => {withTempDir(tmpDir => {@@ -85,7 +95,7 @@ if (test('falls back to rootDir config file when configPath is null', () => {});})) passed++; else failed++;-section('loadPolicy — invalid JSON:');+console.log('\nloadPolicy — invalid JSON:');if (test('throws on invalid JSON', () => {withTempDir(tmpDir => {@@ -94,7 +104,7 @@ if (test('throws on invalid JSON', () => {});})) passed++; else failed++;-section('loadPolicy — non-object JSON:');+console.log('\nloadPolicy — non-object JSON:');if (test('throws when top-level JSON is null', () => {withTempDir(tmpDir => {@@ -117,7 +127,7 @@ if (test('throws when top-level JSON is a string', () => {});})) passed++; else failed++;-section('loadPolicy — labels merging:');+console.log('\nloadPolicy — labels merging:');if (test('merges labels when parsed.labels is a plain object', () => {withTempDir(tmpDir => {@@ -152,7 +162,7 @@ if (test('falls back to empty labels when parsed.labels is a string', () => {});})) passed++; else failed++;-section('loadPolicy — review merging:');+console.log('\nloadPolicy — review merging:');if (test('merges review when parsed.review is a plain object', () => {withTempDir(tmpDir => {@@ -187,7 +197,7 @@ if (test('falls back when parsed.review is an array', () => {});})) passed++; else failed++;-section('loadPolicy — validation merging:');+console.log('\nloadPolicy — validation merging:');if (test('merges validation when parsed.validation is a plain object', () => {withTempDir(tmpDir => {@@ -205,7 +215,7 @@ if (test('falls back when parsed.validation is not an object', () => {});})) passed++; else failed++;-section('loadPolicy — branchModel merging:');+console.log('\nloadPolicy — branchModel merging:');if (test('merges branchModel when parsed.branchModel is a plain object', () => {withTempDir(tmpDir => {@@ -224,7 +234,7 @@ if (test('falls back when parsed.branchModel is not an object', () => {});})) passed++; else failed++;-section('loadPolicy — project merging:');+console.log('\nloadPolicy — project merging:');if (test('merges project when parsed.project is a plain object', () => {withTempDir(tmpDir => {@@ -251,7 +261,7 @@ if (test('falls back when parsed.project is null', () => {});})) passed++; else failed++;-section('loadPolicy — project.fieldNames merging:');+console.log('\nloadPolicy — project.fieldNames merging:');if (test('merges fieldNames when project.fieldNames is a plain object', () => {withTempDir(tmpDir => {@@ -286,7 +296,7 @@ if (test('falls back when project.fieldNames is an array', () => {});})) passed++; else failed++;-section('loadPolicy — sourcePath:');+console.log('\nloadPolicy — sourcePath:');if (test('sets sourcePath to the resolved config file path', () => {withTempDir(tmpDir => {@@ -296,4 +306,5 @@ if (test('sets sourcePath to the resolved config file path', () => {});})) passed++; else failed++;-summary(passed, failed);+console.log(`\n Results: ${passed} passed, ${failed} failed`);+if (failed > 0) process.exit(1);diff --git a/tests/lib/github-coordination-store.test.js b/tests/lib/github-coordination-store.test.jsindex 58f810cc7..9d23637dc 100644--- a/tests/lib/github-coordination-store.test.js+++ b/tests/lib/github-coordination-store.test.js@@ -16,7 +16,17 @@ const {const { DEFAULT_SCHEMA_VERSION, DEFAULT_POLICY } = require('../../scripts/lib/github-coordination/policy');-const { test, testAsync, banner, section, summary, fatal } = require('./helpers/mini-test-runner');+function test(name, fn) {+ try {+ fn();+ console.log(` ✓ ${name}`);+ return true;+ } catch (err) {+ console.log(` ✗ ${name}`);+ console.log(` Error: ${err.message}`);+ return false;+ }+}function makeStore() {const calls = [];@@ -32,15 +42,15 @@ function makeStore() {let passed = 0;let failed = 0;-banner('Testing github-coordination/store.js');+console.log('\n=== Testing github-coordination/store.js ===\n');-section('epicWorkItemId:');+console.log('epicWorkItemId:');if (test('produces a stable ID from repo and issue number', () => {assert.strictEqual(epicWorkItemId('acme/my-repo', 42), 'github-acme-my-repo-epic-42');})) passed++; else failed++;-section('upsertCoordinationWorkItem — null store:');+console.log('\nupsertCoordinationWorkItem — null store:');if (test('returns null when store is null', () => {const result = upsertCoordinationWorkItem(null, 'r/r', { number: 1 }, {}, 'sync');@@ -52,7 +62,7 @@ if (test('returns null when store is undefined', () => {assert.strictEqual(result, null);})) passed++; else failed++;-section('upsertCoordinationWorkItem — with store:');+console.log('\nupsertCoordinationWorkItem — with store:');if (test('passes schemaVersion from state when present', () => {const store = makeStore();@@ -169,17 +179,30 @@ if (test('sets sessionId to null when options.sessionId absent', () => {assert.strictEqual(store.calls[0].sessionId, null);})) passed++; else failed++;-section('openStore — dbPath: false:');+console.log('\nopenStore — dbPath: false:');async function runAsyncTests() {- if (await testAsync('returns null when dbPath is false', async () => {+ let asyncPassed = 0;+ let asyncFailed = 0;++ try {const result = await openStore({ dbPath: false });assert.strictEqual(result, null);- })) passed++; else failed++;-- summary(passed, failed);+ console.log(' ✓ returns null when dbPath is false');+ asyncPassed++;+ } catch (err) {+ console.log(' ✗ returns null when dbPath is false');+ console.log(` Error: ${err.message}`);+ asyncFailed++;+ }++ const totalPassed = passed + asyncPassed;+ const totalFailed = failed + asyncFailed;+ console.log(`\n Results: ${totalPassed} passed, ${totalFailed} failed`);+ if (totalFailed > 0) process.exit(1);}runAsyncTests().catch(err => {- fatal(`Unexpected async test failure: ${err.message}`);+ console.error(`Unexpected async test failure: ${err.message}`);+ process.exit(1);});diff --git a/tests/lib/helpers/mini-test-runner.js b/tests/lib/helpers/mini-test-runner.jsdeleted file mode 100644index c653d9ed6..000000000--- a/tests/lib/helpers/mini-test-runner.js+++ /dev/null@@ -1,56 +0,0 @@-/**- * Shared mini test harness for standalone tests/lib/*.test.js scripts.- *- * Centralizes test execution and console reporting so individual test- * files don't duplicate the runner or log directly.- */--'use strict';--function report(message) {- console.log(message);-}--function test(name, fn) {- try {- fn();- report(` ✓ ${name}`);- return true;- } catch (err) {- report(` ✗ ${name}`);- report(` Error: ${err.message}`);- return false;- }-}--async function testAsync(name, fn) {- try {- await fn();- report(` ✓ ${name}`);- return true;- } catch (err) {- report(` ✗ ${name}`);- report(` Error: ${err.message}`);- return false;- }-}--function banner(title) {- report(`\n=== ${title} ===`);-}--function section(label) {- report(`\n${label}`);-}--function summary(passed, failed) {- report(`\n Results: ${passed} passed, ${failed} failed`);- if (failed > 0) process.exit(1);-}--function fatal(message) {- console.error(message);- process.exit(1);-}--module.exports = { test, testAsync, banner, section, summary, fatal };