Skip to content

Commit 4f0e852

Browse files
authored
test(windows): Fix lib/ unit tests for Windows platform
Merge pull request #1556 from qri-io/win-test-fix
2 parents 21c160f + bfd872d commit 4f0e852

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

lib/fsi.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"os"
7+
"path"
78
"path/filepath"
89

910
"github.com/qri-io/dataset"
@@ -390,3 +391,8 @@ func (m *FSIMethods) EnsureRef(p *EnsureParams, out *dsref.VersionInfo) error {
390391
*out = *vi
391392
return err
392393
}
394+
395+
// PathJoinPosix joins two paths, and makes it explicitly clear we want POSIX slashes
396+
func PathJoinPosix(left, right string) string {
397+
return path.Join(left, right)
398+
}

lib/fsi_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func TestDscacheCheckout(t *testing.T) {
199199
run.ChdirToRoot()
200200

201201
// Checkout the dataset, which should update the dscache
202-
checkoutPath := filepath.Join(run.TmpDir, "cities_ds")
202+
checkoutPath := PathJoinPosix(run.TmpDir, "cities_ds")
203203
run.Checkout("me/cities_ds", checkoutPath)
204204

205205
// Access the dscache

lib/lib.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,8 @@ func NewInstance(ctx context.Context, repoPath string, opts ...Option) (qri *Ins
527527
go inst.waitForAllDone()
528528
go func() {
529529
if err := inst.bus.Publish(ctx, event.ETInstanceConstructed, nil); err != nil {
530-
log.Error(err)
530+
log.Debugf("instance construction: %w", err)
531+
err = nil
531532
}
532533
}()
533534

lib/lib_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os"
99
"path/filepath"
1010
"reflect"
11+
"runtime"
1112
"sync"
1213
"testing"
1314
"time"
@@ -248,10 +249,15 @@ func addNowTransformDataset(t *testing.T, node *p2p.QriNode) dsref.Ref {
248249
}
249250

250251
func TestInstanceEventSubscription(t *testing.T) {
252+
timeoutMs := time.Millisecond*250
253+
if runtime.GOOS == "windows" {
254+
// TODO(dustmop): Why is windows slow? Perhaps its due to the IPFS lock.
255+
timeoutMs = time.Millisecond*2500
256+
}
251257
// TODO (b5) - can't use testrunner for this test because event busses aren't
252258
// wired up correctly in the test runner constructor. The proper fix is to have
253259
// testrunner build it's instance using NewInstance
254-
ctx, done := context.WithTimeout(context.Background(), time.Millisecond*250)
260+
ctx, done := context.WithTimeout(context.Background(), timeoutMs)
255261
defer done()
256262

257263
tmpDir, err := ioutil.TempDir("", "event_sub_test")

lib/test_runner_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (tr *testRunner) ChdirToRoot() {
131131
}
132132

133133
func (tr *testRunner) CreateAndChdirToWorkDir(subdir string) string {
134-
tr.WorkDir = filepath.Join(tr.TmpDir, subdir)
134+
tr.WorkDir = PathJoinPosix(tr.TmpDir, subdir)
135135
err := os.Mkdir(tr.WorkDir, 0755)
136136
if err != nil {
137137
panic(err)

0 commit comments

Comments
 (0)