@cryptotaxi247 / kubo / commits / 53fe9c9bc

add ipfs help sub-command test

License: MIT Signed-off-by: Kejie Zhang <601172892@qq.com>

Kejie Zhang committed Oct 9, 2018 at 16:02 UTC 53fe9c9bcc41b507ee75de51ba5623a7f24023a1
4 files changed +21 -36
cmd/ipfs/main.go
+6 -2
@@ -93,9 +93,13 @@ func mainRet() int {
93 if os.Args[1] == "help" {
94 if len(os.Args) > 2 {
95 os.Args = append(os.Args[:1], os.Args[2:]...)
96 - os.Args = append(os.Args, "-h")
96 + // Handle `ipfs help --help`
97 + // append `--help`,when the command is not `ipfs help --help`
98 + if os.Args[1] != "--help" {
99 + os.Args = append(os.Args, "--help")
100 + }
101 } else {
98 - os.Args[1] = "-h"
102 + os.Args[1] = "--help"
103 }
104 }
105 }
test/sharness/t0010-basic-commands.sh
+15 -20
@@ -41,26 +41,6 @@ test_expect_success "ipfs version --all has all required fields" '
41 grep "Golang version" version_all.txt
42 '
43
44 -test_expect_success "ipfs help succeeds" '
45 - ipfs help >help.txt
46 -'
47 -
48 -test_expect_success "ipfs help output looks good" '
49 - egrep -i "^Usage" help.txt >/dev/null &&
50 - egrep "ipfs <command>" help.txt >/dev/null ||
51 - test_fsh cat help.txt
52 -'
53 -
54 -test_expect_success "ipfs help --help succeeds" '
55 - ipfs help --help >help.txt
56 -'
57 -
58 -test_expect_success "ipfs help --help output looks good" '
59 - egrep -i "^Usage" help.txt >/dev/null &&
60 - egrep "ipfs <command>" help.txt >/dev/null ||
61 - test_fsh cat help.txt
62 -'
63 -
44 test_expect_success "'ipfs commands' succeeds" '
45 ipfs commands >commands.txt
46 '
@@ -71,6 +51,21 @@ test_expect_success "'ipfs commands' output looks good" '
51 grep "ipfs update" commands.txt
52 '
53
54 +test_expect_success "All sub-commands accept help" '
55 + echo 0 > fail
56 + while read -r cmd
57 + do
58 + ${cmd:0:4} help ${cmd:5} >/dev/null ||
59 + { echo "$cmd doesnt accept --help"; echo 1 > fail; }
60 + echo stuff | $cmd --help >/dev/null ||
61 + { echo "$cmd doesnt accept --help when using stdin"; echo 1 > fail; }
62 + done <commands.txt
63 +
64 + if [ $(cat fail) = 1 ]; then
65 + return 1
66 + fi
67 +'
68 +
69 test_expect_success "All commands accept --help" '
70 echo 0 > fail
71 while read -r cmd
test/sharness/t0060-daemon.sh
-10
@@ -80,16 +80,6 @@ test_expect_success "ipfs help output looks good" '
80 test_fsh cat help.txt
81 '
82
83 -test_expect_success "ipfs help --help succeeds" '
84 - ipfs help --help >help.txt
85 -'
86 -
87 -test_expect_success "ipfs help --help output looks good" '
88 - egrep -i "^Usage" help.txt >/dev/null &&
89 - egrep "ipfs .* <command>" help.txt >/dev/null ||
90 - test_fsh cat help.txt
91 -'
92 -
83 # netcat (nc) is needed for the following test
84 test_expect_success "nc is available" '
85 type nc >/dev/null
test/sharness/t0100-name.sh
-4
@@ -158,10 +158,6 @@ test_expect_success "'ipfs name publish --help' succeeds" '
158 ipfs name publish --help
159 '
160
161 -test_expect_success "'ipfs help name publish' succeeds" '
162 - ipfs help name publish
163 -'
164 -
161 test_launch_ipfs_daemon
162
163 test_expect_success "empty request to name publish doesn't panic and returns error" '