Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2a6ae2c
Quick functions for generating TAP output
mndrix Dec 16, 2013
3336e7a
Use test methods instead of functions
mndrix Dec 16, 2013
2f21e10
Start TAP tests at 1
mndrix Dec 16, 2013
00b01ab
Test suite to make sure TAP is correct
mndrix Dec 16, 2013
b7c11a7
Support tests like "testing/quick"
mndrix Dec 17, 2013
b02f607
Create LICENSE
Mar 10, 2015
9955d98
go fmt
mndrix May 10, 2016
e567098
Count method returning number of tests
tahmmee May 9, 2016
d8624b4
Add AutoPlan method
tahmmee May 9, 2016
2d3e559
tap: Teach Header to skip the plan when testCount < 1
wking Sep 28, 2016
f0db097
Add tests for AutoPlan
wking Sep 28, 2016
b0fae82
Merge pull request #2 from wking/auto-plan-header
Sep 28, 2016
ed0683e
Rename repository
mndrix Sep 28, 2016
9bdb5f1
Keep test binaries inside the test/ directory
mndrix Sep 28, 2016
c3d1284
Add a 'clean' rule to remove all test binaries
mndrix Sep 28, 2016
368f25b
Run all tests with a single harness
mndrix Sep 28, 2016
3e8d957
Add tests for Check()
mndrix Sep 28, 2016
e5fc669
Add basic README
mndrix Dec 1, 2016
2bc21a4
Use Count() inside AutoPlan()
mndrix Dec 1, 2016
c07a1b7
More documentation
mndrix Dec 1, 2016
2ab2428
GOPATH symlink hack
mndrix Dec 1, 2016
4f77f9f
Rebuild test scripts if tap.go changes
mndrix Dec 1, 2016
34b25bd
Fix Makefile dependencies for "all"
mndrix Dec 1, 2016
8615712
Use our own printf method for output
mndrix Dec 1, 2016
c4add1a
Send TAP output to any io.Writer
mndrix Dec 1, 2016
a39a5d7
Cover failing tests
mndrix Dec 1, 2016
010390e
Add Pass() and Fail()
mndrix Dec 1, 2016
0fa2830
Added Diagnostic and Diagnosticf.
tesujimath Jan 5, 2017
1c3ba86
Allow for embedded newlines in diagnostics.
tesujimath Jan 5, 2017
3d4b01e
Added diagnostic test to Makefile.
tesujimath Jan 5, 2017
80022f6
test/failing: Wrap failing tests in another harness
wking Jan 5, 2017
76112da
Explicitly test diagnostic output
mndrix Jan 5, 2017
19f6898
Use Diagnostic() inside Check()
mndrix Jan 5, 2017
2dfd665
go fmt
mndrix Jan 5, 2017
92ea411
Merge pull request #5 from wking/wrap-failing-test
Jan 5, 2017
81d3a42
Add T.Skip(count int, description string)
wking Jan 11, 2017
323dc3d
Add T.TODO and t.Todo() to drive the TODO directive
wking Jan 11, 2017
130f1eb
Merge remote-tracking branch 'wking/directives'
mndrix Jan 13, 2017
e1c4a83
Add YAML() for generating YAML blocks
wking Nov 30, 2017
42b56ca
Add 'yaml' build tag for conditionally using gopkg.in/yaml.v2
wking Dec 1, 2017
d68106f
Merge branch 'yaml'
wking Dec 3, 2017
48a14c3
Merge github.com/mndrix/tap-go into util
fmuyassarov May 5, 2023
b6301ac
Add a note about tap-go migration
fmuyassarov May 5, 2023
cba200f
Replace tap-go import path
fmuyassarov May 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/runtimetest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"strings"
"syscall"

"github.com/mndrix/tap-go"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/util/tap"
"github.com/sirupsen/logrus"
"github.com/syndtr/gocapability/capability"
"github.com/urfave/cli"
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/blang/semver/v4 v4.0.0
github.com/google/uuid v1.3.0
github.com/hashicorp/go-multierror v1.1.1
github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b
github.com/mrunalp/fileutils v0.5.0
github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb
github.com/opencontainers/selinux v1.9.1
Expand All @@ -16,6 +15,7 @@ require (
github.com/urfave/cli v1.19.1
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/sys v0.0.0-20191115151921-52ab43148777
gopkg.in/yaml.v2 v2.4.0
)

