Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
ts 34 lines 1.33 KB
Raw
1 // Guards the CLI's command test layout: every command module under
2 // src/commands/ must have a test at its mirrored path under test/src/commands/
3 // (drop `commands/` segments, swap `.cmd.ts` for `.cmd.test.ts`), and every
4 // `*.cmd.test.ts` must resolve to a command. Group entries (`<dir>.cmd.ts`,
5 // `root-<dir>.cmd.ts`) are covered by root-help-consistency.test.ts.
6 // COMMAND_TEST_EXEMPTIONS in command-tests.ts lists untested commands; it only
7 // shrinks, since an exemption whose test now exists fails as stale.
8 //
9 // Usage:
10 // tsx ./scripts/validate-command-tests.ts
11 import * as path from 'node:path';
12
13 import {
14 checkCommandTests,
15 collectCommandTests,
16 COMMAND_TEST_EXEMPTIONS,
17 isGroupEntry,
18 } from './command-tests';
19
20 const scriptDir = import.meta.dirname ?? path.dirname(new URL(import.meta.url).pathname);
21 const packageRoot = path.resolve(scriptDir, '..');
22
23 const { commands, tests } = collectCommandTests(packageRoot);
24 const errors = checkCommandTests({ commands, tests, exemptions: COMMAND_TEST_EXEMPTIONS });
25
26 if (errors.length > 0) {
27 console.error(errors.join('\n'));
28 process.exit(1);
29 }
30
31 const checked = commands.filter(command => !isGroupEntry(command, commands)).length;
32 console.log(
33 `command tests OK: ${checked} commands checked against ${tests.length} test files, ${COMMAND_TEST_EXEMPTIONS.length} exemptions remaining.`
34 );