mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-01 22:37:51 +08:00
updated goprocess for godep restore test
This commit is contained in:
parent
b01663ed43
commit
7e8a17aa7d
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@ -185,7 +185,7 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/jbenet/goprocess",
|
||||
"Rev": "c37725a4a97d6ad772818b071ceef82789562142"
|
||||
"Rev": "c5455a611a9e0cebac87e7ae421c3273c3224000"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/kr/binarydist",
|
||||
|
||||
3
Godeps/_workspace/src/github.com/jbenet/goprocess/.travis.yml
generated
vendored
3
Godeps/_workspace/src/github.com/jbenet/goprocess/.travis.yml
generated
vendored
@ -1,11 +1,10 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.2
|
||||
- 1.3
|
||||
- 1.4
|
||||
- release
|
||||
- tip
|
||||
|
||||
script:
|
||||
- go test -v ./...
|
||||
- go test -race -cpu=5 -v ./...
|
||||
|
||||
56
Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess_test.go
generated
vendored
56
Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess_test.go
generated
vendored
@ -29,15 +29,18 @@ func setupHierarchy(p Process) tree {
|
||||
|
||||
func TestClosingClosed(t *testing.T) {
|
||||
|
||||
bWait := make(chan struct{})
|
||||
a := WithParent(Background())
|
||||
b := WithParent(a)
|
||||
a.Go(func(proc Process) {
|
||||
<-bWait
|
||||
})
|
||||
|
||||
Q := make(chan string, 3)
|
||||
|
||||
go func() {
|
||||
<-a.Closing()
|
||||
Q <- "closing"
|
||||
b.Close()
|
||||
bWait <- struct{}{}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
@ -149,7 +152,7 @@ func TestTeardownCalledOnce(t *testing.T) {
|
||||
a.c[1].Close()
|
||||
}
|
||||
|
||||
func TestOnClosed(t *testing.T) {
|
||||
func TestOnClosedAll(t *testing.T) {
|
||||
|
||||
Q := make(chan string, 10)
|
||||
p := WithParent(Background())
|
||||
@ -165,12 +168,39 @@ func TestOnClosed(t *testing.T) {
|
||||
|
||||
go p.Close()
|
||||
|
||||
testStrs(t, Q, "00", "01", "10", "11")
|
||||
testStrs(t, Q, "00", "01", "10", "11")
|
||||
testStrs(t, Q, "00", "01", "10", "11")
|
||||
testStrs(t, Q, "00", "01", "10", "11")
|
||||
testStrs(t, Q, "0", "1")
|
||||
testStrs(t, Q, "0", "1")
|
||||
testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
|
||||
testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
|
||||
testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
|
||||
testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
|
||||
testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
|
||||
testStrs(t, Q, "00", "01", "10", "11", "0", "1", "")
|
||||
}
|
||||
|
||||
func TestOnClosedLeaves(t *testing.T) {
|
||||
|
||||
Q := make(chan string, 10)
|
||||
p := WithParent(Background())
|
||||
a := setupHierarchy(p)
|
||||
|
||||
go onClosedStr(Q, "0", a.c[0])
|
||||
go onClosedStr(Q, "10", a.c[1].c[0])
|
||||
go onClosedStr(Q, "", a)
|
||||
go onClosedStr(Q, "00", a.c[0].c[0])
|
||||
go onClosedStr(Q, "1", a.c[1])
|
||||
go onClosedStr(Q, "01", a.c[0].c[1])
|
||||
go onClosedStr(Q, "11", a.c[1].c[1])
|
||||
|
||||
go a.c[0].Close()
|
||||
testStrs(t, Q, "00", "01", "0")
|
||||
testStrs(t, Q, "00", "01", "0")
|
||||
testStrs(t, Q, "00", "01", "0")
|
||||
|
||||
go a.c[1].Close()
|
||||
testStrs(t, Q, "10", "11", "1")
|
||||
testStrs(t, Q, "10", "11", "1")
|
||||
testStrs(t, Q, "10", "11", "1")
|
||||
|
||||
go p.Close()
|
||||
testStrs(t, Q, "")
|
||||
}
|
||||
|
||||
@ -370,6 +400,7 @@ func TestCloseAfterChildren(t *testing.T) {
|
||||
<-p.Closing() // wait till we're told to close (parents mustnt)
|
||||
})
|
||||
ready <- struct{}{}
|
||||
// <-p.Closing() // will CloseAfterChildren
|
||||
})
|
||||
a.Go(func(p Process) {
|
||||
d = p
|
||||
@ -379,6 +410,7 @@ func TestCloseAfterChildren(t *testing.T) {
|
||||
<-p.Closing() // wait till we're told to close (parents mustnt)
|
||||
})
|
||||
ready <- struct{}{}
|
||||
<-p.Closing()
|
||||
})
|
||||
|
||||
<-ready
|
||||
@ -397,6 +429,7 @@ func TestCloseAfterChildren(t *testing.T) {
|
||||
aDone := make(chan struct{})
|
||||
bDone := make(chan struct{})
|
||||
|
||||
t.Log("test none when waiting on a")
|
||||
testNone(t, Q)
|
||||
go func() {
|
||||
a.CloseAfterChildren()
|
||||
@ -404,6 +437,7 @@ func TestCloseAfterChildren(t *testing.T) {
|
||||
}()
|
||||
testNone(t, Q)
|
||||
|
||||
t.Log("test none when waiting on b")
|
||||
go func() {
|
||||
b.CloseAfterChildren()
|
||||
bDone <- struct{}{}
|
||||
@ -482,8 +516,8 @@ func testNotClosed(t *testing.T, p Process) {
|
||||
|
||||
func testNone(t *testing.T, c <-chan string) {
|
||||
select {
|
||||
case <-c:
|
||||
t.Fatal("none should be closed")
|
||||
case out := <-c:
|
||||
t.Fatal("none should be closed", out)
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
4
Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go
generated
vendored
4
Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go
generated
vendored
@ -82,8 +82,8 @@ func (p *process) Go(f ProcessFunc) Process {
|
||||
child.WaitFor(waitFor) // prevent child from closing
|
||||
go func() {
|
||||
f(child)
|
||||
waitFor.Close() // allow child to close.
|
||||
child.Close() // close to tear down.
|
||||
waitFor.Close() // allow child to close.
|
||||
child.CloseAfterChildren() // close to tear down.
|
||||
}()
|
||||
return child
|
||||
}
|
||||
|
||||
4
Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit/ratelimit_test.go
generated
vendored
4
Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit/ratelimit_test.go
generated
vendored
@ -46,7 +46,7 @@ func TestRateLimitLimitedGoBlocks(t *testing.T) {
|
||||
t.Log("should be done spawning.")
|
||||
select {
|
||||
case <-doneSpawning:
|
||||
case <-time.After(time.Millisecond): // for scheduler
|
||||
case <-time.After(100 * time.Millisecond): // for scheduler
|
||||
t.Error("still blocked...")
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ func TestRateLimitGoDoesntBlock(t *testing.T) {
|
||||
select {
|
||||
case <-doneSpawning:
|
||||
t.Log("did not block")
|
||||
case <-time.After(time.Millisecond): // for scheduler
|
||||
case <-time.After(100 * time.Millisecond): // for scheduler
|
||||
t.Error("process.Go blocked. it should not.")
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user