MCPcopy
hub / github.com/affaan-m/ECC / runTests

Function runTests

tests/scripts/harness-audit.test.js:72–665  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

70}
71
72function runTests() {
73 console.log('\n=== Testing harness-audit.js ===\n');
74
75 let passed = 0;
76 let failed = 0;
77
78 if (test('parseArgs accepts supported forms and rejects invalid arguments', () => {
79 const rootDir = createTempDir('harness-audit-args-root-');
80
81 try {
82 assert.strictEqual(parseArgs(['node', 'script', '--help']).help, true);
83 assert.strictEqual(parseArgs(['node', 'script', '-h']).help, true);
84
85 const spaced = parseArgs(['node', 'script', '--format', 'json', '--scope', 'skills', '--root', rootDir]);
86 assert.strictEqual(spaced.format, 'json');
87 assert.strictEqual(spaced.scope, 'skills');
88 assert.strictEqual(spaced.root, path.resolve(rootDir));
89
90 const equals = parseArgs(['node', 'script', '--format=json', '--scope=hooks', `--root=${rootDir}`]);
91 assert.strictEqual(equals.format, 'json');
92 assert.strictEqual(equals.scope, 'hooks');
93 assert.strictEqual(equals.root, path.resolve(rootDir));
94
95 assert.strictEqual(parseArgs(['node', 'script', 'commands']).scope, 'commands');
96 assert.strictEqual(parseArgs(['node', 'script', '--scope']).scope, 'repo');
97 assert.throws(() => parseArgs(['node', 'script', '--format', 'xml']), /Invalid format: xml/);
98 assert.throws(() => parseArgs(['node', 'script', '--scope', 'bad-scope']), /Invalid scope: bad-scope/);
99 assert.throws(() => parseArgs(['node', 'script', '--unknown']), /Unknown argument: --unknown/);
100 } finally {
101 cleanup(rootDir);
102 }
103 })) passed++; else failed++;
104
105 if (test('cli help exits cleanly and invalid cli args exit with stderr', () => {
106 const help = runProcess(['--help']);
107 assert.strictEqual(help.status, 0);
108 assert.strictEqual(help.stderr, '');
109 assert.ok(help.stdout.includes('Usage: node scripts/harness-audit.js'));
110 assert.ok(help.stdout.includes('Deterministic harness audit'));
111
112 const invalid = runProcess(['--format', 'xml']);
113 assert.strictEqual(invalid.status, 1);
114 assert.strictEqual(invalid.stdout, '');
115 assert.ok(invalid.stderr.includes('Error: Invalid format: xml. Use text or json.'));
116 })) passed++; else failed++;
117
118 if (test('json output is deterministic between runs', () => {
119 const first = run(['repo', '--format', 'json']);
120 const second = run(['repo', '--format', 'json']);
121
122 assert.strictEqual(first, second);
123 })) passed++; else failed++;
124
125 if (test('report includes bounded scores and fixed categories', () => {
126 const parsed = JSON.parse(run(['repo', '--format', 'json']));
127
128 assert.strictEqual(parsed.deterministic, true);
129 assert.strictEqual(parsed.rubric_version, '2026-05-19');

Callers 1

Calls 10

probeFunction · 0.85
findPluginInstallFunction · 0.85
compareVersionDescFunction · 0.85
okMethod · 0.80
testFunction · 0.70
createTempDirFunction · 0.70
cleanupFunction · 0.70
runProcessFunction · 0.70
runFunction · 0.70
parseArgsFunction · 0.50

Tested by

no test coverage detected