File tree 4 files changed +27
-6
lines changed
4 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -150,9 +150,12 @@ jobs:
150
150
terraform_wrapper : false
151
151
152
152
- name : Test with Mock Database
153
+ env :
154
+ GOCOUNT : ${{ runner.os == 'Windows' && 3 || 5 }}
155
+ GOMAXPROCS : ${{ runner.os == 'Windows' && 1 || 2 }}
153
156
run : gotestsum --junitfile="gotests.xml" --packages="./..." --
154
157
-covermode=atomic -coverprofile="gotests.coverage"
155
- -timeout=3m -count=5 -race -short -parallel=2
158
+ -timeout=3m -count=$GOCOUNT -race -short -failfast
156
159
157
160
- name : Upload DataDog Trace
158
161
if : (success() || failure()) && github.actor != 'dependabot[bot]'
@@ -166,10 +169,10 @@ jobs:
166
169
if : runner.os == 'Linux'
167
170
run : DB=true gotestsum --junitfile="gotests.xml" --packages="./..." --
168
171
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
169
- -count=1 -race -parallel=2
172
+ -count=1 -race -parallel=2 -failfast
170
173
171
174
- name : Upload DataDog Trace
172
- if : (success() || failure()) && github.actor != 'dependabot[bot]'
175
+ if : (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux'
173
176
env :
174
177
DATADOG_API_KEY : ${{ secrets.DATADOG_API_KEY }}
175
178
DD_DATABASE : postgresql
Original file line number Diff line number Diff line change 4
4
"context"
5
5
"database/sql"
6
6
"io"
7
+ "net"
7
8
"net/http/httptest"
8
9
"net/url"
9
10
"os"
@@ -59,7 +60,13 @@ func New(t *testing.T) *codersdk.Client {
59
60
Database : db ,
60
61
Pubsub : pubsub ,
61
62
})
62
- srv := httptest .NewServer (handler )
63
+ srv := httptest .NewUnstartedServer (handler )
64
+ srv .Config .BaseContext = func (_ net.Listener ) context.Context {
65
+ ctx , cancelFunc := context .WithCancel (context .Background ())
66
+ t .Cleanup (cancelFunc )
67
+ return ctx
68
+ }
69
+ srv .Start ()
63
70
serverURL , err := url .Parse (srv .URL )
64
71
require .NoError (t , err )
65
72
t .Cleanup (srv .Close )
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ package pty
6
6
import (
7
7
"io"
8
8
"os"
9
+ "sync"
9
10
10
11
"github.com/creack/pty"
11
12
)
@@ -23,6 +24,7 @@ func newPty() (PTY, error) {
23
24
}
24
25
25
26
type otherPty struct {
27
+ mutex sync.Mutex
26
28
pty , tty * os.File
27
29
}
28
30
@@ -41,13 +43,18 @@ func (p *otherPty) Output() io.ReadWriter {
41
43
}
42
44
43
45
func (p * otherPty ) Resize (cols uint16 , rows uint16 ) error {
46
+ p .mutex .Lock ()
47
+ defer p .mutex .Unlock ()
44
48
return pty .Setsize (p .tty , & pty.Winsize {
45
49
Rows : rows ,
46
50
Cols : cols ,
47
51
})
48
52
}
49
53
50
54
func (p * otherPty ) Close () error {
55
+ p .mutex .Lock ()
56
+ defer p .mutex .Unlock ()
57
+
51
58
err := p .pty .Close ()
52
59
if err != nil {
53
60
return err
Original file line number Diff line number Diff line change @@ -8,13 +8,17 @@ import (
8
8
"syscall"
9
9
10
10
"github.com/creack/pty"
11
+ "golang.org/x/xerrors"
11
12
)
12
13
13
14
func startPty (cmd * exec.Cmd ) (PTY , error ) {
14
15
ptty , tty , err := pty .Open ()
15
16
if err != nil {
16
- return nil , err
17
+ return nil , xerrors . Errorf ( "open: %w" , err )
17
18
}
19
+ defer func () {
20
+ _ = tty .Close ()
21
+ }()
18
22
cmd .SysProcAttr = & syscall.SysProcAttr {
19
23
Setsid : true ,
20
24
Setctty : true ,
@@ -25,7 +29,7 @@ func startPty(cmd *exec.Cmd) (PTY, error) {
25
29
err = cmd .Start ()
26
30
if err != nil {
27
31
_ = ptty .Close ()
28
- return nil , err
32
+ return nil , xerrors . Errorf ( "start: %w" , err )
29
33
}
30
34
return & otherPty {
31
35
pty : ptty ,
You can’t perform that action at this time.
0 commit comments