git-lfs/test
2017-04-05 14:00:55 -06:00
..
cmd tq,docs,test: add expires_in support to batch API 2017-04-05 14:00:55 -06:00
git-lfs-test-server-api tq: use Rel() function to implement multiActionSet 2017-03-06 14:33:58 -07:00
README.md update other github/git-lfs references 2016-11-15 10:07:11 -07:00
test-batch-error-handling.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-batch-retries.sh wip 2016-11-02 16:51:14 -06:00
test-batch-transfer.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-batch-unknown-oids.sh tq,test/cmd: raise an error on unknown OIDs 2016-12-12 15:33:15 -07:00
test-checkout.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-chunked-transfer-encoding.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-clean.sh update the shebang lines to use bash 2015-07-29 20:37:31 -06:00
test-clone.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-commit-delete-push.sh always use 'git rev-parse' to figure out git and working tree dirs 2016-02-01 11:20:32 -07:00
test-config.sh remove deprecated features 2016-11-18 07:44:20 -07:00
test-credentials-no-prompt.sh Remove system credential helper specific work-arounds in tests 2016-09-28 21:30:05 +02:00
test-credentials.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-custom-transfers.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-duplicate-oids.sh test: add a test for pushing multiple revs with the same OID 2016-10-20 18:08:13 -06:00
test-env.sh drop lfs.batch support, its always true now 2017-02-13 14:30:59 -07:00
test-expired.sh tq,docs,test: add expires_in support to batch API 2017-04-05 14:00:55 -06:00
test-ext.sh LFS Extensions: use lfs.extension instead of lfs-ext 2015-08-01 21:13:37 -04:00
test-fetch-include.sh failing test 2016-08-16 17:37:46 -06:00
test-fetch-paths.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-fetch-recent.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-fetch.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-filter-branch.sh test: ensure filter-process works with git filter-branch 2016-12-26 13:28:07 -07:00
test-filter-process.sh Travis-CI complains that it cannot create directory `repo'. Rename it! 2016-11-22 12:32:39 +01:00
test-fsck.sh rewrite fsck command to use gitscanner api 2016-11-29 13:56:47 -07:00
test-happy-path.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-install-custom-hooks-path-unsupported.sh Add post-commit hook to make newly added lockable files read-only 2017-01-02 14:36:28 +00:00
test-install-custom-hooks-path.sh Add post-merge hook to make files read-only again if not locked 2017-01-02 16:56:47 +00:00
test-install.sh Merge branch 'master' into locking-master-2 2017-01-19 11:42:47 +00:00
test-lock.sh commands: use active voice for lock messages 2017-02-23 12:54:57 -07:00
test-locks.sh commands: remove 'matched query' msg 2017-02-23 13:02:42 -07:00
test-logs.sh update the shebang lines to use bash 2015-07-29 20:37:31 -06:00
test-ls-files.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-malformed-pointers.sh commands/smudge: treat empty pointers as empty files 2017-02-16 17:38:15 -07:00
test-object-authenticated.sh Remove system credential helper specific work-arounds in tests 2016-09-28 21:30:05 +02:00
test-pointer.sh fix pointer error messages 2016-08-18 09:39:06 -06:00
test-post-checkout.sh test: add assert_file_writable() and refute_file_writable() 2017-02-28 16:45:11 -08:00
test-post-commit.sh test: add assert_file_writable() and refute_file_writable() 2017-02-28 16:45:11 -08:00
test-post-merge.sh test: add assert_file_writable() and refute_file_writable() 2017-02-28 16:45:11 -08:00
test-pre-push.sh locking,commands/uploader: return and special-case auth errors 2017-03-29 15:54:16 -06:00
test-progress-meter.sh test: assert that the progress meter displays positive progress 2017-02-16 21:28:27 -07:00
test-prune-worktree.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-prune.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-pull.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-push-bad-dns.sh lfs/tq: retry transfers before accepting new ones 2016-12-12 09:24:10 -07:00
test-push-failures.sh test/push: assert message is logged in a /storage 503 2016-09-05 16:49:06 -06:00
test-push-file-with-branch-name.sh Fix git rev-list when a file exists with the same name as the branch 2016-03-19 11:40:30 -07:00
test-push-missing.sh commands/uploader: change header message 2017-03-24 16:05:40 -06:00
test-push.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-reference-clone.sh Add support for reference clone 2016-04-05 22:06:44 +03:00
test-resume-http-range.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-resume-tus.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-smudge.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-status.sh commands/status: show "File" prefix when reading from disk 2017-03-23 11:05:35 -06:00
test-submodule-lfsconfig.sh test lfsconfig behavior with git submodule update --init --remote 2016-01-29 13:47:21 -07:00
test-submodule.sh test lfsconfig behavior with git submodule update --init --remote 2016-01-29 13:47:21 -07:00
test-track-wildcards.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-track.sh commands/track: quote pattern in output of track command 2017-03-24 11:13:11 -06:00
test-uninstall.sh test: shorten test name so the output lines up 2017-01-25 06:32:39 -07:00
test-unlock.sh commands/unlock: fix panic when unlocking with --id 2017-02-27 14:21:59 -07:00
test-untrack.sh commands/untrack: quote pattern in output of untrack command 2017-03-24 11:13:11 -06:00
test-unusual-filenames.sh Add a failing test for filenames starting with dashes 2016-03-17 14:45:50 -07:00
test-update.sh Add post-merge hook to make files read-only again if not locked 2017-01-02 16:56:47 +00:00
test-verify.sh test/test-verify: ensure that Authorization header is sent 2017-03-24 15:30:35 -06:00
test-worktree.sh drop lfs.batch support, its always true now 2017-02-13 14:30:59 -07:00
test-zero-len-file.sh test/zero-len: grep -E and remove tee 2016-07-13 10:34:35 -06:00
testenv.sh integration test added for clone with client certificate 2017-01-24 15:53:43 +01:00
testhelpers.sh test/testhelpers: add corrupt_local_object helper 2017-03-24 14:36:33 -06:00
testlib.sh integration test added for clone with client certificate 2017-01-24 15:53:43 +01:00
testutils.go Adding integration test for #1860 2017-01-17 23:40:19 -05:00

Git LFS Tests

Git LFS uses two form of tests: unit tests for the internals written in Go, and integration tests that run git and git-lfs in a real shell environment. You can run them separately:

$ script/test        # Tests the Go packages.
$ script/integration # Tests the commands in shell scripts.

CI servers should always run both:

$ script/cibuild

Internal Package Tests

The internal tests use Go's builtin testing package.

You can run individual tests by passing arguments to script/test:

# test a specific Go package
$ script/test lfs

# pass other `go test` arguments
$ script/test lfs -run TestSuccessStatus -v
github.com/kr/text
github.com/cheggaaa/pb
github.com/rubyist/tracerx
github.com/kr/pretty
github.com/git-lfs/git-lfs/git
github.com/technoweenie/assert
=== RUN TestSuccessStatus
--- PASS: TestSuccessStatus (0.00 seconds)
PASS
ok  	_/Users/rick/git-lfs/git-lfs/lfs	0.011s

Integration Tests

Git LFS integration tests are shell scripts that test the git-lfs command from the shell. Each test file can be run individually, or in parallel through script/integration. Some tests will change the pwd, so it's important that they run in separate OS processes.

$ test/test-happy-path.sh
compile git-lfs for test/test-happy-path.sh
LFSTEST_URL=/Users/rick/git-lfs/git-lfs/test/remote/url LFSTEST_DIR=/Users/rick/git-lfs/git-lfs/test/remote lfstest-gitserver
test: happy path ...                                               OK
  1. The integration tests should not rely on global system or git config.
  2. The tests should be cross platform (Linux, Mac, Windows).
  3. Tests should bootstrap an isolated, clean environment. See the Test Suite section.
  4. Successful test runs should have minimal output.
  5. Failing test runs should dump enough information to diagnose the bug. This includes stdout, stderr, any log files, and even the OS environment.

There are a few environment variables that you can set to change the test suite behavior:

  • GIT_LFS_TEST_DIR=path - This sets the directory that is used as the current working directory of the tests. By default, this will be in your temp dir. It's recommended that this is set to a directory outside of any Git repository.
  • GIT_LFS_TEST_MAXPROCS=N - This tells script/integration how many tests to run in parallel. Default: 4.
  • KEEPTRASH=1 - This will leave the local repository data in a tmp directory and the remote repository data in test/remote.
  • SKIPCOMPILE=1 - This skips the Git LFS compilation step. Speeds up the tests when you're running the same test script multiple times without changing any Go code.

Also ensure that your noproxy environment variable contains 127.0.0.1 host, to allow git commands to reach the local Git server lfstest-gitserver.

Test Suite

The testenv.sh script includes some global variables used in tests. This should be automatically included in every test/test-*.sh script and script/integration.

testhelpers.sh defines some shell functions. Most are only used in the test scripts themselves. script/integration uses the setup() and shutdown() functions.

testlib.sh is a fork of a lightweight shell testing lib that is used internally at GitHub. Only the test/test-*.sh scripts should include this.

Tests live in this ./test directory, and must have a unique name like: test-{name}.sh. All tests should start with a basic template. See test/test-happy-path.sh for an example.

#!/usr/bin/env bash

. "test/testlib.sh"

begin_test "template"
(
  set -e

  echo "your tests go here"
)
end_test

The set -e command will bail on the test at the first command that returns a non zero exit status. Use simple shell commands like grep as assertions.

The test suite has standard setup and shutdown functions that should be run only once. If a test script is run by script/integration, it will skip the functions. Setup does the following:

  • Resets temporary test directories.
  • Compiles git-lfs with the latest code changes.
  • Compiles Go files in test/cmd to bin, and adds them the PATH.
  • Spins up a test Git and Git LFS server so the entire push/pull flow can be exercised.
  • Sets up a git credential helper that always returns a set username and password.

The test Git server writes a test/remote/url file when it's complete. This file is how individual test scripts detect if script/integration is being run. You can fake this by manually spinning up the Git server using the lfstest-gitserver line that is output after Git LFS is compiled.

By default, temporary directories in tmp and the test/remote directory are cleared after test runs. Send the "KEEPTRASH" if you want to keep these files around for debugging failed tests.