git-lfs/t
brian m. carlson f137f45388 lfsapi: handle SSH hostnames and aliases without users
It's very common for a user to specify an SSH remote that refers to an
alias in their gitconfig file.  For example, if a user must use
different SSH keys when pushing to different remotes, setting different
aliases that use those different keys is the simplest and easiest way to
accomplish that goal.

Unfortunately, our parsing logic was broken for SSH remotes that used
bare SSH URLs (that is, without “ssh://”) with a hostname or alias, but
without a username component.  The URL parser we used saw the hostname
portion as the scheme of a URL, and we passed through any URLs with
unknown schemes.  This led to a failure to push, since we misparsed the
URL as a non-SSH URL and gave up when it also didn't look like an
HTTP(S) URL.

If we get an unknown “scheme” when parsing a URL, check if the URL uses
a remote helper (that is, it contains a double colon), and pass it
through.  Otherwise, do what Git does, and assume the URL is in fact an
SSH URL, and handle it accordingly.

We already handle the url.insteadof syntax properly, even if it looks
like a scheme.  Add tests that we continue to do so, and for the new
code and all the various permutations mentioned above, and update the
existing integration test to reflect our new parsing strategy.
2018-09-06 14:52:56 +00:00
..
cmd appveyor.yml: disable lock acquiring 2018-07-23 11:17:48 -05:00
fixtures Merge branch 'master' into ttaylorr/prove 2018-07-23 11:12:04 -05:00
git-lfs-test-server-api t: import t/cmd/util in t/git-lfs-test-server-api/main.go 2018-07-13 13:05:19 -05:00
Makefile t/Makefile: mark test sources as .PHONY 2018-09-05 10:57:00 -04:00
README.md t/README.md: link to 'Test Lifecycle' appropriately 2018-07-16 16:39:51 -05:00
t-askpass.sh Merge branch 'master' into ttaylorr/prove 2018-07-17 12:54:38 -05:00
t-batch-error-handling.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-batch-retries.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-batch-transfer.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-batch-unknown-oids.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-checkout.sh Merge branch 'master' into ttaylorr/prove 2018-07-17 12:54:38 -05:00
t-chunked-transfer-encoding.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-clean.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-clone-deprecated.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-clone.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-commit-delete-push.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-config.sh lfsapi: handle SSH hostnames and aliases without users 2018-09-06 14:52:56 +00:00
t-content-type.sh Always provide a Content-Type when uploading files 2018-09-04 15:03:35 +00:00
t-credentials-no-prompt.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-credentials.sh t: disable lock verification in credentials test 2018-07-25 18:41:43 -05:00
t-custom-transfers.sh t: remove extraneous assertion 2018-07-25 19:01:18 -05:00
t-duplicate-oids.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-env.sh config: add origin to remote list 2018-07-26 11:40:47 -07:00
t-expired.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05: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 t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-fetch-include.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-fetch-paths.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-fetch-recent.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-fetch-refspec.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-fetch.sh t: use '$reponame' in 't/t-fetch' instead of constant 2018-07-11 16:56:18 -05:00
t-filter-branch.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-filter-process.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-fsck.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-happy-path.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-install-custom-hooks-path-unsupported.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-install-custom-hooks-path.sh tools/filetools.go: teach ExpandPath() to do path expansion 2018-08-30 16:59:33 -04:00
t-install.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-lock.sh locking: remove write permission for ignored files 2018-08-20 07:42:28 -06:00
t-locks.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05: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/command_ls_files: hide index with arguments 2018-09-05 10:33:27 -04:00
t-malformed-pointers.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-mergetool.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-migrate-export.sh Merge branch 'master' into ttaylorr/prove 2018-07-23 11:12:04 -05:00
t-migrate-fixup.sh Merge branch 'master' into ttaylorr/prove 2018-07-23 11:12:04 -05:00
t-migrate-import-no-rewrite.sh Merge branch 'master' into ttaylorr/prove 2018-07-23 11:12:04 -05:00
t-migrate-import.sh commands/command_migrate_import.go: install hooks 2018-09-05 10:50:57 -04:00
t-migrate-info.sh t: move 't-migrate-fixtures.sh' to 'fixtures' 2018-07-11 13:18:25 -05:00
t-object-authenticated.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-pointer.sh t: fix missing end_test's in t-pointer.sh 2018-07-11 16:29:29 -05:00
t-post-checkout.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-post-commit.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-post-merge.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-pre-push.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-progress-meter.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-progress.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-prune-worktree.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-prune.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-pull.sh config: add origin to remote list 2018-07-26 11:40:47 -07:00
t-push-bad-dns.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-push-failures-local.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-push-failures-remote.sh lfsapi/errors.go: create a NewUnprocessableEntityError when appropriate 2018-07-31 13:23:16 -05:00
t-push-file-with-branch-name.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-push.sh Merge branch 'master' into ttaylorr/prove 2018-07-23 11:12:04 -05:00
t-reference-clone.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-resume-http-range.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-resume-tus.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-smudge.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-ssh.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-status.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-submodule-lfsconfig.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-submodule.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-track-attrs.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05: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 Apply code review suggestions 2018-08-21 18:06:42 +03:00
t-uninstall.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-unlock.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-untrack.sh Fix a redirection typo which has plagued the poor t-untrack.sh before it infects the other kids 2018-08-21 18:10:40 +03:00
t-unusual-filenames.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-update.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-verify.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-version.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
t-worktree.sh t: fix contains_same_elements() fn 2018-07-25 14:29:50 -07:00
t-zero-len-file.sh t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
test-alternates.sh Merge branch 'master' into ttaylorr/prove 2018-07-17 12:54:38 -05:00
testenv.sh t/Makefile: setup and shutdown in 'make test' 2018-07-12 12:39:39 -05:00
testhelpers.sh Merge pull request #3144 from git-lfs/ttaylorr/makefile 2018-07-25 20:23:13 -05:00
testlib.sh t/testlib.sh: run atexit on more traps 2018-07-11 13:18:25 -05: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