Skip to content

Commit c6226de

Browse files
test: improve error messages in CLI integration test assertions
Capture stderr output and include it in assertion failure messages across all CLI integration tests for better debugging when tests fail. This ensures that diagnostic information from failed commands is visible when assertions fail. Changes: - Replace unused `_stderr` with captured `stderr` variable in test helper calls - Append stderr and stdout to assertion messages for all CLI commands - Applies to all integration test files: cli_executables, enrichments, websets, and webset_items tests These changes maintain existing test logic while improving observability of failures. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent cfd2956 commit c6226de

4 files changed

Lines changed: 89 additions & 89 deletions

File tree

test/integration/cli_executables_test.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ def run_executable(command)
1717

1818
# Main dispatcher executable
1919
def test_exa_ai_help
20-
stdout, _stderr, status = run_executable("bundle exec exe/exa-ai --help")
20+
stdout, stderr, status = run_executable("bundle exec exe/exa-ai --help")
2121

22-
assert status.success?, "exa-ai --help should exit successfully"
22+
assert status.success?, "exa-ai --help should exit successfully. stderr: #{stderr}, stdout: #{stdout}"
2323
assert_includes stdout, "Exa CLI"
2424
assert_includes stdout, "Core Search:"
2525
assert_includes stdout, "search"
@@ -28,27 +28,27 @@ def test_exa_ai_help
2828
end
2929

3030
def test_exa_ai_version
31-
stdout, _stderr, status = run_executable("bundle exec exe/exa-ai --version")
31+
stdout, stderr, status = run_executable("bundle exec exe/exa-ai --version")
3232

33-
assert status.success?, "exa-ai --version should exit successfully"
33+
assert status.success?, "exa-ai --version should exit successfully. stderr: #{stderr}, stdout: #{stdout}"
3434
assert_match(/\d+\.\d+\.\d+/, stdout)
3535
end
3636

3737
# Search command
3838
def test_search_help
39-
stdout, _stderr, status = run_executable("bundle exec exe/exa-ai-search --help")
39+
stdout, stderr, status = run_executable("bundle exec exe/exa-ai-search --help")
4040

41-
assert status.success?, "exa-ai-search --help should exit successfully"
41+
assert status.success?, "exa-ai-search --help should exit successfully. stderr: #{stderr}, stdout: #{stdout}"
4242
assert_includes stdout, "Usage:"
4343
assert_includes stdout, "search"
4444
assert_includes stdout, "QUERY"
4545
end
4646

4747
# Answer command
4848
def test_answer_help
49-
stdout, _stderr, status = run_executable("bundle exec exe/exa-ai-answer --help")
49+
stdout, stderr, status = run_executable("bundle exec exe/exa-ai-answer --help")
5050

51-
assert status.success?, "exa-ai-answer --help should exit successfully"
51+
assert status.success?, "exa-ai-answer --help should exit successfully. stderr: #{stderr}, stdout: #{stdout}"
5252
assert_includes stdout, "Usage:"
5353
assert_includes stdout, "answer"
5454
assert_includes stdout, "QUERY"
@@ -58,65 +58,65 @@ def test_answer_help
5858

5959
# Context command
6060
def test_context_help
61-
stdout, _stderr, status = run_executable("bundle exec exe/exa-ai-context --help")
61+
stdout, stderr, status = run_executable("bundle exec exe/exa-ai-context --help")
6262

63-
assert status.success?, "exa-ai-context --help should exit successfully"
63+
assert status.success?, "exa-ai-context --help should exit successfully. stderr: #{stderr}, stdout: #{stdout}"
6464
assert_includes stdout, "Usage:"
6565
assert_includes stdout, "context"
6666
assert_includes stdout, "query"
6767
end
6868

6969
# Get contents command
7070
def test_get_contents_help
71-
stdout, _stderr, status = run_executable("bundle exec exe/exa-ai-get-contents --help")
71+
stdout, stderr, status = run_executable("bundle exec exe/exa-ai-get-contents --help")
7272

73-
assert status.success?, "exa-ai-get-contents --help should exit successfully"
73+
assert status.success?, "exa-ai-get-contents --help should exit successfully. stderr: #{stderr}, stdout: #{stdout}"
7474
assert_includes stdout, "Usage:"
7575
assert_includes stdout, "get-contents"
7676
end
7777

7878
# Research start command
7979
def test_research_start_help
80-
stdout, _stderr, status = run_executable("bundle exec exe/exa-ai-research-start --help")
80+
stdout, stderr, status = run_executable("bundle exec exe/exa-ai-research-start --help")
8181

