Skip to content

Commit 4b49cba

Browse files
committed
devel guidelines: update TAP documentation
Signed-off-by: Alban Crequy <[email protected]>
1 parent 699dbce commit 4b49cba

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

docs/devel_guidelines.md

+46-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,52 @@ Each validation test has a `.go` file in the `validation/` directory and can be
77
### TAP output
88

99
Each validation test prints TAP output.
10-
So far, we have two kinds of validation tests and they print the TAP output differently:
11-
* tests using `util.RuntimeInsideValidate`: they start the process `runtimetest` inside the container and `runtimetest` prints the TAP output. The test process itself must not output anything to avoid mixing its output with the TAP output. Each test can only call `util.RuntimeInsideValidate` one time because several TAP outputs cannot be concatenated.
12-
* tests using `util.RuntimeOutsideValidate`: they create a container but without executing `runtimetest`. The test program itself must print the TAP output.
10+
So far, we have three kinds of validation tests and they print the TAP output differently:
11+
12+
#### Using `util.RuntimeOutsideValidate`
13+
14+
They create a container but without executing `runtimetest`. The test program itself must print the TAP output.
15+
16+
Example:
17+
```go
18+
err = util.RuntimeOutsideValidate(g, t, func(config *rspec.Spec, t *tap.T, state *rspec.State) error {
19+
err := testFoo()
20+
t.Ok((err == nil), "check foo")
21+
if err != nil {
22+
t.Diagnostic(err.Error())
23+
return nil
24+
}
25+
return nil
26+
})
27+
28+
```
29+
#### Using `util.RuntimeInsideValidate` and passthrough
30+
31+
They start the process `runtimetest` inside the container and `runtimetest` prints the TAP output.
32+
The test process itself must not output anything to avoid mixing its output with the TAP output.
33+
Each test can only call `util.RuntimeInsideValidate` one time because several TAP outputs cannot be concatenated.
34+
35+
Example:
36+
```go
37+
err = util.RuntimeInsideValidate(g, nil, nil)
38+
if err != nil {
39+
util.Fatal(err)
40+
}
41+
```
42+
43+
#### Using `util.RuntimeInsideValidate` and encapsulation
44+
45+
Similar to the passthrough variant but the test consumes the output from `runtimetest` and re-emit a single TAP result for the container run.
46+
For that, the TAP object must be passed as parameter to `util.RuntimeInsideValidate`.
47+
48+
Example:
49+
```go
50+
g.AddAnnotation("TestName", "check foo")
51+
err = util.RuntimeInsideValidate(g, t, nil)
52+
if err != nil {
53+
util.Fatal(err)
54+
}
55+
```
1356

1457
### Exit status
1558

0 commit comments

Comments
 (0)