git-lfs/t
Chris Darroch 43c0a1fae8 t: add tests with missing Retry-After header
A prior commit in this PR resolves a bug where a 429 response to an
upload or download request causes a Go panic in the client if the
response lacks a Retry-After header.

We can simulate this condition and confirm that the changes fix the
problem by updating our test server to respond with a 429 but no
Retry-After header when passed a new sentinel value, and then adding
a pair of tests which send this value.  Both tests generate the
Go panic condition without the other changes in this PR.
2024-06-18 23:31:03 -07:00
..
cmd t: add tests with missing Retry-After header 2024-06-18 23:31:03 -07:00
fixtures Update cobra to 1.7.0 2023-08-02 04:47:58 -04:00
git-lfs-test-server-api tq: make Manifest an interface 2023-03-23 16:55:57 +00:00
Makefile Merge branch 'main' into upgrade-go-1-21 2023-09-14 19:35:55 -07:00
README.md t/README.md: link to 'Test Lifecycle' appropriately 2018-07-16 16:39:51 -05:00
t-alternates.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-askpass.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-attributes.sh t: avoid incorrect negated commands 2023-02-22 14:57:29 +00:00
t-batch-error-handling.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-batch-retries-ratelimit.sh t: make all test scripts executable 2024-06-18 12:00:48 -07:00
t-batch-retries.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-batch-storage-retries-ratelimit.sh t: add tests with missing Retry-After header 2024-06-18 23:31:03 -07:00
t-batch-transfer.sh tq: pass hash algorithm during batch requests 2021-09-10 14:39:01 +00:00
t-batch-unknown-oids.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-checkout.sh checkout: gracefully handle files deleted from the index 2024-04-04 12:59:52 +00:00
t-cherry-pick-commits.sh t: make all test scripts executable 2024-06-18 12:00:48 -07:00
t-chunked-transfer-encoding.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-clean.sh t: pipe data to base64 to be compatible with macOS 2024-01-10 20:29:43 -08:00
t-clone-deprecated.sh use backticks around commands in messages 2022-01-29 22:35:10 -08:00
t-clone.sh t-clone: add .gitattributes before pushing 2024-04-16 15:13:06 +00:00
t-commit-delete-push.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-completion.sh t: add basic completion script tests 2023-07-17 13:55:50 -07:00
t-config.sh commands,config,t: use single quotes in messages 2022-01-29 22:35:10 -08:00
t-content-type.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-credentials-no-prompt.sh subprocess: report errors when finding executables 2022-04-19 09:45:20 -07:00
t-credentials.sh creds: handle authtype and credential 2024-06-10 13:27:03 +00:00
t-custom-transfers.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-dedup.sh commands/command_dedup.go,t: consistent messages 2022-01-29 22:32:57 -08:00
t-duplicate-oids.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-env.sh Add --verify-unreachable option to LFS prune 2024-02-08 17:31:34 +01:00
t-expired.sh t: label expiration test using git-lfs-authenticate 2021-07-20 19:16:00 +00:00
t-ext.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-extra-header.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-fetch-include.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-fetch-paths.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-fetch-recent.sh t: test fetch/prune diff parsing with ANSI escapes 2021-08-17 19:47:36 -07:00
t-fetch-refspec.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-fetch.sh lfshttp: don't crash on invalid cert data 2024-02-23 14:54:25 +00:00
t-filter-branch.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-filter-process.sh tq: avoid spawning SSH process needlessly 2023-03-28 15:21:58 +00:00
t-fsck.sh t: add tests for invalid refs 2024-01-31 22:09:35 -08:00
t-happy-path.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-install-custom-hooks-path-unsupported.sh commands,t: use capitalized Git in messages 2022-01-29 22:30:22 -08:00
t-install-custom-hooks-path.sh commands,t: use capitalized Git in messages 2022-01-29 22:30:22 -08:00
t-install-worktree-unsupported.sh t: add tests for --worktree install and uninstall 2020-06-26 14:56:06 -07:00
t-install-worktree.sh Add a --file option to install and uninstall 2023-05-02 14:11:27 +00:00
t-install.sh Add a --file option to install and uninstall 2023-05-02 14:11:27 +00:00
t-lock.sh Correct t-lock regular expression to be musl compatible 2021-10-07 16:37:23 +02:00
t-locks.sh Add a configuration option to control the SSH protocol is used 2023-11-06 16:28:29 +00:00
t-logs.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-ls-files.sh commands,t: fix output of ls-files in subdirectory 2024-02-22 00:33:18 -08:00
t-malformed-pointers.sh t: pipe data to base64 to be compatible with macOS 2024-01-10 20:29:43 -08:00
t-merge-driver.sh Add a merge driver 2022-05-10 17:05:15 +00:00
t-mergetool.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-migrate-export.sh t: add tests for invalid refs 2024-01-31 22:09:35 -08:00
t-migrate-fixup.sh t: add future tests of migrate "lfs" macro support 2023-06-01 02:34:10 -07:00
t-migrate-import-no-rewrite.sh commands,config,t: use single quotes in messages 2022-01-29 22:35:10 -08:00
t-migrate-import.sh t: add tests for invalid refs 2024-01-31 22:09:35 -08:00
t-migrate-info.sh t: add tests for invalid refs 2024-01-31 22:09:35 -08:00
t-multiple-remotes.sh t: fix standalone tests on Windows 2022-09-07 20:25:17 +00:00
t-no-remote.sh strip trailing whitespace 2023-08-25 10:45:16 -07:00
t-object-authenticated.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-path.sh t/t-path.sh: avoid test setup failure on Windows 2024-01-09 15:37:21 -08:00
t-pointer.sh commands/pointer: add an option for strict checking 2021-07-14 18:12:07 +00:00
t-post-checkout.sh post-checkout: don't modify permissions of untracked files 2021-12-06 13:44:33 +00:00
t-post-commit.sh t: avoid incorrect negated commands 2023-02-22 14:57:29 +00:00
t-post-merge.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-pre-push.sh t: avoid incorrect negated commands 2023-02-22 14:57:29 +00:00
t-progress-meter.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-progress.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-prune-worktree.sh Fix git lfs prune is deleting staged files in the index 2024-02-01 14:18:34 +01:00
t-prune.sh Add --verify-unreachable option to LFS prune 2024-02-08 17:31:34 +01:00
t-pull.sh lfs: don't update mtime on empty files on pull 2023-08-31 17:14:03 +00:00
t-push-bad-dns.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-push-failures-local.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-push-failures-remote.sh Fix typos 2022-01-05 08:49:08 +02:00
t-push-file-with-branch-name.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-push.sh commands,t: report invalid ref in push command 2024-01-31 22:09:35 -08:00
t-reference-clone.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-repo-format.sh Add support for an LFS repository format version 2021-07-21 13:28:51 +00:00
t-resume-http-range.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-resume-tus.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-smudge.sh t/t-smudge.sh: test smudge spooling to temp file 2024-01-15 19:27:40 -08:00
t-ssh.sh t/t-ssh.sh: also perform test without ssh variant 2021-11-30 20:23:35 +00:00
t-standalone-file.sh lfsapi: gracefully handle local paths with trailing slash 2023-06-21 17:43:11 +00:00
t-status.sh commands,t: use capitalized Git in messages 2022-01-29 22:30:22 -08:00
t-submodule-lfsconfig.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-submodule-recurse.sh t: make all test scripts executable 2024-06-18 12:00:48 -07:00
t-submodule.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-tempfile.sh fs: be a little less aggressive with cleanup 2021-04-30 14:36:06 +00:00
t-track-attrs.sh track: don't modify .gitattributes with --dry-run 2023-10-26 13:52:09 +00:00
t-track-wildcards.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-track.sh track: return an error on error or no action 2023-09-26 20:17:25 +00:00
t-umask.sh TST: Trim security context when checking permissions. 2019-01-15 01:20:13 -05:00
t-uninstall-worktree-unsupported.sh t: add tests for --worktree install and uninstall 2020-06-26 14:56:06 -07:00
t-uninstall-worktree.sh Add a --file option to install and uninstall 2023-05-02 14:11:27 +00:00
t-uninstall.sh Add a --file option to install and uninstall 2023-05-02 14:11:27 +00:00
t-unlock.sh t/t-unlock.sh: test unlock by path without refspec 2023-10-04 10:26:45 -07:00
t-untrack.sh commands: make sure we're in the working tree 2020-10-14 20:58:28 +00:00
t-unusual-filenames.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-update.sh hooks: mention core.hookspath instead of just .git/hooks 2023-01-05 17:08:25 +00:00
t-upload-redirect.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-verify.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
t-version.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-worktree.sh Add --verify-unreachable option to LFS prune 2024-02-08 17:31:34 +01:00
t-zero-len-file.sh Rename default branch in tests to "main" 2020-07-08 15:38:17 +00:00
testenv.sh t: add basic completion script tests 2023-07-17 13:55:50 -07:00
testhelpers.sh Implement support for authtype in test credential helper 2024-06-10 13:27:02 +00:00
testlib.sh t: add an environment variable to dump test output 2018-09-18 20:48:18 +00:00

