Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
39716077
提交
39716077
authored
6月 07, 2015
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1341 from ipfs/use-go-sleep
Use github.com/chriscool/go-sleep
上级
268894c8
14a3315d
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
104 行增加
和
19 行删除
+104
-19
Godeps.json
Godeps/Godeps.json
+4
-0
LICENSE
Godeps/_workspace/src/github.com/chriscool/go-sleep/LICENSE
+22
-0
README.md
...ps/_workspace/src/github.com/chriscool/go-sleep/README.md
+32
-0
go-sleep.go
.../_workspace/src/github.com/chriscool/go-sleep/go-sleep.go
+27
-0
Makefile
test/Makefile
+6
-1
Makefile
test/sharness/Makefile
+1
-1
test-lib.sh
test/sharness/lib/test-lib.sh
+12
-17
没有找到文件。
Godeps/Godeps.json
浏览文件 @
39716077
...
...
@@ -276,6 +276,10 @@
{
"ImportPath"
:
"gopkg.in/tomb.v1"
,
"Rev"
:
"dd632973f1e7218eb1089048e0798ec9ae7dceb8"
},
{
"ImportPath"
:
"github.com/chriscool/go-sleep"
,
"Rev"
:
"743ab5f1bb487edf1772bc29ca0bdf572b40785e"
}
]
}
Godeps/_workspace/src/github.com/chriscool/go-sleep/LICENSE
0 → 100644
浏览文件 @
39716077
The MIT License (MIT)
Copyright (c) 2014 Juan Batiz-Benet
Copyright (c) 2015 Christian Couder
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Godeps/_workspace/src/github.com/chriscool/go-sleep/README.md
0 → 100644
浏览文件 @
39716077
# go-sleep sleeps for some duration
This unix tool is a thin wrapper around
`time.Sleep()`
.
It aims to provide a portable way to sleep for an amount of time that
need not to be a number of seconds.
See https://godoc.org/time#ParseDuration for how the duration can be
specified.
### Install
```
sh
go install github.com/chriscool/go-sleep
```
### Usage:
```
> go-sleep
Usage: go-sleep <duration>
Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
See https://godoc.org/time#ParseDuration for more.
> time go-sleep 100ms
real 0m0.104s
user 0m0.000s
sys 0m0.007s
```
### License
MIT
Godeps/_workspace/src/github.com/chriscool/go-sleep/go-sleep.go
0 → 100644
浏览文件 @
39716077
package
main
import
(
"fmt"
"os"
"time"
)
func
main
()
{
if
len
(
os
.
Args
)
!=
2
{
usageError
()
}
d
,
err
:=
time
.
ParseDuration
(
os
.
Args
[
1
])
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Could not parse duration: %s
\n
"
,
err
)
usageError
()
}
time
.
Sleep
(
d
)
}
func
usageError
()
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Usage: %s <duration>
\n
"
,
os
.
Args
[
0
])
fmt
.
Fprintln
(
os
.
Stderr
,
`Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".`
)
fmt
.
Fprintln
(
os
.
Stderr
,
"See https://godoc.org/time#ParseDuration for more."
)
os
.
Exit
(
-
1
)
}
test/Makefile
浏览文件 @
39716077
BINS
=
bin/random bin/multihash bin/ipfs bin/pollEndpoint bin/iptb
BINS
=
bin/random bin/multihash bin/ipfs bin/pollEndpoint bin/iptb
bin/go-sleep
IPFS_ROOT
=
../
IPFS_CMD
=
../cmd/ipfs
RANDOM_SRC
=
../Godeps/_workspace/src/github.com/jbenet/go-random
MULTIHASH_SRC
=
../Godeps/_workspace/src/github.com/jbenet/go-multihash
IPTB_SRC
=
../Godeps/_workspace/src/github.com/whyrusleeping/iptb
POLLENDPOINT_SRC
=
../thirdparty/pollEndpoint
GOSLEEP_SRC
=
../Godeps/_workspace/src/github.com/chriscool/go-sleep
# User might want to override those on the command line
GOFLAGS
=
...
...
@@ -41,6 +42,10 @@ bin/iptb: $(call find_go_files, $(IPTB_SRC)) IPFS-BUILD-OPTIONS
@
echo
"*** installing
$@
***"
go build
$(GOFLAGS)
-o
bin/iptb
$(IPTB_SRC)
bin/go-sleep
:
$(call find_go_files
,
$(GOSLEEP_SRC)) IPFS-BUILD-OPTIONS
@
echo
"*** installing
$@
***"
go build
$(GOFLAGS)
-o
bin/go-sleep
$(GOSLEEP_SRC)
test
:
test_expensive
test_expensive
:
verify_gofmt
...
...
test/sharness/Makefile
浏览文件 @
39716077
...
...
@@ -8,7 +8,7 @@
T
=
$
(
sort
$
(
wildcard t[0-9][0-9][0-9][0-9]-
*
.sh
))
BINS
=
bin/random bin/multihash bin/ipfs bin/pollEndpoint
\
bin/iptb
bin/iptb
bin/go-sleep
SHARNESS
=
lib/sharness/sharness.sh
IPFS_ROOT
=
../..
...
...
test/sharness/lib/test-lib.sh
浏览文件 @
39716077
...
...
@@ -55,38 +55,33 @@ test_cmp_repeat_10_sec() {
for
i
in
$(
test_seq 1 100
)
do
test_cmp
"
$1
"
"
$2
"
>
/dev/null
&&
return
sleep 0.1
go-sleep 100ms
done
test_cmp
"
$1
"
"
$2
"
}
test_run_repeat_60_sec
()
{
for
i
in
1 2 3 4 5 6
for
i
in
$(
test_seq 1 600
)
do
for
i
in
1 2 3 4 5 6 7 8 9 10
do
(
test_eval_
"
$1
"
)
&&
return
sleep 1
done
(
test_eval_
"
$1
"
)
&&
return
go-sleep 100ms
done
return
1
# failed
}
test_wait_output_n_lines_60_sec
()
{
for
i
in
1 2 3 4 5 6
for
i
in
$(
test_seq 1 600
)
do
for
i
in
1 2 3 4 5 6 7 8 9 10
do
test
$(
cat
"
$1
"
| wc
-l
| tr
-d
" "
)
-ge
$2
&&
return
sleep 1
done
test
$(
cat
"
$1
"
| wc
-l
| tr
-d
" "
)
-ge
$2
&&
return
go-sleep 100ms
done
actual
=
$(
cat
"
$1
"
| wc
-l
| tr
-d
" "
)
test_fsh
"expected
$2
lines of output. got
$actual
"
}
test_wait_open_tcp_port_10_sec
()
{
for
i
in
1 2 3 4 5 6 7 8 9 10
;
do
for
i
in
$(
test_seq 1 100
)
do
# this is not a perfect check, but it's portable.
# cant count on ss. not installed everywhere.
# cant count on netstat using : or . as port delim. differ across platforms.
...
...
@@ -94,7 +89,7 @@ test_wait_open_tcp_port_10_sec() {
if
[
$(
netstat
-aln
| egrep
"^tcp.*LISTEN"
| egrep
"[.:]
$1
"
| wc
-l
)
-gt
0
]
;
then
return
0
fi
sleep 1
go-sleep 100ms
done
return
1
}
...
...
@@ -247,13 +242,13 @@ test_kill_repeat_10_sec() {
kill
$1
for
i
in
$(
test_seq 1 100
)
do
sleep 0.1
go-sleep 100ms
!
kill
-0
$1
2>/dev/null
&&
return
done
# if not, try once more, which will skip graceful exit
kill
$1
sleep 1
go-sleep 1s
!
kill
-0
$1
2>/dev/null
&&
return
# ok, no hope. kill it to prevent it messing with other tests
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论