82-
assert status.success?, "exa-ai-research-start --help should exit successfully"
82+
assert status.success?, "exa-ai-research-start --help should exit successfully. stderr: #{stderr}, stdout: #{stdout}"
8383
assert_includes stdout, "Usage:"
8484
assert_includes stdout, "research-start"
8585
assert_includes stdout, "--instructions"
8686
end
8787

8888
# Research get command
8989
def test_research_get_help
90-
stdout, _stderr, status = run_executable("bundle exec exe/exa-ai-research-get --help")
90+
stdout, stderr, status = run_executable("bundle exec exe/exa-ai-research-get --help")
9191

92-
assert status.success?, "exa-ai-research-get --help should exit successfully"
92+
assert status.success?, "exa-ai-research-get --help should exit successfully. stderr: #{stderr}, stdout: #{stdout}"
9393
assert_includes stdout, "Usage:"
9494
assert_includes stdout, "research-get"
9595
assert_includes stdout, "research_id"
9696
end
9797

9898
# Research list command
9999
def test_research_list_help
100-
stdout, _stderr, status = run_executable("bundle exec exe/exa-ai-research-list --help")
100+
stdout, stderr, status = run_executable("bundle exec exe/exa-ai-research-list --help")
101101

102-
assert status.success?, "exa-ai-research-list --help should exit successfully"
102+
assert status.success?, "exa-ai-research-list --help should exit successfully. stderr: #{stderr}, stdout: #{stdout}"
103103
assert_includes stdout, "Usage:"
104104
assert_includes stdout, "research-list"
105105
end
106106

107107
# Test that main dispatcher can route to subcommands
108108
def test_dispatcher_routes_to_search_help
109-
stdout, _stderr, status = run_executable("bundle exec exe/exa-ai search --help")
109+
stdout, stderr, status = run_executable("bundle exec exe/exa-ai search --help")
110110

111-
assert status.success?, "exa-ai search --help should route correctly"
111+
assert status.success?, "exa-ai search --help should route correctly. stderr: #{stderr}, stdout: #{stdout}"
112112
assert_includes stdout, "Usage:"
113113
assert_includes stdout, "search"
114114
end
115115

116116
def test_dispatcher_routes_to_answer_help
117-
stdout, _stderr, status = run_executable("bundle exec exe/exa-ai answer --help")
117+
stdout, stderr, status = run_executable("bundle exec exe/exa-ai answer --help")
118118

119-
assert status.success?, "exa-ai answer --help should route correctly"
119+
assert status.success?, "exa-ai answer --help should route correctly. stderr: #{stderr}, stdout: #{stdout}"
120120
assert_includes stdout, "Usage:"
121121
assert_includes stdout, "answer"
122122
end
@@ -125,7 +125,7 @@ def test_dispatcher_routes_to_answer_help
125125
def test_invalid_command_shows_error
126126
stdout, stderr, status = run_executable("bundle exec exe/exa-ai invalid-command")
127127

128-
refute status.success?, "Invalid command should exit with error"
128+
refute status.success?, "Invalid command should exit with error. stderr: #{stderr}, stdout: #{stdout}"
129129
# Error message could be in stdout or stderr
130130
combined_output = stdout + stderr
131131
assert_includes combined_output, "Unknown command"

test/integration/enrichments_cli_integration_test.rb

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ def test_enrichment_create_text_format
7777
"--format text " \
7878
"--output-format json"
7979

80-
stdout, _stderr, status = run_command(command)
80+
stdout, stderr, status = run_command(command)
8181

82-
assert status.success?, "enrichment-create should succeed"
82+
assert status.success?, "enrichment-create should succeed. stderr: #{stderr}, stdout: #{stdout}"
8383
result = parse_json_output(stdout)
8484
track_enrichment(webset_id, result["id"])
8585

@@ -114,9 +114,9 @@ def test_enrichment_create_options_format
114114
"--options '#{JSON.generate(options)}' " \
115115
"--output-format json"
116116

117-
stdout, _stderr, status = run_command(command)
117+
stdout, stderr, status = run_command(command)
118118

119-
assert status.success?, "enrichment-create with options should succeed"
119+
assert status.success?, "enrichment-create with options should succeed. stderr: #{stderr}, stdout: #{stdout}"
120120
result = parse_json_output(stdout)
121121
track_enrichment(webset_id, result["id"])
122122

@@ -154,9 +154,9 @@ def test_enrichment_create_options_from_file
154154
"--options @#{options_file.path} " \
155155
"--output-format json"
156156

