kubo/test/sharness
Whyrusleeping a98a4f40d3
Merge pull request #4873 from ipfs/fix/4871
make the tar writer handle sharded ipfs directories
2018-03-25 12:47:40 -07:00
..
lib sharness: increase timeout waiting for api file 2018-01-21 11:11:47 -08: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 cid_secuirty: add test for gc 2018-03-05 19:38:25 +01: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 make: rework makefiles for non-recursive make and add sharness coverage 2017-02-12 01:18:40 +01:00
Rules.mk remove useless make target 2018-02-04 15:11:09 +01:00
t0010-basic-commands.sh sharness/t0010: also check 'echo stuff | $cmd --help' 2018-03-23 10:23:33 +01:00
t0015-basic-sh-functions.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0018-indent.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0020-init.sh config: apply review to lowpower profile 2018-03-24 16:11:42 +01:00
t0021-config.sh config: apply review to lowpower profile 2018-03-24 16:11:42 +01:00
t0022-init-default.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0023-shutdown.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0024-datastore-config.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0025-datastores.sh Update badgerds to 1.1.3 2017-11-12 05:34:31 +01:00
t0030-mount.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0031-mount-publish.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0040-add-and-cat.sh fix add-and-cat test: we no longer set a default CIDv0 2018-01-23 22:18:16 -08:00
t0041-ping.sh put ping sharness test cmds on separate lines 2018-01-04 16:28:14 -08:00
t0042-add-skip.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0043-add-w.sh add: hash-only: set the prefix for MFS root 2018-03-02 15:46:02 -03:00
t0044-add-symlink.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0045-ls.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0050-block.sh Enforce Cid security rules for getting and adding blocks 2018-03-04 01:38:17 +01:00
t0051-object.sh object-patch: test resolving ipld objects 2017-12-07 21:34:01 +01:00
t0052-object-diff.sh dag: diff: check CIDs in base case when comparing nodes 2018-03-05 12:22:52 -03:00
t0053-dag.sh add raw support to the dag put command. 2017-10-10 19:58:23 -07:00
t0060-daemon.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0061-daemon-opts.sh add sharness test for deprecated supernode option 2017-10-16 09:27:24 -07:00
t0062-daemon-api.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0063-daemon-init.sh Fix t0063-daemon-init.sh by adding test profile to daemon 2018-03-15 01:06:54 +01:00
t0063-external.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0065-active-requests.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0066-migration.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0070-user-config.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0080-repo.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0081-repo-pinning.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0082-repo-gc-auto.sh fix loops in sharness tests to fail the test if the inner command fails 2017-12-14 18:48:48 -08:00
t0083-repo-fsck.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0084-repo-read-rehash.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0085-pins.sh fix ipfs pin verify --verbose not working 2018-03-04 01:38:17 +01:00
t0086-repo-verify.sh fix t0086-repo-verify.sh on FreeBSD 2018-02-06 20:35:17 +01:00
t0087-repo-robust-gc.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0088-repo-stat-symlink.sh make sure the repo size is greater than the size of the symlink 2017-12-01 09:56:03 -08:00
t0090-get.sh Merge pull request #4743 from schomatis/fix/unixfs/dagarchive-path 2018-03-22 23:16:24 -07:00
t0100-name.sh cleanup name publish argument tests 2018-03-19 16:31:07 -07:00
t0101-iptb-name.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0110-gateway.sh cleanup 2018-01-21 11:11:47 -08:00
t0111-gateway-writeable.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0112-gateway-cors.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0120-bootstrap.sh use prefix in bootstrapWritePeers 2018-03-19 01:36:51 +01:00
t0121-bootstrap-iptb.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0125-twonode.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0130-multinode.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0131-multinode-client-routing.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0140-swarm.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0141-addfilter.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0150-clisuggest.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0151-sysdiag.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0160-resolve.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0165-keystore.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0170-dht.sh make base64 decoding cross-platform 2018-01-27 13:45:36 -08:00
t0175-reprovider.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0180-p2p.sh sharness: make t0180-p2p less racy 2017-10-16 23:19:03 +02:00
t0180-pubsub.sh fix pubsub pub reading stdin args 2018-03-05 11:45:11 -08:00
t0181-private-network.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0182-circuit-relay.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0183-namesys-pubsub.sh fix namesys pubsub sharness tests 2018-01-27 13:45:36 -08:00
t0200-unixfs-ls.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0210-tar.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0220-bitswap.sh sharness: fix OSX build 2017-10-04 13:39:14 +02:00
t0230-channel-streaming-http-content-type.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0231-channel-streaming.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0235-cli-request.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0240-republisher.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0250-files-api.sh add tests for ipfs files stat --with-local 2018-02-04 01:51:37 +01:00
t0251-files-flushing.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0252-files-gc.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0260-sharding.sh test ipfs get on sharded directory 2018-03-23 16:24:57 -07:00
t0270-filestore.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0271-filestore-utils.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0275-cid-security.sh cid_secuirty: add test for gc 2018-03-05 19:38:25 +01:00
t0280-plugin-git.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0300-docker-image.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0301-docker-migrate.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0400-api-security.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0410-api-add.sh fix content type detection to allow adding via curl 2018-01-21 11:11:47 -08:00
t0500-issues-and-regressions-offline.sh sharness: 2 space indent 2017-10-04 13:39:14 +02:00
t0600-issues-and-regressions-online.sh compatible to js-ipfs-api 2017-11-17 15:22:42 +01:00
x0601-pin-fail-test.sh sharness: 2 space indent 2017-10-04 13:39:14 +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. (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