|  | 
| 215 | 215 |     assert_equal 0, status.exitstatus | 
| 216 | 216 |   end | 
| 217 | 217 | 
 | 
|  | 218 | +  it "uses the file path instead of classname for annotation content when specified" do | 
|  | 219 | +    output, status = Open3.capture2e("env", "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT=file", "#{__dir__}/../bin/annotate", "#{__dir__}/test-failure-and-error/") | 
|  | 220 | + | 
|  | 221 | +    assert_equal <<~OUTPUT, output | 
|  | 222 | +      Parsing junit-1.xml | 
|  | 223 | +      Parsing junit-2.xml | 
|  | 224 | +      Parsing junit-3.xml | 
|  | 225 | +      --- ❓ Checking failures | 
|  | 226 | +      There are 4 failures/errors 😭 | 
|  | 227 | +      --- ✍️ Preparing annotation | 
|  | 228 | +      2 failures and 2 errors: | 
|  | 229 | +
 | 
|  | 230 | +      <details> | 
|  | 231 | +      <summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in ./spec/models/account_spec.rb</code></summary> | 
|  | 232 | +
 | 
|  | 233 | +      <code><pre>Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250) | 
|  | 234 | +
 | 
|  | 235 | +        expected: 250 | 
|  | 236 | +             got: 500 | 
|  | 237 | +
 | 
|  | 238 | +        (compared using eql?) | 
|  | 239 | +      ./spec/models/account_spec.rb:78:in `block (3 levels) in <top (required)>' | 
|  | 240 | +      ./spec/support/database.rb:16:in `block (2 levels) in <top (required)>' | 
|  | 241 | +      ./spec/support/log.rb:17:in `run' | 
|  | 242 | +      ./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code> | 
|  | 243 | +
 | 
|  | 244 | +      in <a href="#1">Job #1</a> | 
|  | 245 | +      </details> | 
|  | 246 | +
 | 
|  | 247 | +      <details> | 
|  | 248 | +      <summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 700 if the account is XYZ in ./spec/models/account_spec.rb</code></summary> | 
|  | 249 | +
 | 
|  | 250 | +      <code><pre>Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250) | 
|  | 251 | +
 | 
|  | 252 | +        expected: 700 | 
|  | 253 | +             got: 500 | 
|  | 254 | +
 | 
|  | 255 | +        (compared using eql?) | 
|  | 256 | +      ./spec/models/account_spec.rb:78:in `block (3 levels) in <top (required)>' | 
|  | 257 | +      ./spec/support/database.rb:16:in `block (2 levels) in <top (required)>' | 
|  | 258 | +      ./spec/support/log.rb:17:in `run' | 
|  | 259 | +      ./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code> | 
|  | 260 | +
 | 
|  | 261 | +      in <a href="#2">Job #2</a> | 
|  | 262 | +      </details> | 
|  | 263 | +
 | 
|  | 264 | +      <details> | 
|  | 265 | +      <summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 700 if the account is XYZ in ./spec/models/account_spec.rb</code></summary> | 
|  | 266 | +
 | 
|  | 267 | +      <code><pre>Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250) | 
|  | 268 | +
 | 
|  | 269 | +        expected: 700 | 
|  | 270 | +             got: 500 | 
|  | 271 | +
 | 
|  | 272 | +        (compared using eql?) | 
|  | 273 | +      ./spec/models/account_spec.rb:78:in `block (3 levels) in <top (required)>' | 
|  | 274 | +      ./spec/support/database.rb:16:in `block (2 levels) in <top (required)>' | 
|  | 275 | +      ./spec/support/log.rb:17:in `run' | 
|  | 276 | +      ./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code> | 
|  | 277 | +
 | 
|  | 278 | +      in <a href="#3">Job #3</a> | 
|  | 279 | +      </details> | 
|  | 280 | +
 | 
|  | 281 | +      <details> | 
|  | 282 | +      <summary><code>Account#maximum_jobs_added_by_pipeline_changer returns 250 by default in ./spec/models/account_spec.rb</code></summary> | 
|  | 283 | +
 | 
|  | 284 | +      <code><pre>Failure/Error: expect(account.maximum_jobs_added_by_pipeline_changer).to eql(250) | 
|  | 285 | +
 | 
|  | 286 | +        expected: 250 | 
|  | 287 | +             got: 500 | 
|  | 288 | +
 | 
|  | 289 | +        (compared using eql?) | 
|  | 290 | +      ./spec/models/account_spec.rb:78:in `block (3 levels) in <top (required)>' | 
|  | 291 | +      ./spec/support/database.rb:16:in `block (2 levels) in <top (required)>' | 
|  | 292 | +      ./spec/support/log.rb:17:in `run' | 
|  | 293 | +      ./spec/support/log.rb:66:in `block (2 levels) in <top (required)>'</pre></code> | 
|  | 294 | +
 | 
|  | 295 | +      in <a href="#3">Job #3</a> | 
|  | 296 | +      </details> | 
|  | 297 | +    OUTPUT | 
|  | 298 | + | 
|  | 299 | +    assert_equal 0, status.exitstatus | 
|  | 300 | +  end | 
|  | 301 | + | 
|  | 302 | +  it "raises an error when an invalid failure-format is provided" do | 
|  | 303 | +    output, status = Open3.capture2e("env", "BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAILURE_FORMAT=kittens", "#{__dir__}/../bin/annotate", "#{__dir__}/test-failure-and-error/") | 
|  | 304 | +    assert_equal false, status.success? | 
|  | 305 | +  end | 
|  | 306 | + | 
| 218 | 307 |   it "handles failures across multiple files in sub dirs" do | 
| 219 | 308 |     output, status = Open3.capture2e("#{__dir__}/../bin/annotate", "#{__dir__}/tests-in-sub-dirs/") | 
| 220 | 309 | 
 | 
|  | 
0 commit comments