kubo/test/sharness
Jeromy b3828f4d48 fix small typo
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
2017-06-27 19:20:41 -07:00
..
lib test: fix ulimit tests for 2048 fds 2017-03-24 20:56:09 +01:00
t0051-object-data
t0053-dag-data
t0060-data
.gitignore
Makefile
README.md
Rules.mk Corenet API: Use simple util instead of socat for tests 2017-05-31 11:33:17 +02:00
t0010-basic-commands.sh test: add test for checking if commands mans lengths are shorter than 80 2017-03-10 19:05:34 +01:00
t0015-basic-sh-functions.sh
t0020-init.sh
t0021-config.sh
t0022-init-default.sh
t0023-shutdown.sh fix shutdown check in t0023 2017-06-10 11:32:46 -07:00
t0030-mount.sh
t0031-mount-publish.sh
t0040-add-and-cat.sh adder: add support for specifying the hash function 2017-05-14 17:38:32 -04:00
t0042-add-skip.sh
t0043-add-w.sh adder: add support for using CidV1 2017-04-25 23:36:39 -04:00
t0044-add-symlink.sh adder: add support for using CidV1 2017-04-25 23:36:39 -04:00
t0045-ls.sh
t0050-block.sh
t0051-object.sh
t0052-object-diff.sh
t0053-dag.sh
t0060-daemon.sh test: fix ulimit tests for 2048 fds 2017-03-24 20:56:09 +01:00
t0061-daemon-opts.sh
t0062-daemon-api.sh
t0063-daemon-init.sh daemon: use fsrepo.IsInitialized to test for initialization 2017-03-22 04:25:57 -04:00
t0063-external.sh
t0065-active-requests.sh
t0066-migration.sh
t0070-user-config.sh
t0080-repo.sh Add MaxStorage field to output of "repo stat". 2017-05-10 23:41:35 -04:00
t0081-repo-pinning.sh
t0082-repo-gc-auto.sh
t0083-repo-fsck.sh
t0084-repo-read-rehash.sh
t0085-pins.sh
t0086-repo-verify.sh
t0087-repo-robust-gc.sh gc: add option to stream errors 2017-03-06 14:26:14 -05:00
t0090-get.sh fix: ipfs get panic with empty API call 2017-03-09 15:42:15 +01:00
t0100-name.sh add sharness tests 2017-05-03 06:19:30 +03:00
t0101-iptb-name.sh
t0110-gateway.sh
t0111-gateway-writeable.sh
t0112-gateway-cors.sh
t0120-bootstrap.sh
t0121-bootstrap-iptb.sh
t0125-twonode.sh Add more info to bitswap stat 2017-03-06 09:47:53 +01:00
t0130-multinode.sh feat: remove broken spdy multiplexer and enable mplex by default 2017-03-01 23:28:05 -08:00
t0131-multinode-client-routing.sh
t0140-swarm.sh
t0141-addfilter.sh
t0150-clisuggest.sh
t0151-sysdiag.sh
t0160-resolve.sh
t0165-keystore.sh Add a test for failure of 'ipfs key rm self' 2017-05-14 21:01:18 +09:00
t0170-dht.sh
t0180-p2p.sh Don't use wait in p2p sharness test 2017-06-21 18:35:17 +02:00
t0180-pubsub.sh
t0181-private-network.sh deps: update dependencies for PNet 2017-02-22 20:04:43 +01:00
t0200-unixfs-ls.sh
t0210-tar.sh
t0220-bitswap.sh Add more info to bitswap stat 2017-03-06 09:47:53 +01:00
t0230-channel-streaming-http-content-type.sh
t0231-channel-streaming.sh
t0235-cli-request.sh
t0240-republisher.sh repub: iterate through all keys in keystore 2017-06-07 14:35:44 -04:00
t0250-files-api.sh fix small typo 2017-06-27 19:20:41 -07:00
t0251-files-flushing.sh
t0252-files-gc.sh
t0260-sharding-flag.sh Fix sharding memory growth, and fix resolver for unixfs paths 2017-04-30 13:48:28 -07:00
t0270-filestore.sh test: skip not necessary var assigment 2017-03-08 00:07:18 +01:00
t0271-filestore-utils.sh filestore: add "--file-order" option to "filestore ls" and "verify" 2017-05-23 17:40:20 -04:00
t0300-docker-image.sh
t0301-docker-migrate.sh
t0400-api-security.sh
t0500-issues-and-regressions-offline.sh
t0600-issues-and-regressions-online.sh test: added issue number to regression test 2017-03-08 00:12:52 +01:00
x0601-pin-fail-test.sh

ipfs whole tests using the sharness framework

Running all the tests

Just use make in this directory to run all the tests. Run with TEST_VERBOSE=1 to get helpful verbose output.

TEST_VERBOSE=1 make

The usual ipfs env flags also apply:

# the output will make your eyes bleed
IPFS_LOGGING=debug TEST_VERBOSE=1 make

Running just one test

You can run only one test script by launching it like a regular shell script:

$ ./t0010-basic-commands.sh

Debugging one test

You can use the -v option to make it verbose and the -i option to make it stop as soon as one test fails. For example:

$ ./t0010-basic-commands.sh -v -i

Sharness

When running sharness tests from main Makefile or when test_sharness_deps target is run dependencies for sharness will be downloaded from its github repo and installed in a "lib/sharness" directory.

Please do not change anything in the "lib/sharness" directory.

If you really need some changes in sharness, please fork it from its cannonical repo and send pull requests there.

Writing Tests

Please have a look at existing tests and try to follow their example.

When possible and not too inefficient, that means most of the time, an ipfs command should not be on the left side of a pipe, because if the ipfs command fails (exit non zero), the pipe will mask this failure. For example after false | true, echo $? prints 0 (despite false failing).

It should be possible to put most of the code inside test_expect_success, or sometimes test_expect_failure, blocks, and to chain all the commands inside those blocks with &&, or || for diagnostic commands.

Diagnostics

Make your test case output helpful for when running sharness verbosely. This means cating certain files, or running diagnostic commands. For example:

test_expect_success ".ipfs/ has been created" '
  test -d ".ipfs" &&
  test -f ".ipfs/config" &&
  test -d ".ipfs/datastore" &&
  test -d ".ipfs/blocks" ||
  test_fsh ls -al .ipfs
'

The || ... is a diagnostic run when the preceding command fails. test_fsh is a shell function that echoes the args, runs the cmd, and then also fails, making sure the test case fails. (wouldnt want the diagnostic accidentally returning true and making it seem like the test case succeeded!).

Testing commands on daemon or mounted

Use the provided functions in lib/test-lib.sh to run the daemon or mount:

To init, run daemon, and mount in one go:

test_launch_ipfs_daemon_and_mount

test_expect_success "'ipfs add --help' succeeds" '
  ipfs add --help >actual
'

# other tests here...

# dont forget to kill the daemon!!
test_kill_ipfs_daemon

To init, run daemon, and then mount separately:

test_init_ipfs

# tests inited but not running here

test_launch_ipfs_daemon

# tests running but not mounted here

test_mount_ipfs

# tests mounted here

# dont forget to kill the daemon!!
test_kill_ipfs_daemon