mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-11 02:59:34 -06:00
Flush() output from noms diff to ensure results are printed.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
42
cmd/noms/noms_diff_test.go
Normal file
42
cmd/noms/noms_diff_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user