Skip to content

Commit

Permalink
fix(tests): readd sync lock
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Dec 2, 2023
1 parent d7c8f81 commit 762699b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions testscript/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"os/exec"
"path/filepath"
"strings"
"sync"
"syscall"
"testing"
"time"
Expand Down Expand Up @@ -59,6 +60,7 @@ func TestMain(m *testing.M) {
func TestScript(t *testing.T) {
flag.Parse()

var lock sync.Mutex
mkkey := func(name string) (string, *keygen.SSHKeyPair) {
path := filepath.Join(t.TempDir(), name)
pair, err := keygen.New(path, keygen.WithKeyType(keygen.Ed25519), keygen.WithWrite())
Expand Down Expand Up @@ -158,6 +160,7 @@ func TestScript(t *testing.T) {

ctx := config.WithContext(context.Background(), cfg)

lock.Lock()
// XXX: Right now, --sync-hooks is the only flag option we have for
// the serve command.
// TODO: Find a way to test different flag options.
Expand All @@ -172,8 +175,11 @@ func TestScript(t *testing.T) {
e.T().Fatal(err)
}
}()
lock.Unlock()

e.Defer(func() {
lock.Lock()
defer lock.Unlock()
if cmd.Process == nil {
e.T().Fatal("process not started")
}
Expand Down

0 comments on commit 762699b

Please sign in to comment.