Skip to content

Commit

Permalink
*: Transition from tap Diagnostic(...) to YAML(...)
Browse files Browse the repository at this point in the history
See ad47e7d (Makefile: Change from prove to node-tap, 2017-11-30,
opencontainers#439) about how node-tap handles YAML blocks vs. diagnostics.

The README's localvalidation line is back after I accidentally removed
it in ad47e7d.

Signed-off-by: W. Trevor King <[email protected]>
  • Loading branch information
wking committed Dec 3, 2017
1 parent aeaf786 commit 206845a
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 12 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ $ npm install tap

```console
$ make runtimetest validation-executables
$ sudo make RUNTIME=runc localvalidation
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
validation/linux_rootfs_propagation_shared.t ........ 18/19
not ok rootfs propagation
error: 'rootfs should be shared, but not'

validation/create.t ................................... 4/4
validation/default.t ................................ 19/19
validation/linux_readonly_paths.t ................... 19/19
validation/linux_masked_paths.t ..................... 18/19
not ok masked paths
error: /masktest should not be readable

validation/mounts.t ................................... 0/1
Skipped: 1
Expand Down
4 changes: 2 additions & 2 deletions cmd/runtimetest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,15 +917,15 @@ func run(context *cli.Context) error {
} else {
t.Fail(v.description)
}
t.Diagnostic(err.Error())
t.YAML(map[string]string{"error": err.Error()})
}
} else {
if e, ok := err.(*rfc2119.Error); ok {
t.Ok(e.Level < complianceLevel, v.description)
} else {
t.Fail(v.description)
}
t.Diagnostic(err.Error())
t.YAML(map[string]string{"error": err.Error()})
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions validation/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,24 @@ func main() {
r.SetID(c.id)
stderr, err := r.Create()
t.Ok((err == nil) == c.errExpected, c.err.(*specerror.Error).Err.Err.Error())
t.Diagnostic(c.err.(*specerror.Error).Err.Reference)
diagnostic := map[string]string{
"reference": c.err.(*specerror.Error).Err.Reference,
}
if err != nil {
t.Diagnostic(err.Error())
diagnostic["error"] = err.Error()
}
if len(stderr) > 0 {
t.Diagnostic(string(stderr))
diagnostic["stderr"] = string(stderr)
}
t.YAML(diagnostic)

if err == nil {
state, _ := r.State()
t.Ok(state.ID == c.id, "")
t.Diagnosticf("container PID: %d, state ID: %d", c.id, state.ID)
t.YAML(map[string]string{
"container ID": c.id,
"state ID": state.ID,
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion validation/mounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import (
)

func main() {
util.Skip("TODO: mounts generation options have not been implemented", "")
util.Skip("TODO: mounts generation options have not been implemented", nil)
}
2 changes: 1 addition & 1 deletion validation/process_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

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

Expand Down
2 changes: 1 addition & 1 deletion validation/root_readonly_true.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

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

Expand Down
6 changes: 3 additions & 3 deletions validation/util/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ func Fatal(err error) {
}

// Skip skips a full TAP suite.
func Skip(message string, diagnostic string) {
func Skip(message string, diagnostic interface{}) {
t := tap.New()
t.Header(1)
t.Skip(1, message)
if diagnostic != "" {
t.Diagnostic(diagnostic)
if diagnostic != nil {
t.YAML(diagnostic)
}
}

Expand Down

0 comments on commit 206845a

Please sign in to comment.