@cryptotaxi247 / kubo / commits / f67522e3f

sharness/README: add writing tests and debugging

Add information from the discussion of PR #891. While at it, suggest using -v and -i options to debug one test. License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>

Christian Couder committed Mar 9, 2015 at 14:46 UTC f67522e3f37616fd3da9ffaf053c99344b4b7ba0
1 file changed +21 -1
test/sharness/README.md
+21 -1
@@ -16,7 +16,6 @@ The usual ipfs env flags also apply:
16 IPFS_LOGGING=debug TEST_VERBOSE=1 make
17 ```
18
19 -
19 ## Running just one test
20
21 You can run only one test script by launching it like a regular shell
@@ -26,6 +25,16 @@ script:
25 $ ./t0010-basic-commands.sh
26 ```
27
28 +## Debugging one test
29 +
30 +You can use the `-v` option to make it verbose and the `-i` option to
31 +make it stop as soon as one test fails.
32 +For example:
33 +
34 +```
35 +$ ./t0010-basic-commands.sh -v -i
36 +```
37 +
38 ## Sharness
39
40 When running "make" in this directory for the first time, sharness
@@ -40,6 +49,17 @@ send pull requests there.
49
50 ## Writing Tests
51
52 +Please have a look at existing tests and try to follow their example.
53 +
54 +When possible and not too inefficient, that means most of the time,
55 +an ipfs command should not be on the left side of a pipe, because if
56 +the ipfs command fails (exit non zero), the pipe will mask this failure.
57 +For example after `false | true`, `echo $?` prints 0 (despite `false`
58 +failing).
59 +
60 +It should be possible to put most of the code inside `test_expect_success`,
61 +or sometimes `test_expect_failure`, blocks, and to chain all the commands
62 +inside those blocks with `&&`, or `||` for diagnostic commands.
63
64 ### Diagnostics
65