157-
stdout, _stderr, status = run_command(command)
157+
stdout, stderr, status = run_command(command)
158158

159-
assert status.success?, "enrichment-create with options file should succeed"
159+
assert status.success?, "enrichment-create with options file should succeed. stderr: #{stderr}, stdout: #{stdout}"
160160
result = parse_json_output(stdout)
161161
track_enrichment(webset_id, result["id"])
162162

@@ -190,9 +190,9 @@ def test_enrichment_get
190190
# Get the enrichment
191191
command = "bundle exec exe/exa-ai enrichment-get #{webset_id} #{enrichment_id} --output-format json"
192192

193-
stdout, _stderr, status = run_command(command)
193+
stdout, stderr, status = run_command(command)
194194

195-
assert status.success?, "enrichment-get should succeed"
195+
assert status.success?, "enrichment-get should succeed. stderr: #{stderr}, stdout: #{stdout}"
196196
result = parse_json_output(stdout)
197197

198198
assert_equal enrichment_id, result["id"]
@@ -224,9 +224,9 @@ def test_enrichment_list
224224
# List enrichments
225225
command = "bundle exec exe/exa-ai enrichment-list #{webset_id} --output-format json"
226226

227-
stdout, _stderr, status = run_command(command)
227+
stdout, stderr, status = run_command(command)
228228

229-
assert status.success?, "enrichment-list should succeed"
229+
assert status.success?, "enrichment-list should succeed. stderr: #{stderr}, stdout: #{stdout}"
230230
result = parse_json_output(stdout)
231231

232232
# List response has data array
@@ -260,9 +260,9 @@ def test_enrichment_update
260260
"--description 'Updated description' " \
261261
"--output-format json"
262262

263-
stdout, _stderr, status = run_command(command)
263+
stdout, stderr, status = run_command(command)
264264

265-
assert status.success?, "enrichment-update should succeed"
265+
assert status.success?, "enrichment-update should succeed. stderr: #{stderr}, stdout: #{stdout}"
266266
result = parse_json_output(stdout)
267267

268268
assert_equal enrichment_id, result["id"]
@@ -294,9 +294,9 @@ def test_enrichment_delete
294294
command = "bundle exec exe/exa-ai enrichment-delete #{webset_id} #{enrichment_id} " \
295295
"--force --output-format json"
296296

297-
stdout, _stderr, status = run_command(command)
297+
stdout, stderr, status = run_command(command)
298298

299-
assert status.success?, "enrichment-delete should succeed"
299+
assert status.success?, "enrichment-delete should succeed. stderr: #{stderr}, stdout: #{stdout}"
300300
result = parse_json_output(stdout)
301301

302302
# API returns the enrichment object after deletion
@@ -328,9 +328,9 @@ def test_enrichment_cancel
328328
# Cancel the enrichment
329329
command = "bundle exec exe/exa-ai enrichment-cancel #{webset_id} #{enrichment_id} --output-format json"
330330

331-
stdout, _stderr, status = run_command(command)
331+
stdout, stderr, status = run_command(command)
332332

333-
assert status.success?, "enrichment-cancel should succeed"
333+
assert status.success?, "enrichment-cancel should succeed. stderr: #{stderr}, stdout: #{stdout}"
334334
result = parse_json_output(stdout)
335335

336336
assert_equal enrichment_id, result["id"]
@@ -356,9 +356,9 @@ def test_enrichment_create_pretty_format
356356
"--format url " \
357357
"--output-format pretty"
358358

359-
stdout, _stderr, status = run_command(command)
359+
stdout, stderr, status = run_command(command)
360360

361-
assert status.success?, "enrichment-create with pretty format should succeed"
361+
assert status.success?, "enrichment-create with pretty format should succeed. stderr: #{stderr}, stdout: #{stdout}"
362362
# Pretty format outputs human-readable text, not JSON
363363
assert_includes stdout, "Enrichment ID:"
364364
assert_includes stdout, "Webset ID:"
@@ -381,7 +381,7 @@ def test_enrichment_create_invalid_format
381381

382382
stdout, stderr, status = run_command(command)
383383

384-
refute status.success?, "enrichment-create with invalid format should fail"
384+
refute status.success?, "enrichment-create with invalid format should fail. stderr: #{stderr}, stdout: #{stdout}"
385385
combined = stdout + stderr
386386
assert_includes combined.downcase, "error"
387387
end
@@ -394,7 +394,7 @@ def test_enrichment_create_missing_description
394394