t

This directory contains one of the two types of tests that the Git LFS project uses to protect against regression. The first, scattered in *_test.go files throughout the repository are unit tests, and written in Go, designed to uncover failures at the unit level.

The second kind--and the one contained in this directory--are integration tests, which are designed to exercise Git LFS in an end-to-end fashion, running the git, and git-lfs binaries, along with a mock Git server.

You can run all tests in this directory with any of the following:

$ make
$ make test
$ make PROVE_EXTRA_ARGS=-j9 test

Or run a single test (for example, t-checkout.sh) by any of the following:

$ make ./t-checkout.sh
$ make PROVE_EXTRA_ARGS=-v ./t-checkout.sh
$ ./t-checkout.sh

Alternatively, one can run a selection of tests (via explicitly listing them or making use of the built-in shell globbing) by any of the following:

$ make ./t-*.sh
$ make PROVE_EXTRA_ARGS=-j9 ./t-*.sh
$ ./t-*.sh

Test File(s)

There are a few important kinds of files to know about in the t directory:

  • cmd/: contains the source code of binaries that are useful during test time, like the mocked Git server, or the test counting binary. For more about the contents of this directory, see test lifecycle below.

    The file t/cmd/testutils.go is automatically linked and included during the build process of each file in cmd.

  • fixtures/: contains shell scripts that load fixture repositories useful for testing against.

  • t-*.sh: file(s) containing zero or more tests, typically related to a similar topic (c.f,. t/t-push.sh, t/t-pull.sh, etc.)

  • testenv.sh: loads environment variables useful during tests. This file is sourced by testlib.sh.

  • testhelpers.sh: loads shell functions useful during tests, like setup_remote_repo, and clone_repo.

  • testlib.sh: loads the begin_test, end_test, and similar functions useful for instantiating a particular test.

Test Lifecycle

When a test is run, the following occurs, in order:

  1. Missing test binaries are compiled into the bin directory in the repository root. Note: this does not include the git-lfs binary, which is re-compiled via script/boostrap.

  2. An integration server is started by either (1) the Makefile or (2) the cmd/lfstest-count-test.go program, which keeps track of the number of running tests and starts an integration server any time the number of active tests goes from 0 to 1, and stops the server when it goes from n to 0.

  3. After sourcing t/testlib.sh (& loading t/testenv.sh), each test is run in sequence per file. (In other words, multiple test files can be run in parallel, but the tests in a single file are run in sequence.)

  4. An individual test will finish, and (if running under prove) another will be started in its place. Once all tests are done, t/test_count will go to 0, and the test server will be torn down.

Test 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.

  • KEEPTRASH=1 - This will leave the local repository data in a tmp directory and the remote repository data in test/remote.

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.

Writing new tests

A new test file should be named t/t-*.sh, where * is the topic of Git LFS being tested. It should look as follows:

#!/usr/bin/env bash

. "$(dirname "$0")/testlib.sh"

begin_test "my test"
(
  set -e

  # ...
)
end_test