Commit 53fe9c9b authored by Kejie Zhang's avatar Kejie Zhang

add ipfs help sub-command test

License: MIT
Signed-off-by: default avatarKejie Zhang <601172892@qq.com>
parent 08c75aa7
......@@ -93,9 +93,13 @@ func mainRet() int {
if os.Args[1] == "help" {
if len(os.Args) > 2 {
os.Args = append(os.Args[:1], os.Args[2:]...)
os.Args = append(os.Args, "-h")
// Handle `ipfs help --help`
// append `--help`,when the command is not `ipfs help --help`
if os.Args[1] != "--help" {
os.Args = append(os.Args, "--help")
}
} else {
os.Args[1] = "-h"
os.Args[1] = "--help"
}
}
}
......
......@@ -41,26 +41,6 @@ test_expect_success "ipfs version --all has all required fields" '
grep "Golang version" version_all.txt
'
test_expect_success "ipfs help succeeds" '
ipfs help >help.txt
'
test_expect_success "ipfs help output looks good" '
egrep -i "^Usage" help.txt >/dev/null &&
egrep "ipfs <command>" help.txt >/dev/null ||
test_fsh cat help.txt
'
test_expect_success "ipfs help --help succeeds" '
ipfs help --help >help.txt
'
test_expect_success "ipfs help --help output looks good" '
egrep -i "^Usage" help.txt >/dev/null &&
egrep "ipfs <command>" help.txt >/dev/null ||
test_fsh cat help.txt
'
test_expect_success "'ipfs commands' succeeds" '
ipfs commands >commands.txt
'
......@@ -71,6 +51,21 @@ test_expect_success "'ipfs commands' output looks good" '
grep "ipfs update" commands.txt
'
test_expect_success "All sub-commands accept help" '
echo 0 > fail
while read -r cmd
do
${cmd:0:4} help ${cmd:5} >/dev/null ||
{ echo "$cmd doesnt accept --help"; echo 1 > fail; }
echo stuff | $cmd --help >/dev/null ||
{ echo "$cmd doesnt accept --help when using stdin"; echo 1 > fail; }
done <commands.txt
if [ $(cat fail) = 1 ]; then
return 1
fi
'
test_expect_success "All commands accept --help" '
echo 0 > fail
while read -r cmd
......
......@@ -80,16 +80,6 @@ test_expect_success "ipfs help output looks good" '
test_fsh cat help.txt
'
test_expect_success "ipfs help --help succeeds" '
ipfs help --help >help.txt
'
test_expect_success "ipfs help --help output looks good" '
egrep -i "^Usage" help.txt >/dev/null &&
egrep "ipfs .* <command>" help.txt >/dev/null ||
test_fsh cat help.txt
'
# netcat (nc) is needed for the following test
test_expect_success "nc is available" '
type nc >/dev/null
......
......@@ -158,10 +158,6 @@ test_expect_success "'ipfs name publish --help' succeeds" '
ipfs name publish --help
'
test_expect_success "'ipfs help name publish' succeeds" '
ipfs help name publish
'
test_launch_ipfs_daemon
test_expect_success "empty request to name publish doesn't panic and returns error" '
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment