|
3 | 3 |
|
4 | 4 | describe "Junit annotate plugin parser" do
|
5 | 5 | it "handles no failures" do
|
6 |
| - output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/no-test-failures/") |
| 6 | + stdout, stderr, status = Open3.capture3("#{__dir__}/../bin/annotate", "#{__dir__}/no-test-failures/") |
7 | 7 |
|
8 |
| - assert_equal <<~OUTPUT, output |
| 8 | + assert_equal stderr, <<~OUTPUT |
9 | 9 | Parsing junit-1.xml
|
10 | 10 | Parsing junit-2.xml
|
11 | 11 | Parsing junit-3.xml
|
12 | 12 | --- ✍️ Preparing annotation
|
13 |
| - 8 testcases found |
14 |
| - There were no failures/errors 🙌 |
| 13 | + OUTPUT |
| 14 | + |
| 15 | + assert_equal stdout, <<~OUTPUT |
| 16 | + Failures: 0 |
| 17 | + Errors: 0 |
| 18 | + Total tests: 8 |
15 | 19 | OUTPUT
|
16 | 20 |
|
17 | 21 | assert_equal 0, status.exitstatus
|
18 | 22 | end
|
19 | 23 |
|
20 | 24 | it "handles failures across multiple files" do
|
21 |
| - output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/two-test-failures/") |
| 25 | + stdout, stderr, status = Open3.capture3("#{__dir__}/../bin/annotate", "#{__dir__}/two-test-failures/") |
22 | 26 |
|
23 |
| - assert_equal <<~OUTPUT, output |
| 27 | + assert_equal stderr, <<~OUTPUT |
24 | 28 | Parsing junit-1.xml
|
25 | 29 | Parsing junit-2.xml
|
26 | 30 | Parsing junit-3.xml
|
27 | 31 | --- ✍️ Preparing annotation
|
28 |
| - 6 testcases found |
29 |
| - There are 4 failures/errors 😭 |
30 |
| - 4 failures: |
| 32 | + OUTPUT |
| 33 | + |
| 34 | + assert_equal stdout, <<~OUTPUT |
| 35 | + Failures: 4 |
| 36 | + Errors: 0 |
| 37 | + Total tests: 6 |
31 | 38 |
|
32 | 39 | <details>
|
33 | 40 | <summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
|
|
110 | 117 | end
|
111 | 118 |
|
112 | 119 | it "handles failures and errors across multiple files" do
|
113 |
| - output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/test-failure-and-error/") |
| 120 | + stdout, stderr, status = Open3.capture3("#{__dir__}/../bin/annotate", "#{__dir__}/test-failure-and-error/") |
114 | 121 |
|
115 |
| - assert_equal <<~OUTPUT, output |
| 122 | + assert_equal stderr, <<~OUTPUT |
116 | 123 | Parsing junit-1.xml
|
117 | 124 | Parsing junit-2.xml
|
118 | 125 | Parsing junit-3.xml
|
119 | 126 | --- ✍️ Preparing annotation
|
120 |
| - 6 testcases found |
121 |
| - There are 4 failures/errors 😭 |
122 |
| - 2 failures and 2 errors: |
123 |
| - |
| 127 | + OUTPUT |
| 128 | + |
| 129 | + assert_equal stdout, <<~OUTPUT |
| 130 | + Failures: 2 |
| 131 | + Errors: 2 |
| 132 | + Total tests: 6 |
| 133 | +
|
124 | 134 | <details>
|
125 | 135 | <summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
|
126 | 136 |
|
|
202 | 212 | end
|
203 | 213 |
|
204 | 214 | it "accepts custom regex filename patterns for job id" do
|
205 |
| - output, status = Open3.capture2e("env", "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN=junit-(.*)-custom-pattern.xml", "#{__dir__}/../bin/annotate", "#{__dir__}/custom-job-uuid-pattern/") |
| 215 | + stdout, stderr, status = Open3.capture3("env", "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_JOB_UUID_FILE_PATTERN=junit-(.*)-custom-pattern.xml", "#{__dir__}/../bin/annotate", "#{__dir__}/custom-job-uuid-pattern/") |
206 | 216 |
|
207 |
| - assert_equal <<~OUTPUT, output |
| 217 | + assert_equal stderr, <<~OUTPUT |
208 | 218 | Parsing junit-123-456-custom-pattern.xml
|
209 | 219 | --- ✍️ Preparing annotation
|
210 |
| - 2 testcases found |
211 |
| - There is 1 failure/error 😭 |
212 |
| - 1 failure: |
| 220 | + OUTPUT |
| 221 | + |
| 222 | + assert_equal stdout, <<~OUTPUT |
| 223 | + Failures: 1 |
| 224 | + Errors: 0 |
| 225 | + Total tests: 2 |
213 | 226 |
|
214 | 227 | <details>
|
215 | 228 | <summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
|
|
235 | 248 | end
|
236 | 249 |
|
237 | 250 | it "uses the file path instead of classname for annotation content when specified" do
|
238 |
| - output, status = Open3.capture2e("env", "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT=file", "#{__dir__}/../bin/annotate", "#{__dir__}/test-failure-and-error/") |
| 251 | + stdout, stderr, status = Open3.capture3("env", "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT=file", "#{__dir__}/../bin/annotate", "#{__dir__}/test-failure-and-error/") |
239 | 252 |
|
240 |
| - assert_equal <<~OUTPUT, output |
| 253 | + assert_equal stderr, <<~OUTPUT |
241 | 254 | Parsing junit-1.xml
|
242 | 255 | Parsing junit-2.xml
|
243 | 256 | Parsing junit-3.xml
|
244 | 257 | --- ✍️ Preparing annotation
|
245 |
| - 6 testcases found |
246 |
| - There are 4 failures/errors 😭 |
247 |
| - 2 failures and 2 errors: |
| 258 | + OUTPUT |
| 259 | + |
| 260 | + assert_equal stdout, <<~OUTPUT |
| 261 | + Failures: 2 |
| 262 | + Errors: 2 |
| 263 | + Total tests: 6 |
248 | 264 |
|
249 | 265 | <details>
|
250 | 266 | <summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in ./spec/models/account_spec.rb</code></summary>
|
|
327 | 343 | end
|
328 | 344 |
|
329 | 345 | it "handles failures across multiple files in sub dirs" do
|
330 |
| - output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/tests-in-sub-dirs/") |
| 346 | + stdout, stderr, status = Open3.capture3("#{__dir__}/../bin/annotate", "#{__dir__}/tests-in-sub-dirs/") |
331 | 347 |
|
332 |
| - assert_equal <<~OUTPUT, output |
| 348 | + assert_equal stderr, <<~OUTPUT |
333 | 349 | Parsing sub-dir/junit-1.xml
|
334 | 350 | Parsing sub-dir/junit-2.xml
|
335 | 351 | Parsing sub-dir/junit-3.xml
|
336 | 352 | --- ✍️ Preparing annotation
|
337 |
| - 6 testcases found |
338 |
| - There are 4 failures/errors 😭 |
339 |
| - 4 failures: |
| 353 | + OUTPUT |
| 354 | + |
| 355 | + assert_equal stdout, <<~OUTPUT |
| 356 | + Failures: 4 |
| 357 | + Errors: 0 |
| 358 | + Total tests: 6 |
340 | 359 |
|
341 | 360 | <details>
|
342 | 361 | <summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
|
|
419 | 438 | end
|
420 | 439 |
|
421 | 440 | it "handles empty failure bodies" do
|
422 |
| - output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/empty-failure-body/") |
| 441 | + stdout, stderr, status = Open3.capture3("#{__dir__}/../bin/annotate", "#{__dir__}/empty-failure-body/") |
423 | 442 |
|
424 |
| - assert_equal <<~OUTPUT, output |
| 443 | + assert_equal stderr, <<~OUTPUT |
425 | 444 | Parsing junit.xml
|
426 | 445 | --- ✍️ Preparing annotation
|
427 |
| - 2 testcases found |
428 |
| - There is 1 failure/error 😭 |
429 |
| - 1 failure: |
| 446 | + OUTPUT |
| 447 | + |
| 448 | + assert_equal stdout, <<~OUTPUT |
| 449 | + Failures: 1 |
| 450 | + Errors: 0 |
| 451 | + Total tests: 2 |
430 | 452 |
|
431 | 453 | <details>
|
432 | 454 | <summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
|
|
439 | 461 | assert_equal 64, status.exitstatus
|
440 | 462 | end
|
441 | 463 |
|
442 |
| - it "handles missing message attributes" do |
443 |
| - output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/missing-message-attribute/") |
| 464 | + it "handles miss message attributes" do |
| 465 | + stdout, stderr, status = Open3.capture3("#{__dir__}/../bin/annotate", "#{__dir__}/missing-message-attribute/") |
444 | 466 |
|
445 |
| - assert_equal <<~OUTPUT, output |
| 467 | + assert_equal stderr, <<~OUTPUT |
446 | 468 | Parsing junit.xml
|
447 | 469 | --- ✍️ Preparing annotation
|
448 |
| - 4 testcases found |
449 |
| - There are 3 failures/errors 😭 |
450 |
| - 1 failure and 2 errors: |
| 470 | + OUTPUT |
| 471 | + |
| 472 | + assert_equal stdout, <<~OUTPUT |
| 473 | + Failures: 1 |
| 474 | + Errors: 2 |
| 475 | + Total tests: 4 |
451 | 476 |
|
452 | 477 | <details>
|
453 | 478 | <summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
|
|
469 | 494 | end
|
470 | 495 |
|
471 | 496 | it "handles cdata formatted XML files" do
|
472 |
| - output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/failure-with-cdata/") |
| 497 | + stdout, stderr, status = Open3.capture3("#{__dir__}/../bin/annotate", "#{__dir__}/failure-with-cdata/") |
473 | 498 |
|
474 |
| - assert_equal <<~OUTPUT, output |
| 499 | + assert_equal stderr, <<~OUTPUT |
475 | 500 | Parsing junit.xml
|
476 | 501 | --- ✍️ Preparing annotation
|
477 |
| - 2 testcases found |
478 |
| - There is 1 failure/error 😭 |
479 |
| - 1 error: |
| 502 | + OUTPUT |
| 503 | + |
| 504 | + assert_equal stdout, <<~OUTPUT |
| 505 | + Failures: 0 |
| 506 | + Errors: 1 |
| 507 | + Total tests: 2 |
480 | 508 |
|
481 | 509 | <details>
|
482 | 510 | <summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in spec.models.account_spec</code></summary>
|
|
493 | 521 | end
|
494 | 522 |
|
495 | 523 | it "reports specified amount of slowest tests" do
|
496 |
| - output, status = Open3.capture2e("env", "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST=5", "#{__dir__}/../bin/annotate", "#{__dir__}/no-test-failures/") |
| 524 | + stdout, stderr, status = Open3.capture3("env", "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_REPORT_SLOWEST=5", "#{__dir__}/../bin/annotate", "#{__dir__}/no-test-failures/") |
497 | 525 |
|
498 |
| - assert_equal <<~OUTPUT, output |
| 526 | + assert_equal stderr, <<~OUTPUT |
499 | 527 | Parsing junit-1.xml
|
500 | 528 | Parsing junit-2.xml
|
501 | 529 | Parsing junit-3.xml
|
502 | 530 | --- ✍️ Preparing annotation
|
503 |
| - 8 testcases found |
504 |
| - There were no failures/errors 🙌 |
505 | 531 | Reporting slowest tests ⏱
|
| 532 | + OUTPUT |
| 533 | + |
| 534 | + assert_equal stdout, <<~OUTPUT |
| 535 | + Failures: 0 |
| 536 | + Errors: 0 |
| 537 | + Total tests: 8 |
| 538 | + |
506 | 539 | <details>
|
507 | 540 | <summary>5 slowest tests</summary>
|
508 | 541 |
|
|
523 | 556 | end
|
524 | 557 |
|
525 | 558 | it "handles junit dir paths with hidden directories" do
|
526 |
| - output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/.tests-in-hidden-dir/") |
| 559 | + stdout, stderr, status = Open3.capture3("#{__dir__}/../bin/annotate", "#{__dir__}/.tests-in-hidden-dir/") |
527 | 560 |
|
528 |
| - assert_equal <<~OUTPUT, output |
| 561 | + assert_equal stderr, <<~OUTPUT |
529 | 562 | Parsing junit-1.xml
|
530 | 563 | --- ✍️ Preparing annotation
|
531 |
| - 2 testcases found |
532 |
| - There were no failures/errors 🙌 |
| 564 | + OUTPUT |
| 565 | + |
| 566 | + assert_equal stdout, <<~OUTPUT |
| 567 | + Failures: 0 |
| 568 | + Errors: 0 |
| 569 | + Total tests: 2 |
533 | 570 | OUTPUT
|
534 | 571 |
|
535 | 572 | assert_equal 0, status.exitstatus
|
|
0 commit comments