kubo/test/sharness
Steven Allen 8293e20aae fix the repo verify test
We've added a new file to the flatfs datastore.

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
2018-06-01 23:39:32 -07:00
..
lib ci: Collect test times for sharness 2018-04-21 22:40:03 +02:00
t0024-files fix t0024 on osx 2017-09-03 18:43:18 -07:00
t0051-object-data no newlines in json objects 2015-11-30 15:23:48 -08:00
t0053-dag-data fix printing out of binary escaped data for test 2017-02-09 10:31:18 -08:00
t0060-data multistream tests use data from file 2016-04-07 15:55:41 -07:00
t0110-gateway-data gateway: fix seeker can't seek on specific files 2017-10-18 20:10:22 +02:00
t0275-cid-security-data cidsec: add test for command closing right away 2018-04-20 17:07:39 +02:00
t0280-plugin-git-data git: add git plugin tests 2017-07-12 23:38:32 +02:00
.gitignore make(sharness): add plugins as part of sharness build 2017-07-12 21:53:59 +02:00
Makefile make: make default rule 'aggregate' in sharness 2017-02-12 01:18:40 +01:00
README.md misc: Fix a few typos 2018-03-30 09:47:22 +02:00
Rules.mk sharness/junit: fixes after review 2018-04-10 18:31:25 +02:00
t0010-basic-commands.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0015-basic-sh-functions.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0018-indent.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0020-init.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0021-config.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0022-init-default.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0023-shutdown.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0024-datastore-config.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0025-datastores.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0030-mount.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0031-mount-publish.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0040-add-and-cat.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0041-ping.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0042-add-skip.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0043-add-w.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0044-add-symlink.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0045-ls.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0050-block.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0051-object.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0052-object-diff.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0053-dag.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0060-daemon.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0061-daemon-opts.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0062-daemon-api.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0063-daemon-init.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0063-external.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0065-active-requests.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0066-migration.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0070-user-config.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0080-repo.sh sharness/junit: fixes after review 2018-04-10 18:31:25 +02:00
t0081-repo-pinning.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0082-repo-gc-auto.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0083-repo-fsck.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0084-repo-read-rehash.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0085-pins.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0086-repo-verify.sh fix the repo verify test 2018-06-01 23:39:32 -07:00
t0087-repo-robust-gc.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0088-repo-stat-symlink.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0090-get.sh remove extra newline from expected command output 2018-05-31 18:29:22 -07:00
t0100-name.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0101-iptb-name.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0110-gateway.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0111-gateway-writeable.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0112-gateway-cors.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0120-bootstrap.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0121-bootstrap-iptb.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0125-twonode.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0130-multinode.sh fix: reduced number of leafs in multinode test's file tree 2018-04-22 19:07:28 +02:00
t0131-multinode-client-routing.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0140-swarm.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0141-addfilter.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0150-clisuggest.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0151-sysdiag.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0160-resolve.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0165-keystore.sh fix keystore tests for peer ID inlining patch 2018-05-31 18:29:22 -07:00
t0170-dht.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0175-reprovider.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0180-p2p.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0180-pubsub.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0181-private-network.sh fix: add timeout to iptb connect in sharness 2018-04-23 20:22:05 +02:00
t0182-circuit-relay.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0183-namesys-pubsub.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0200-unixfs-ls.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0210-tar.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0220-bitswap.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0230-channel-streaming-http-content-type.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0231-channel-streaming.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0235-cli-request.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0240-republisher.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0250-files-api.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0251-files-flushing.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0252-files-gc.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0260-sharding.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0270-filestore.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0271-filestore-utils.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0275-cid-security.sh cidsec: add test for command closing right away 2018-04-20 17:07:39 +02:00
t0280-plugin-git.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0300-docker-image.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0301-docker-migrate.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0400-api-security.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0410-api-add.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0500-issues-and-regressions-offline.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0600-issues-and-regressions-online.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
x0601-pin-fail-test.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00

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. (wouldn't 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