From f4e76d83091b43e88bb2a832c3b6424c3cc17e1d Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 31 Jan 2011 18:36:28 -0500 Subject: replace non-blocking send, receive syntax with select R=golang-dev, nigeltao, niemeyer, r CC=golang-dev https://golang.org/cl/4079053 --- src/pkg/path/path_test.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/pkg/path/path_test.go') diff --git a/src/pkg/path/path_test.go b/src/pkg/path/path_test.go index 6b4be07a95..ab0b48ad6a 100644 --- a/src/pkg/path/path_test.go +++ b/src/pkg/path/path_test.go @@ -256,8 +256,11 @@ func TestWalk(t *testing.T) { // 2) handle errors, expect none errors := make(chan os.Error, 64) Walk(tree.name, v, errors) - if err, ok := <-errors; ok { + select { + case err := <-errors: t.Errorf("no error expected, found: %s", err) + default: + // ok } checkMarks(t) @@ -276,14 +279,21 @@ func TestWalk(t *testing.T) { errors = make(chan os.Error, 64) os.Chmod(Join(tree.name, tree.entries[1].name), 0) Walk(tree.name, v, errors) + Loop: for i := 1; i <= 2; i++ { - if _, ok := <-errors; !ok { + select { + case <-errors: + // ok + default: t.Errorf("%d. error expected, none found", i) - break + break Loop } } - if err, ok := <-errors; ok { + select { + case err := <-errors: t.Errorf("only two errors expected, found 3rd: %v", err) + default: + // ok } // the inaccessible subtrees were marked manually checkMarks(t) -- cgit v1.3-5-g9baa