require (
Expand All @@ -24,5 +24,4 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/U
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b h1:Ga1nclDSe8gOw37MVLMhfu2QKWtD6gvtQ298zsKVh8g=
github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b/go.mod h1:pzzDgJWZ34fGzaAZGFW22KVZDfyrYW+QABMrWnJBnSs=
github.com/mrunalp/fileutils v0.5.0 h1:NKzVxiH7eSk+OQ4M+ZYW1K6h27RUV3MI6NUTsHhU6Z4=
github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ=
github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb h1:1xSVPOd7/UA+39/hXEGnBJ13p6JFB0E1EvQFlrRDOXI=
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ The [Test Anything Protocol](http://testanything.org/) ("TAP") is a text-based
interface between tests and a test harness. This package helps Go to generate
TAP output.

Read the [full package documentation](https://godoc.org/github.com/mndrix/tap-go)
Read the [full package documentation](https://godoc.org/github.com/opencontainers/runtime-tools/util/tap)

NOTE: This code was originally located at https://github.com/mndrix/tap-go and
migrated to here as the project was archieved.
28 changes: 14 additions & 14 deletions vendor/github.com/mndrix/tap-go/tap.go → util/tap/tap.go
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
// Package tap provides support for automated Test Anything Protocol ("TAP")
// tests in Go. For example:
//
// package main
// package main
//
// import "github.com/mndrix/tap-go"
// import "github.com/opencontainers/runtime-tools/util/tap"
//
// func main() {
// t := tap.New()
// t.Header(2)
// t.Ok(true, "first test")
// t.Ok(true, "second test")
// }
// func main() {
// t := tap.New()
// t.Header(2)
// t.Ok(true, "first test")
// t.Ok(true, "second test")
// }
//
// generates the following output
//
// TAP version 13
// 1..2
// ok 1 - first test
// ok 2 - second test
package tap // import "github.com/mndrix/tap-go"
// TAP version 13
// 1..2
// ok 1 - first test
// ok 2 - second test
package tap

import (
"fmt"
"io"
"os"
"strings"
"testing/quick"
)
import "testing/quick"

// T is a type to encapsulate test state. Methods on this type generate TAP
// output.
Expand Down
11 changes: 11 additions & 0 deletions util/tap/test/auto/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

import "github.com/opencontainers/runtime-tools/util/tap"

func main() {
t := tap.New()
t.Header(0)
t.Ok(true, "first test")
t.Ok(true, "second test")
t.AutoPlan()
}
16 changes: 16 additions & 0 deletions util/tap/test/check/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import "github.com/opencontainers/runtime-tools/util/tap"

func main() {
add := func(x int) bool { return x+3 > x }
sub := func(x int) bool { return x-3 < x }
one := func(x int) bool { return x*1 == x }

t := tap.New()
t.Header(0)
t.Check(add, "addition makes numbers larger")
t.Check(sub, "subtraction makes numbers smaller")
t.Check(one, "1 is a multiplicative identity")
t.AutoPlan()
}
37 changes: 37 additions & 0 deletions util/tap/test/diagnostic/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"bytes"
"io"
"os"

tap "github.com/opencontainers/runtime-tools/util/tap"
)

func main() {
// collect output for comparison later
buf := new(bytes.Buffer)
t := tap.New()
t.Writer = io.MultiWriter(os.Stdout, buf)

t.Header(1)
t.Diagnostic("expecting all to be well")
t.Diagnosticf("here's some perfectly magical output: %d %s 0x%X.", 6, "abracadabra", 28)
t.Diagnostic("some\nmultiline\ntext\n")
t.Diagnosticf("%d lines\n%s multiline\ntext", 3, "more")

got := buf.String()
t.Ok(got == expected, "diagnostics gave expected output")
}

const expected = `TAP version 13
1..1
# expecting all to be well
# here's some perfectly magical output: 6 abracadabra 0x1C.
# some
# multiline
# text
# 3 lines
# more multiline
# text
`
25 changes: 25 additions & 0 deletions util/tap/test/failing/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"bytes"

"github.com/opencontainers/runtime-tools/util/tap"
)

func main() {
t1 := tap.New()
t1.Header(2)

buf := new(bytes.Buffer)
t2 := tap.New()
t2.Writer = buf
t2.Header(2)

buf.Reset()
t2.Ok(false, "first test")
t1.Ok(buf.String() == "not ok 1 - first test\n", "Ok(false, ...) produces appropriate output")

buf.Reset()
t2.Fail("second test")
t1.Ok(buf.String() == "not ok 2 - second test\n", "Fail(...) produces appropriate output")
}
10 changes: 10 additions & 0 deletions util/tap/test/known/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

import "github.com/opencontainers/runtime-tools/util/tap"

func main() {
t := tap.New()
t.Header(2)
t.Ok(true, "first test")
t.Pass("second test")
}
30 changes: 30 additions & 0 deletions util/tap/test/skip/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"bytes"
"io"
"os"

tap "github.com/opencontainers/runtime-tools/util/tap"
)

func main() {
// collect output for comparison later
buf := new(bytes.Buffer)
t := tap.New()
t.Writer = io.MultiWriter(os.Stdout, buf)

t.Header(4)
t.Skip(1, "insufficient flogiston pressure")
t.Skip(2, "no /sys directory")

got := buf.String()
t.Ok(got == expected, "skip gave expected output")
}

const expected = `TAP version 13
1..4
ok 1 # SKIP insufficient flogiston pressure
ok 2 # SKIP no /sys directory
ok 3 # SKIP no /sys directory
`
38 changes: 38 additions & 0 deletions util/tap/test/todo/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import (
"bytes"
"io"
"os"

tap "github.com/opencontainers/runtime-tools/util/tap"
)

func main() {
// collect output for comparison later
buf := new(bytes.Buffer)
t := tap.New()
t.Writer = io.MultiWriter(os.Stdout, buf)

t.Header(6)
t.TODO = true
t.Ok(false, "using Ok(false, ...) in TODO mode")
t.Fail("using Fail(...) in TODO mode")
t.TODO = false
t.Ok(true, "using Ok(false, ...) after leaving TODO mode")

t.Todo().Fail("using Fail(...) in TODO mode with method chaining")
t.Pass("using Pass(...) after Todo method chaining")

got := buf.String()
t.Ok(got == expected, "TODO gave expected output")
}

const expected = `TAP version 13
1..6
not ok 1 # TODO using Ok(false, ...) in TODO mode
not ok 2 # TODO using Fail(...) in TODO mode
ok 3 - using Ok(false, ...) after leaving TODO mode
not ok 4 # TODO using Fail(...) in TODO mode with method chaining
ok 5 - using Pass(...) after Todo method chaining
`
19 changes: 19 additions & 0 deletions util/tap/test/writer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"bytes"
"os"

"github.com/opencontainers/runtime-tools/util/tap"
)

