Skip to content

Commit

Permalink
Merge pull request #12 from hartwork/make-ci-cover-windows
Browse files Browse the repository at this point in the history
Make CI cover Windows
  • Loading branch information
hartwork authored Nov 8, 2020
2 parents 6607d02 + c3358b3 commit 211c139
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Build and test
strategy:
matrix:
runs-on: [macos-latest, ubuntu-latest]
runs-on: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions internal/network/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type connectResult struct {
err error
}

func waitForAddress(address syntax.Address) <-chan bool {
func waitForAddressForever(address syntax.Address) <-chan bool {
available := make(chan bool, 1)
go func() {
for {
Expand All @@ -46,7 +46,7 @@ func waitForAddressWithTimeout(address syntax.Address, timeout time.Duration, st
err := error(nil)

select {
case <-waitForAddress(address):
case <-waitForAddressForever(address):
duration = time.Now().Sub(startedAt)
case <-deadline:
err = fmt.Errorf("Failed to connect to %s for %s.", address, timeout)
Expand Down
17 changes: 14 additions & 3 deletions internal/network/wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/stretchr/testify/assert"
)

func TestWaitForAddress(t *testing.T) {
func TestWaitForAddressSuccess(t *testing.T) {
testlab.WithListeningPort(t, func(address syntax.Address) {
port := address.Port

Expand All @@ -27,16 +27,27 @@ func TestWaitForAddress(t *testing.T) {

deadlineCombined := time.After(2 * time.Second)
for _, address := range addresses {
available := waitForAddress(address)
available := waitForAddressForever(address)
select {
case <-available:
case <-deadlineCombined:
t.Errorf("waitForAddress should be long done by now.")
t.Errorf("waitForAddressForever should be long done by now.")
}
}
})
}

func TestWaitForAddressFailure(t *testing.T) {
testlab.WithUnusedPort(t, func(address syntax.Address) {
timeout := 1250 * time.Millisecond // small to not blow up test runtime
select {
case <-waitForAddressForever(address):
t.Errorf("waitForAddressForever was expected to never finish.")
case <-time.After(timeout):
}
})
}

func TestWaitForAddressWithTimeoutSuccess(t *testing.T) {
testlab.WithListeningPort(t, func(address syntax.Address) {
timeout := 2 * time.Second
Expand Down

0 comments on commit 211c139

Please sign in to comment.