updated goprocess for godep restore test
Juan Batiz-Benet committed
Jan 24, 2015 at 09:33 UTC
7e8a17aa7d0034994266befaec4978ac2a5e172d
5 files changed
+51
-18
Godeps/Godeps.json
+1
-1
@@ -185,7 +185,7 @@
185
},
186
{
187
"ImportPath": "github.com/jbenet/goprocess",
188
- "Rev": "c37725a4a97d6ad772818b071ceef82789562142"
188
+ "Rev": "c5455a611a9e0cebac87e7ae421c3273c3224000"
189
},
190
{
191
"ImportPath": "github.com/kr/binarydist",
Godeps/_workspace/src/github.com/jbenet/goprocess/.travis.yml
+1
-2
@@ -1,11 +1,10 @@
1
language: go
2
3
go:
4
- - 1.2
4
- 1.3
5
- 1.4
6
- release
7
- tip
8
9
script:
11
- - go test -v ./...
10
+ - go test -race -cpu=5 -v ./...
Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess_test.go
+45
-11
@@ -29,15 +29,18 @@ func setupHierarchy(p Process) tree {
29
30
func TestClosingClosed(t *testing.T) {
31
32
+ bWait := make(chan struct{})
33
a := WithParent(Background())
33
- b := WithParent(a)
34
+ a.Go(func(proc Process) {
35
+ <-bWait
36
+ })
37
38
Q := make(chan string, 3)
39
40
go func() {
41
<-a.Closing()
42
Q <- "closing"
40
- b.Close()
43
+ bWait <- struct{}{}
44
}()
45
46
go func() {
@@ -149,7 +152,7 @@ func TestTeardownCalledOnce(t *testing.T) {
152
a.c[1].Close()
153
}
154
152
-func TestOnClosed(t *testing.T) {
155
+func TestOnClosedAll(t *testing.T) {
156
157
Q := make(chan string, 10)
158
p := WithParent(Background())
@@ -165,12 +168,39 @@ func TestOnClosed(t *testing.T) {
168
169
go p.Close()
170
168
- testStrs(t, Q, "00", "01", "10", "11")
169
- testStrs(t, Q, "00", "01", "10", "11")
170
- testStrs(t, Q, "00", "01", "10", "11")
171
- testStrs(t, Q, "00", "01", "10", "11")
172
- testStrs(t, Q, "0", "1")
173
- testStrs(t, Q, "0", "1")
171
+ testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
172
+ testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
173
+ testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
174
+ testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
175
+ testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
176
+ testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
177
+}
178
+
179
+func TestOnClosedLeaves(t *testing.T) {
180
+
181
+ Q := make(chan string, 10)
182
+ p := WithParent(Background())
183
+ a := setupHierarchy(p)
184
+
185
+ go onClosedStr(Q, "0", a.c[0])
186
+ go onClosedStr(Q, "10", a.c[1].c[0])
187
+ go onClosedStr(Q, "", a)
188
+ go onClosedStr(Q, "00", a.c[0].c[0])
189
+ go onClosedStr(Q, "1", a.c[1])
190
+ go onClosedStr(Q, "01", a.c[0].c[1])
191
+ go onClosedStr(Q, "11", a.c[1].c[1])
192
+
193
+ go a.c[0].Close()
194
+ testStrs(t, Q, "00", "01", "0")
195
+ testStrs(t, Q, "00", "01", "0")
196
+ testStrs(t, Q, "00", "01", "0")
197
+
198
+ go a.c[1].Close()
199
+ testStrs(t, Q, "10", "11", "1")
200
+ testStrs(t, Q, "10", "11", "1")
201
+ testStrs(t, Q, "10", "11", "1")
202
+
203
+ go p.Close()
204
testStrs(t, Q, "")
205
}
206
@@ -370,6 +400,7 @@ func TestCloseAfterChildren(t *testing.T) {
400
<-p.Closing() // wait till we're told to close (parents mustnt)
401
})
402
ready <- struct{}{}
403
+ // <-p.Closing() // will CloseAfterChildren
404
})
405
a.Go(func(p Process) {
406
d = p
@@ -379,6 +410,7 @@ func TestCloseAfterChildren(t *testing.T) {
410
<-p.Closing() // wait till we're told to close (parents mustnt)
411
})
412
ready <- struct{}{}
413
+ <-p.Closing()
414
})
415
416
<-ready
@@ -397,6 +429,7 @@ func TestCloseAfterChildren(t *testing.T) {
429
aDone := make(chan struct{})
430
bDone := make(chan struct{})
431
432
+ t.Log("test none when waiting on a")
433
testNone(t, Q)
434
go func() {
435
a.CloseAfterChildren()
@@ -404,6 +437,7 @@ func TestCloseAfterChildren(t *testing.T) {
437
}()
438
testNone(t, Q)
439
440
+ t.Log("test none when waiting on b")
441
go func() {
442
b.CloseAfterChildren()
443
bDone <- struct{}{}
@@ -482,8 +516,8 @@ func testNotClosed(t *testing.T, p Process) {
516
517
func testNone(t *testing.T, c <-chan string) {
518
select {
485
- case <-c:
486
- t.Fatal("none should be closed")
519
+ case out := <-c:
520
+ t.Fatal("none should be closed", out)
521
default:
522
}
523
}
Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go
+2
-2
@@ -82,8 +82,8 @@ func (p *process) Go(f ProcessFunc) Process {
82
child.WaitFor(waitFor) // prevent child from closing
83
go func() {
84
f(child)
85
- waitFor.Close() // allow child to close.
86
- child.Close() // close to tear down.
85
+ waitFor.Close() // allow child to close.
86
+ child.CloseAfterChildren() // close to tear down.
87
}()
88
return child
89
}
Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit/ratelimit_test.go
+2
-2
@@ -46,7 +46,7 @@ func TestRateLimitLimitedGoBlocks(t *testing.T) {
46
t.Log("should be done spawning.")
47
select {
48
case <-doneSpawning:
49
- case <-time.After(time.Millisecond): // for scheduler
49
+ case <-time.After(100 * time.Millisecond): // for scheduler
50
t.Error("still blocked...")
51
}
52
@@ -84,7 +84,7 @@ func TestRateLimitGoDoesntBlock(t *testing.T) {
84
select {
85
case <-doneSpawning:
86
t.Log("did not block")
87
- case <-time.After(time.Millisecond): // for scheduler
87
+ case <-time.After(100 * time.Millisecond): // for scheduler
88
t.Error("process.Go blocked. it should not.")
89
}
90