func main() {
buf := new(bytes.Buffer)
t := tap.New()
t.Writer = buf
t.Header(2)
t.Ok(true, "a test")
t.Ok(buf.Len() > 0, "buffer has content")

buf.WriteTo(os.Stdout)
}
14 changes: 14 additions & 0 deletions util/tap/test/yaml/json.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// +build !yaml

package main

const expected = `TAP version 13
1..2
ok 1 - test for anchoring the YAML block
---
{
"code": 3,
"message": "testing YAML blocks"
}
...
`
26 changes: 26 additions & 0 deletions util/tap/test/yaml/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package main

import (
"bytes"
"io"
"os"

tap "github.com/opencontainers/runtime-tools/util/tap"
)

func main() {
// collect output for comparison later
buf := new(bytes.Buffer)
t := tap.New()
t.Writer = io.MultiWriter(os.Stdout, buf)

t.Header(2)
t.Pass("test for anchoring the YAML block")
message := map[string]interface{}{
"message": "testing YAML blocks",
"code": 3,
}
t.YAML(message)
got := buf.String()
t.Ok(got == expected, "diagnostics gave expected output")
}
12 changes: 12 additions & 0 deletions util/tap/test/yaml/yaml.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// +build yaml

package main

const expected = `TAP version 13
1..2
ok 1 - test for anchoring the YAML block
---
code: 3
message: testing YAML blocks
...
`
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"time"

"github.com/google/uuid"
tap "github.com/mndrix/tap-go"
"github.com/mrunalp/fileutils"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/opencontainers/runtime-tools/specerror"
tap "github.com/opencontainers/runtime-tools/util/tap"
"github.com/opencontainers/runtime-tools/validation/util"
)

Expand Down
2 changes: 1 addition & 1 deletion validation/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"runtime"

"github.com/google/uuid"
"github.com/mndrix/tap-go"
rspecs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/opencontainers/runtime-tools/specerror"
"github.com/opencontainers/runtime-tools/util/tap"
"github.com/opencontainers/runtime-tools/validation/util"
)

Expand Down
4 changes: 2 additions & 2 deletions validation/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"os"
"time"

"github.com/mndrix/tap-go"
"github.com/google/uuid"
rspecs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/opencontainers/runtime-tools/specerror"
"github.com/opencontainers/runtime-tools/util/tap"
"github.com/opencontainers/runtime-tools/validation/util"
"github.com/google/uuid"
)

func main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"time"

"github.com/google/uuid"
tap "github.com/mndrix/tap-go"
"github.com/mrunalp/fileutils"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/specerror"
tap "github.com/opencontainers/runtime-tools/util/tap"
"github.com/opencontainers/runtime-tools/validation/util"
)

Expand Down
Loading