1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
#!/usr/bin/env bash
# Including in script/integration and every t/t-*.sh file.
set -e
UNAME=$(uname -s)
IS_WINDOWS=0
IS_MAC=0
X=""
SHASUM="shasum -a 256"
PATH_SEPARATOR="/"
if [[ $UNAME == MINGW* || $UNAME == MSYS* || $UNAME == CYGWIN* ]]
then
IS_WINDOWS=1
X=".exe"
# Windows might be MSYS2 which does not have the shasum Perl wrapper
# script by default, so use sha256sum directly. MacOS on the other hand
# does not have sha256sum, so still use shasum as the default.
SHASUM="sha256sum"
PATH_SEPARATOR="\\"
elif [[ $UNAME == *Darwin* ]]
then
IS_MAC=1
fi
# Convert potentially MinGW bash paths to native Windows paths
# Needed to match generic built paths in test scripts to native paths generated from Go
native_path() {
local arg=$1
if [ $IS_WINDOWS -eq 1 ]; then
# Use params form to avoid interpreting any '\' characters
printf '%s' "$(cygpath -w $arg)"
else
printf '%s' "$arg"
fi
}
resolve_symlink() {
local arg=$1
if [ $IS_WINDOWS -eq 1 ]; then
printf '%s' "$arg"
elif [ $IS_MAC -eq 1 ]; then
# no readlink -f on Mac
local oldwd=$(pwd)
local target=$arg
cd `dirname $target`
target=`basename $target`
while [ -L "$target" ]
do
target=`readlink $target`
cd `dirname $target`
target=`basename $target`
done
local resolveddir=`pwd -P`
cd "$oldwd"
printf '%s' "$resolveddir/$target"
else
readlink -f "$arg"
fi
}
# The root directory for the git-lfs repository by default.
if [ -z "$ROOTDIR" ]; then
ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
fi
# Where Git LFS outputs the compiled binaries
BINPATH="$ROOTDIR/bin"
# Put bin path on PATH
PATH="$BINPATH:$PATH"
# Always provide a test dir outside our git repo if not specified
if [ "$IS_MAC" -eq 1 ]; then
TEMPDIR_PREFIX="git-lfs_TEMP"
else
TEMPDIR_PREFIX="git-lfs_TEMP.XXXXXX"
fi
if [ -z "$GIT_LFS_TEST_DIR" ]; then
GIT_LFS_TEST_DIR="$(mktemp -d -t "$TEMPDIR_PREFIX")"
GIT_LFS_TEST_DIR="$(resolve_symlink "$GIT_LFS_TEST_DIR")"
# cleanup either after single test or at end of integration (except on fail)
RM_GIT_LFS_TEST_DIR="yes"
fi
# Make these variables available to all test files run in the same shell,
# particularly when setup() is run first by itself to start a single
# common lfstest-gitserver instance.
export GIT_LFS_TEST_DIR RM_GIT_LFS_TEST_DIR
# create a temporary work space
TMPDIR=$GIT_LFS_TEST_DIR
# This is unique to every test file, and cleared after every test run.
TRASHDIR="$TMPDIR/$(basename "$0")-$$"
# The directory that the test Git server works from. This cleared at the
# beginning of every test run.
REMOTEDIR="$ROOTDIR/t/remote"
# The directory that stores credentials. Credentials are stored in files with
# the username:password with filenames identifying the host (port numbers are
# ignored).
#
# # stores the credentials for http://127.0.0.1:*
# $CREDSDIR/127.0.0.1
#
# # stores the credentials for http://git-server.com
# $CREDSDIR/git-server.com
#
CREDSDIR="$REMOTEDIR/creds/"
# This file contains the URL of the test Git server. See the "Test Suite"
# section in t/README.md
LFS_URL_FILE="$REMOTEDIR/url"
# This file contains the SSL URL of the test Git server. See the "Test Suite"
# section in t/README.md
LFS_SSL_URL_FILE="$REMOTEDIR/sslurl"
# This file contains the client cert SSL URL of the test Git server. See the "Test Suite"
# section in t/README.md
LFS_CLIENT_CERT_URL_FILE="$REMOTEDIR/clientcerturl"
# This file contains the self-signed SSL cert of the TLS endpoint of the test Git server.
LFS_CERT_FILE="$REMOTEDIR/cert"
# This file contains the client certificate of the client cert endpoint of the test Git server.
LFS_CLIENT_CERT_FILE="$REMOTEDIR/client.crt"
# This file contains the client key of the client cert endpoint of the test Git server.
LFS_CLIENT_KEY_FILE="$REMOTEDIR/client.key"
# This file contains the encrypted client key of the client cert endpoint of the test Git server.
LFS_CLIENT_KEY_FILE_ENCRYPTED="$REMOTEDIR/client.enc.key"
# the fake home dir used for the initial setup
TESTHOME="$REMOTEDIR/home"
# This directory contains the expected output of the "git lfs completion"
# command for different shells.
COMPLETIONSDIR="$ROOTDIR/t/fixtures/completions"
GIT_LFS_FORCE_PROGRESS=1
GIT_CONFIG_NOSYSTEM=1
GIT_TERMINAL_PROMPT=0
GIT_SSH=lfs-ssh-echo
GIT_TEMPLATE_DIR="$(native_path "$ROOTDIR/t/fixtures/templates")"
LC_ALL=C
export CREDSDIR
export GIT_LFS_FORCE_PROGRESS
export GIT_CONFIG_NOSYSTEM
export GIT_SSH
export GIT_TEMPLATE_DIR
export LC_ALL
# Don't fail if run under git rebase -x.
unset GIT_DIR
unset GIT_WORK_TREE
unset GIT_EXEC_PATH
unset GIT_CHERRY_PICK_HELP
mkdir -p "$TMPDIR"
mkdir -p "$TRASHDIR"
if [ $IS_WINDOWS -eq 1 ]; then
# prevent Windows OpenSSH from opening GUI prompts
SSH_ASKPASS=""
fi
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/testhelpers.sh"
|