Skip to content

Commit 3e71216

Browse files
committed
switch to use blackbox testing, move tests to separate module
This allows us to remove the test-dependencies from the module itself Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 9c3c875 commit 3e71216

File tree

7 files changed

+35
-8
lines changed

7 files changed

+35
-8
lines changed

Diff for: .github/workflows/test.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Checkout code
1616
uses: actions/checkout@v3
1717
- name: Test
18-
run: go test -v ./...
18+
run: cd test && go test -v .
1919
lint:
2020
runs-on: ubuntu-latest
2121
steps:
@@ -30,3 +30,8 @@ jobs:
3030
docker run --rm -v `pwd`:/go/src/github.com/moby/term -w /go/src/github.com/moby/term \
3131
golangci/golangci-lint:v1.50.1 golangci-lint run --disable-all -v \
3232
-E govet -E misspell -E gofmt -E ineffassign -E revive
33+
- name: Lint tests
34+
run: |
35+
docker run --rm -v `pwd`:/go/src/github.com/moby/term -w /go/src/github.com/moby/term/test \
36+
golangci/golangci-lint:v1.50.1 golangci-lint run --disable-all -v \
37+
-E govet -E misspell -E gofmt -E ineffassign -E revive

Diff for: go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ go 1.18
44

55
require (
66
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1
7-
github.com/creack/pty v1.1.18
87
golang.org/x/sys v0.1.0
98
)

Diff for: go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
22
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
3-
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
4-
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
53
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
64
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
75
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

Diff for: test/go.mod

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module github.com/moby/term/test
2+
3+
go 1.18
4+
5+
require (
6+
github.com/creack/pty v1.1.18
7+
github.com/moby/term v0.0.0-00010101000000-000000000000 // replaced
8+
)
9+
10+
require (
11+
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
12+
golang.org/x/sys v0.1.0 // indirect
13+
)
14+
15+
replace github.com/moby/term => ../

Diff for: test/go.sum

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
2+
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
3+
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
4+
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
5+
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
6+
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
7+
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

Diff for: proxy_test.go renamed to test/proxy_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
package term
1+
package test
22

33
import (
44
"bytes"
55
"testing"
6+
7+
. "github.com/moby/term"
68
)
79

810
func TestEscapeProxyRead(t *testing.T) {

Diff for: term_test.go renamed to test/term_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
//go:build !windows
22
// +build !windows
33

4-
package term
4+
package test
55

66
import (
77
"os"
88
"reflect"
99
"testing"
1010

1111
cpty "github.com/creack/pty"
12+
. "github.com/moby/term"
1213
)
1314

1415
func newTTYForTest(t *testing.T) *os.File {
@@ -47,7 +48,7 @@ func TestGetWinsize(t *testing.T) {
4748
t.Fatal("winSize is nil")
4849
}
4950

50-
newSize := Winsize{Width: 200, Height: 200, x: winSize.x, y: winSize.y}
51+
newSize := Winsize{Width: 200, Height: 200}
5152
err = SetWinsize(tty.Fd(), &newSize)
5253
if err != nil {
5354
t.Fatal(err)
@@ -70,7 +71,7 @@ func TestSetWinsize(t *testing.T) {
7071
if winSize == nil {
7172
t.Fatal("winSize is nil")
7273
}
73-
newSize := Winsize{Width: 200, Height: 200, x: winSize.x, y: winSize.y}
74+
newSize := Winsize{Width: 200, Height: 200}
7475
err = SetWinsize(tty.Fd(), &newSize)
7576
if err != nil {
7677
t.Fatal(err)

0 commit comments

Comments
 (0)