Skip to content

Commit e6a60ee

Browse files
authored
Merge pull request #533 from wking/tap-yaml
*: Transition from tap Diagnostic(...) to YAML(...)
2 parents 32b6ee1 + e85081a commit e6a60ee

File tree

13 files changed

+95
-19
lines changed

13 files changed

+95
-19
lines changed

Diff for: Godeps/Godeps.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ clean:
4040
rm -f oci-runtime-tool runtimetest *.1 $(VALIDATION_TESTS)
4141

4242
localvalidation:
43+
@for EXECUTABLE in runtimetest $(VALIDATION_TESTS); \
44+
do \
45+
if test ! -x "$${EXECUTABLE}"; \
46+
then \
47+
echo "missing test executable $${EXECUTABLE}; run 'make runtimetest validation-executables'" >&2; \
48+
exit 1; \
49+
fi; \
50+
done
4351
RUNTIME=$(RUNTIME) $(TAP) $(VALIDATION_TESTS)
4452

4553
.PHONY: validation-executables

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,18 @@ $ npm install tap
3939

4040
```console
4141
$ make runtimetest validation-executables
42+
$ sudo make RUNTIME=runc localvalidation
4243
RUNTIME=runc tap validation/linux_rootfs_propagation_shared.t validation/create.t validation/default.t validation/linux_readonly_paths.t validation/linux_masked_paths.t validation/mounts.t validation/process.t validation/root_readonly_false.t validation/linux_sysctl.t validation/linux_devices.t validation/linux_gid_mappings.t validation/process_oom_score_adj.t validation/process_capabilities.t validation/process_rlimits.t validation/root_readonly_true.t validation/linux_rootfs_propagation_unbindable.t validation/hostname.t validation/linux_uid_mappings.t
4344
validation/linux_rootfs_propagation_shared.t ........ 18/19
4445
not ok rootfs propagation
46+
error: 'rootfs should be shared, but not'
4547

4648
validation/create.t ................................... 4/4
4749
validation/default.t ................................ 19/19
4850
validation/linux_readonly_paths.t ................... 19/19
4951
validation/linux_masked_paths.t ..................... 18/19
5052
not ok masked paths
53+
error: /masktest should not be readable
5154

5255
validation/mounts.t ................................... 0/1
5356
Skipped: 1

Diff for: cmd/runtimetest/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -945,15 +945,15 @@ func run(context *cli.Context) error {
945945
} else {
946946
t.Fail(v.description)
947947
}
948-
t.Diagnostic(err.Error())
948+
t.YAML(map[string]string{"error": err.Error()})
949949
}
950950
} else {
951951
if e, ok := err.(*rfc2119.Error); ok {
952952
t.Ok(e.Level < complianceLevel, v.description)
953953
} else {
954954
t.Fail(v.description)
955955
}
956-
t.Diagnostic(err.Error())
956+
t.YAML(map[string]string{"error": err.Error()})
957957
}
958958
}
959959
}

Diff for: validation/create.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,24 @@ func main() {
5050
r.SetID(c.id)
5151
stderr, err := r.Create()
5252
t.Ok((err == nil) == c.errExpected, c.err.(*specerror.Error).Err.Err.Error())
53-
t.Diagnostic(c.err.(*specerror.Error).Err.Reference)
53+
diagnostic := map[string]string{
54+
"reference": c.err.(*specerror.Error).Err.Reference,
55+
}
5456
if err != nil {
55-
t.Diagnostic(err.Error())
57+
diagnostic["error"] = err.Error()
5658
}
5759
if len(stderr) > 0 {
58-
t.Diagnostic(string(stderr))
60+
diagnostic["stderr"] = string(stderr)
5961
}
62+
t.YAML(diagnostic)
6063

6164
if err == nil {
6265
state, _ := r.State()
63-
t.Ok(state.ID == c.id, "")
64-
t.Diagnosticf("container PID: %d, state ID: %d", c.id, state.ID)
66+
t.Ok(state.ID == c.id, "'state' MUST return the state of a container")
67+
t.YAML(map[string]string{
68+
"container ID": c.id,
69+
"state ID": state.ID,
70+
})
6571
}
6672
}
6773

Diff for: validation/process_capabilities.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func main() {
1111
if "linux" != runtime.GOOS {
12-
util.Skip("linux-specific process.capabilities test", runtime.GOOS)
12+
util.Skip("linux-specific process.capabilities test", map[string]string{"OS": runtime.GOOS})
1313
os.Exit(0)
1414
}
1515

Diff for: validation/root_readonly_true.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
func main() {
1111
if "windows" == runtime.GOOS {
12-
util.Skip("non-Windows root.readonly test", runtime.GOOS)
12+
util.Skip("non-Windows root.readonly test", map[string]string{"OS": runtime.GOOS})
1313
os.Exit(0)
1414
}
1515

Diff for: validation/util/container.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
rspecs "github.com/opencontainers/runtime-spec/specs-go"
1414
"github.com/opencontainers/runtime-tools/generate"
15+
"github.com/satori/go.uuid"
1516
)
1617

1718
// Runtime represents the basic requirement of a container runtime
@@ -63,12 +64,13 @@ func (r *Runtime) Create() (stderr []byte, err error) {
6364
// }
6465
cmd := exec.Command(r.RuntimeCommand, args...)
6566
cmd.Dir = r.BundleDir
66-
r.stdout, err = os.OpenFile(filepath.Join(r.BundleDir, fmt.Sprintf("stdout-%s", r.ID)), os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)
67+
id := uuid.NewV4().String()
68+
r.stdout, err = os.OpenFile(filepath.Join(r.BundleDir, fmt.Sprintf("stdout-%s", id)), os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)
6769
if err != nil {
6870
return []byte(""), err
6971
}
7072
cmd.Stdout = r.stdout
71-
r.stderr, err = os.OpenFile(filepath.Join(r.BundleDir, fmt.Sprintf("stderr-%s", r.ID)), os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)
73+
r.stderr, err = os.OpenFile(filepath.Join(r.BundleDir, fmt.Sprintf("stderr-%s", id)), os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)
7274
if err != nil {
7375
return []byte(""), err
7476
}

Diff for: validation/util/test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ func Fatal(err error) {
4242
}
4343

4444
// Skip skips a full TAP suite.
45-
func Skip(message string, diagnostic string) {
45+
func Skip(message string, diagnostic interface{}) {
4646
t := tap.New()
4747
t.Header(1)
4848
t.Skip(1, message)
49-
if diagnostic != "" {
50-
t.Diagnostic(diagnostic)
49+
if diagnostic != nil {
50+
t.YAML(diagnostic)
5151
}
5252
}
5353

Diff for: vendor/github.com/mndrix/tap-go/Makefile

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: vendor/github.com/mndrix/tap-go/tap.go

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: vendor/github.com/mndrix/tap-go/yaml_json.go

+22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: vendor/github.com/mndrix/tap-go/yaml_yaml.go

+23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)