rspec_junit_formatter 0.7.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8938b63b79c5d0cfd77464773645cca9a0c72b11c5d3f1fe7fc92d0279c4021
4
- data.tar.gz: 9fc9a172d1292bb89a368e889f2f90165e47b087dd5c39fe7a154d9480ca3f61
3
+ metadata.gz: 86651a64a7f810497cc1958b49c285df2aea4d912e3ad9d2cc59a791902fef4c
4
+ data.tar.gz: e90928c8f44a31a0dfe16344200aabede4e9b11af848de063f4786ba05feb64f
5
5
  SHA512:
6
- metadata.gz: e4c83896373201abf5ec66c1cc8dc858e44eb3def5546646e2ca72d36ea2dd70cb44d42b9db2d51d094daa46b3248fd4a189edced96f1db1a2319d4f38bdfff6
7
- data.tar.gz: f3619e7aaef1751d2dc433c41e2c6608e77d31483e550fa8ce47ad95352f21c7052b10fa8b447b1f00d2a21b5d883be017939f120162fb5f635238088230aeca
6
+ metadata.gz: c3620be8b07588d2acd5feaf5e9f795b1c4096dbf029875518084709dc70c057c1abf5c0deaed9beec954d0ff41dc11a4c36bfea404a735648bed11bde79c458
7
+ data.tar.gz: 869977b6c8a97bbf1f2ba08706249463e80260e92c84fd72f4feb0a45ae882214a29430ad4f344cfb7ed5b23373a540ee99ce4729ae7e2ad3dcf01e6cdba9d3c
data/README.md CHANGED
@@ -66,7 +66,47 @@ For use with `parallel_tests`, add `$TEST_ENV_NUMBER` in the output file option
66
66
  --out tmp/rspec<%= ENV["TEST_ENV_NUMBER"] %>.xml
67
67
  ```
68
68
 
69
- The formatter includes `$TEST_ENV_NUMBER` in the test suite name within the XML, too.
69
+ The formatter appends `$TEST_ENV_NUMBER` to the test suite name within the XML, too.
70
+ An explicitly set value always wins, including the empty string that `parallel_tests`
71
+ uses for its first worker: `TEST_ENV_NUMBER=""` keeps the name `rspec`.
72
+
73
+ When `TEST_ENV_NUMBER` is **unset**, the formatter uses the first non-empty value
74
+ from this table, in order:
75
+
76
+ | Variable | Provider | Native first index |
77
+ | --- | --- | --- |
78
+ | `CI_NODE_INDEX` | [GitLab](https://docs.gitlab.com/ci/variables/predefined_variables/), or a user-supplied CI label | `1` on GitLab |
79
+ | `CIRCLE_NODE_INDEX` | [CircleCI](https://circleci.com/docs/reference/variables/#built-in-environment-variables) | `0` |
80
+ | `SEMAPHORE_JOB_INDEX` | [Semaphore](https://docs.semaphore.io/reference/env-vars#job-index) | `1` |
81
+ | `BUILDKITE_PARALLEL_JOB` | [Buildkite](https://buildkite.com/docs/pipelines/configure/environment-variables#BUILDKITE_PARALLEL_JOB) | `0` |
82
+ | `BITBUCKET_PARALLEL_STEP` | [Bitbucket Pipelines](https://support.atlassian.com/bitbucket-cloud/docs/parallel-step-options/) | `0` |
83
+
84
+ Values are labels, not test-sharding offsets: they are XML-escaped but otherwise
85
+ unchanged. For example, GitLab's `CI_NODE_INDEX=1` produces `rspec1`, while
86
+ Buildkite's `BUILDKITE_PARALLEL_JOB=0` produces `rspec0`. There is no index
87
+ conversion based on `GITLAB_CI`, and a custom `CI_NODE_INDEX` takes precedence over
88
+ the other CI variables. If all these values are empty or unset, the name stays
89
+ `rspec`; no default `0` is appended.
90
+
91
+ The old `SEMAPHORE_CURRENT_THREAD` and `SNAP_WORKER_INDEX` variables are not
92
+ detected: [Semaphore Classic was retired in 2023](https://semaphore.io/blog/semaphore-classic-deprecation)
93
+ and [Snap CI in 2017](https://github.com/snap-ci/snap-ci-blog-content/blob/master/posts/2017-02-06-2017-02-06-snap-announcement.md).
94
+ Other runners can set `TEST_ENV_NUMBER` explicitly.
95
+
96
+ This changes **only the XML suite name**, not the output filename. Continue to
97
+ choose distinct `--out` paths for processes sharing a filesystem. CI indexes are
98
+ unique only within their parallel job group, not across steps, builds, or nested
99
+ `parallel_tests` workers. To combine those reports, set an explicit label that
100
+ includes each relevant dimension, and use it in the filename too. For example,
101
+ inside each `parallel_tests` worker on Buildkite:
102
+
103
+ ```sh
104
+ export TEST_ENV_NUMBER="-${BUILDKITE_STEP_KEY}-${BUILDKITE_PARALLEL_JOB}-${TEST_ENV_NUMBER}"
105
+ bundle exec rspec --format RspecJunitFormatter --out "tmp/rspec${TEST_ENV_NUMBER}.xml"
106
+ ```
107
+
108
+ Use distinct Buildkite step keys for this example; add a build identifier too if
109
+ you combine reports across builds.
70
110
 
71
111
  ### Capturing output
72
112
 
@@ -11,10 +11,20 @@ require "rspec/core/formatters/base_formatter"
11
11
  class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter
12
12
  private
13
13
 
14
+ def suite_name
15
+ # parallel_tests deliberately uses an empty label for its first worker.
16
+ suffix = ENV.fetch("TEST_ENV_NUMBER") do
17
+ %w[CI_NODE_INDEX CIRCLE_NODE_INDEX SEMAPHORE_JOB_INDEX
18
+ BUILDKITE_PARALLEL_JOB BITBUCKET_PARALLEL_STEP].map { |name| ENV[name] }.
19
+ find { |value| value && !value.empty? }
20
+ end
21
+ "rspec#{suffix}"
22
+ end
23
+
14
24
  def xml_dump
15
25
  output << %{<?xml version="1.0" encoding="UTF-8"?>\n}
16
26
  output << %{<testsuite}
17
- output << %{ name="rspec#{escape(ENV["TEST_ENV_NUMBER"].to_s)}"}
27
+ output << %{ name="#{escape(suite_name)}"}
18
28
  output << %{ tests="#{example_count}"}
19
29
  output << %{ skipped="#{pending_count}"}
20
30
  output << %{ failures="#{failure_count}"}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_junit_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Cochran