Flush() output from noms diff to ensure results are printed.

This commit is contained in:
Dan Willhite
2016-07-19 14:41:58 -07:00
parent f52844e2b6
commit ac4472eed7
2 changed files with 44 additions and 2 deletions

View File

@@ -52,8 +52,6 @@ func runDiff(args []string) int {
defer db2.Close()
waitChan := outputpager.PageOutput()
w := bufio.NewWriter(os.Stdout)
if waitChan != nil {
go func() {
<-waitChan
@@ -61,6 +59,8 @@ func runDiff(args []string) int {
}()
}
w := bufio.NewWriter(os.Stdout)
diff.Diff(w, value1, value2)
w.Flush()
return 0
}

View File

@@ -0,0 +1,42 @@
// Copyright 2016 Attic Labs, Inc. All rights reserved.
// Licensed under the Apache License, version 2.0:
// http://www.apache.org/licenses/LICENSE-2.0
package main
import (
"testing"
"github.com/attic-labs/noms/go/spec"
"github.com/attic-labs/noms/go/util/clienttest"
"github.com/attic-labs/testify/suite"
)
type nomsDiffTestSuite struct {
clienttest.ClientTestSuite
}
func TestNomsDiff(t *testing.T) {
suite.Run(t, &nomsDiffTestSuite{})
}
func (s *nomsDiffTestSuite) TestNomsDiffOutputNotTruncated() {
datasetName := "diffTest"
str := spec.CreateValueSpecString("ldb", s.LdbDir, datasetName)
ds, err := spec.GetDataset(str)
s.NoError(err)
ds, err = addCommit(ds, "first commit")
s.NoError(err)
r1 := spec.CreateValueSpecString("ldb", s.LdbDir, "#"+ds.HeadRef().TargetHash().String())
ds, err = addCommit(ds, "second commit")
s.NoError(err)
r2 := spec.CreateValueSpecString("ldb", s.LdbDir, "#"+ds.HeadRef().TargetHash().String())
ds.Database().Close()
out, _ := s.Run(main, []string{"diff", r1, r2})
if s.True(len(out) > 3) {
s.Equal(out[len(out)-2:], "}\n")
}
}