395395
stdout, stderr, status = run_command(command)
396396

397-
refute status.success?, "enrichment-create without description should fail"
397+
refute status.success?, "enrichment-create without description should fail. stderr: #{stderr}, stdout: #{stdout}"
398398
combined = stdout + stderr
399399
assert_includes combined, "description"
400400
end
@@ -410,16 +410,16 @@ def test_enrichment_create_options_without_options
410410

411411
stdout, stderr, status = run_command(command)
412412

413-
refute status.success?, "enrichment-create with options format but no options should fail"
413+
refute status.success?, "enrichment-create with options format but no options should fail. stderr: #{stderr}, stdout: #{stdout}"
414414
combined = stdout + stderr
415415
assert_includes combined.downcase, "options"
416416
end
417417

418418
# Test help output for each command
419419
def test_enrichment_create_help
420-
stdout, _stderr, status = run_command("bundle exec exe/exa-ai enrichment-create --help")
420+
stdout, stderr, status = run_command("bundle exec exe/exa-ai enrichment-create --help")
421421

422-
assert status.success?, "enrichment-create --help should succeed"
422+
assert status.success?, "enrichment-create --help should succeed. stderr: #{stderr}, stdout: #{stdout}"
423423
assert_includes stdout, "Usage:"
424424
assert_includes stdout, "webset_id"
425425
assert_includes stdout, "--description"
@@ -428,46 +428,46 @@ def test_enrichment_create_help
428428
end
429429

430430
def test_enrichment_get_help
431-
stdout, _stderr, status = run_command("bundle exec exe/exa-ai enrichment-get --help")
431+
stdout, stderr, status = run_command("bundle exec exe/exa-ai enrichment-get --help")
432432

433-
assert status.success?, "enrichment-get --help should succeed"
433+
assert status.success?, "enrichment-get --help should succeed. stderr: #{stderr}, stdout: #{stdout}"
434434
assert_includes stdout, "Usage:"
435435
assert_includes stdout, "webset_id"
436436
assert_includes stdout, "enrichment_id"
437437
end
438438

439439
def test_enrichment_list_help
440-
stdout, _stderr, status = run_command("bundle exec exe/exa-ai enrichment-list --help")
440+
stdout, stderr, status = run_command("bundle exec exe/exa-ai enrichment-list --help")
441441

442-
assert status.success?, "enrichment-list --help should succeed"
442+
assert status.success?, "enrichment-list --help should succeed. stderr: #{stderr}, stdout: #{stdout}"
443443
assert_includes stdout, "Usage:"
444444
assert_includes stdout, "webset_id"
445445
end
446446

447447
def test_enrichment_update_help
448-
stdout, _stderr, status = run_command("bundle exec exe/exa-ai enrichment-update --help")
448+
stdout, stderr, status = run_command("bundle exec exe/exa-ai enrichment-update --help")
449449

450-
assert status.success?, "enrichment-update --help should succeed"
450+
assert status.success?, "enrichment-update --help should succeed. stderr: #{stderr}, stdout: #{stdout}"
451451
assert_includes stdout, "Usage:"
452452
assert_includes stdout, "webset_id"
453453
assert_includes stdout, "enrichment_id"
454454
assert_includes stdout, "--description"
455455
end
456456

457457
def test_enrichment_delete_help
458-
stdout, _stderr, status = run_command("bundle exec exe/exa-ai enrichment-delete --help")
458+
stdout, stderr, status = run_command("bundle exec exe/exa-ai enrichment-delete --help")
459459

460-
assert status.success?, "enrichment-delete --help should succeed"
460+
assert status.success?, "enrichment-delete --help should succeed. stderr: #{stderr}, stdout: #{stdout}"
461461
assert_includes stdout, "Usage:"
462462
assert_includes stdout, "webset_id"
463463
assert_includes stdout, "enrichment_id"
464464
assert_includes stdout, "--force"
465465
end
466466

467467
def test_enrichment_cancel_help
468-
stdout, _stderr, status = run_command("bundle exec exe/exa-ai enrichment-cancel --help")
468+
stdout, stderr, status = run_command("bundle exec exe/exa-ai enrichment-cancel --help")
469469

470-
assert status.success?, "enrichment-cancel --help should succeed"
470+
assert status.success?, "enrichment-cancel --help should succeed. stderr: #{stderr}, stdout: #{stdout}"
471471
assert_includes stdout, "Usage:"
472472
assert_includes stdout, "webset_id"
473473
assert_includes stdout, "enrichment_id"

0 commit comments

Comments
 (0)