Skip to content

Commit 2672477

Browse files
committed
test(cli): cover bash syntax validation
1 parent bf6d9d3 commit 2672477

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

src/cli/index.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ describe('CLI Output Option', () => {
107107
});
108108
});
109109

110+
describe('CLI Bash Syntax Validation', () => {
111+
it('should fail compilation when generated script has bash syntax errors', () => {
112+
const command = 'node dist/cli/index.js compile tests/workflows/invalid-bash-test.yaml';
113+
114+
try {
115+
execSync(command, { encoding: 'utf8' });
116+
expect(false).toBe(true);
117+
} catch (error: any) {
118+
const errorOutput = error.stderr?.toString() ?? error.stdout?.toString() ?? error.message;
119+
expect(errorOutput).toContain('Compilation failed:');
120+
expect(errorOutput).toContain('Bash syntax validation failed');
121+
}
122+
});
123+
});
124+
110125
describe('CLI DSL Command', () => {
111126
it('should execute dsl command and show DSL structure', () => {
112127
const command = 'node dist/cli/index.js dsl';
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
workflow:
2+
name: 'Invalid Bash'
3+
description: 'Workflow with intentionally invalid bash to test syntax validation'
4+
5+
graph:
6+
nodes:
7+
- id: 'start'
8+
type: 'start'
9+
data:
10+
title: 'Start'
11+
12+
- id: 'invalid_command'
13+
type: 'code'
14+
data:
15+
title: 'Invalid Command'
16+
description: 'Command with unterminated quote'
17+
command: 'echo "unterminated'
18+
19+
- id: 'end'
20+
type: 'end'
21+
data:
22+
title: 'End'
23+
24+
edges:
25+
- id: 'start_to_invalid'
26+
source: 'start'
27+
target: 'invalid_command'
28+
29+
- id: 'invalid_to_end'
30+
source: 'invalid_command'
31+
target: 'end'

0 commit comments

Comments
 (0)