Skip to content

Commit

Permalink
Revert "Test Sync() call when calling AddSync"
Browse files Browse the repository at this point in the history
This reverts commit 9da32f3.
  • Loading branch information
Akshay Shah committed Mar 13, 2017
1 parent fe6ede6 commit 6ed63f7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 30 deletions.
14 changes: 0 additions & 14 deletions zapcore/write_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,12 @@ type WriteSyncer interface {
func AddSync(w io.Writer) WriteSyncer {
switch w := w.(type) {
case WriteSyncer:
if !checkSync(w.(WriteSyncer)) {
return writerWrapper{w}
}
return w
default:
return writerWrapper{w}
}
}

// checkSync executes a Sync() on the WriteSyncer to check whether it operates
// cleanly. In the particular case of the WriteSyncer being a special file,
// calling Sync will return an `os.ErrInvalid` error. If, for whatever reason,
// the call of `Sync()` returns an error, this will return a `false`.
func checkSync(w WriteSyncer) bool {
if err := w.Sync(); err != nil {
return false
}
return true
}

type lockedWriteSyncer struct {
sync.Mutex
ws WriteSyncer
Expand Down
16 changes: 0 additions & 16 deletions zapcore/write_syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ package zapcore
import (
"bytes"
"errors"
"io/ioutil"
"os"
"testing"

"io"
Expand Down Expand Up @@ -67,20 +65,6 @@ func TestAddSyncWriter(t *testing.T) {
assert.NoError(t, ws.Sync(), "Unexpected error calling a no-op Sync method.")
}

func TestCheckSync(t *testing.T) {
assert.False(t, checkSync(os.Stdout), "Expected os.Stdout to fail sync check")
assert.False(t, checkSync(os.Stderr), "Expected os.Stderr to fail sync check")

// Test a real file, which should pass
tmpFile, err := ioutil.TempFile("/tmp", "zapcore-test")
if err != nil {
t.SkipNow()
return
}
defer tmpFile.Close()
assert.True(t, checkSync(tmpFile), "Expected os.Stderr to fail sync check")
}

func TestMultiWriteSyncerWritesBoth(t *testing.T) {
first := &bytes.Buffer{}
second := &bytes.Buffer{}
Expand Down

0 comments on commit 6ed63f7

Please sign in to comment.