Skip to content

Commit f7f2c3f

Browse files
authored
Merge pull request #10556 from circleci/test-216/bulk-file-mapper
TEST-216 Update file-mapper docs
2 parents 4454466 + a3de3e3 commit f7f2c3f

2 files changed

Lines changed: 66 additions & 8 deletions

File tree

docs/guides/modules/test/pages/testsuite-configuration-reference.adoc

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,70 @@ run: go tool gotestsum --junitfile="<< outputs.junit >>" -- -race -count=1 << te
135135
[#file-mapper]
136136
== *`file-mapper`*
137137
138-
When test atoms are not files, Smarter Testing cannot determine which test files belong to which test atom. The `file-mapper` creates a mapping of test atoms to related test files.
138+
When test atoms are not files, Smarter Testing cannot determine which test files belong to which test atom. The `file-mapper` command creates a mapping of test atoms to related test files.
139139
140140
* During analysis, Smarter Testing can associate test files with their test atoms in impact data.
141141
* During selection, Smarter Testing can determine which test atom to run when a test file is modified.
142142
143-
The test atom to map can be specified in one of two ways:
143+
File mapper maps all test atoms to test files in a single pass.
144+
145+
The test atoms to map can be specified in one of two ways:
144146
145147
* Use the template variable `<< test.atoms >>` in the `file-mapper` command.
146-
* If the template variable is not found in the `file-mapper` command, the test atom will be passed on stdin.
148+
* If the template variable is not found in the `file-mapper` command, the test atoms will be passed on stdin separated by newlines.
149+
150+
File mapper supports two different output formats:
151+
152+
* *Go list JSON format* `<< outputs.go-list-json >>`.
153+
* *CircleCI list format* `<< outputs.circleci-list >>`.
154+
155+
=== *Go list JSON format*
156+
157+
Go list JSON format is the format produced by `go list -json="Dir,ImportPath,TestGoFiles,XTestGoFiles" ./\...`.
158+
159+
It consists of one or more JSON documents separated by newlines. Note that each record is a separate JSON document.
160+
161+
.Example showing Go list JSON format
162+
[source,json]
163+
----
164+
{
165+
"Dir": "/home/user/dev/module-name/internal/foo",
166+
"ImportPath": "github.com/org/module-name/internal/foo",
167+
"TestGoFiles": [
168+
"foo_test.go"
169+
]
170+
}
171+
{
172+
"Dir": "/home/user/dev/module-name/internal/bar",
173+
"ImportPath": "github.com/org/module-name/internal/bar",
174+
"XTestGoFiles": [
175+
"bar_test.go",
176+
"baz_test.go",
177+
"shared_test.go"
178+
]
179+
}
180+
----
181+
182+
=== *CircleCI list format*
183+
184+
CircleCI list format is a plain text, record oriented format. It consists of one or more records separated by newlines.
185+
186+
Each record begins with a line starting with `TA:`, followed by the test atom name.
147187
148-
File mapper can run in two modes:
188+
Each subsequent line lists a file that contains code for the test atom.
149189
150-
* *One test atom at a time.* This mode expects a list of files back for a passed in `<< test.atom >>`.
151-
* *All test atoms in a single pass.* This mode supports `<< outputs.go-list-json >>` to map all go test files to go packages.
190+
Each line must be fewer than 32,768 characters long.
191+
192+
.Example showing CircleCI list format
193+
[source]
194+
----
195+
TA:TestFooClass
196+
src/foo_test.py
197+
src/bar_test.py
198+
199+
TA:TestQuzClass
200+
src/quz_test.py
201+
----
152202
153203
[.table-scroll]
154204
--
@@ -163,15 +213,22 @@ File mapper can run in two modes:
163213
|===
164214
--
165215
166-
*Example:*
167-
216+
.Example of file-mapper using `<< outputs.go-list-json >>`
168217
[%linenums,yaml]
169218
----
170219
---
171220
name: go tests
172221
file-mapper: go list -json="Dir,ImportPath,TestGoFiles,XTestGoFiles" ./... > << outputs.go-list-json >>
173222
----
174223
224+
.Example of file-mapper using `<< outputs.circleci-list >>`
225+
[%linenums,yaml]
226+
----
227+
---
228+
name: python tests
229+
file-mapper: for _atom in << test.atoms >>; do echo "TA:${_atom}"; echo "${_atom}" | sed -E 's/::.*$//'; done > << outputs.circleci-list >>
230+
----
231+
175232
'''
176233
177234
[#analysis]

styles/config/vocabularies/Docs/accept.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ Jenkins
205205
JFrog
206206
Jira
207207
jq\b
208+
JSON
208209
\bJUnit\b
209210
junit
210211
JRuby

0 commit comments

Comments
 (0)