2015-07-30 02:37:31 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-05-19 01:09:32 +00:00
|
|
|
# Including in script/integration and every test/test-*.sh file.
|
2015-05-18 23:28:58 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2016-03-18 15:03:05 +00:00
|
|
|
UNAME=$(uname -s)
|
|
|
|
IS_WINDOWS=0
|
|
|
|
IS_MAC=0
|
2016-10-08 17:00:30 +00:00
|
|
|
SHASUM="shasum -a 256"
|
2017-08-08 17:46:12 +00:00
|
|
|
PATH_SEPARATOR="/"
|
2016-10-08 17:00:30 +00:00
|
|
|
|
2016-10-08 20:30:36 +00:00
|
|
|
if [[ $UNAME == MINGW* || $UNAME == MSYS* || $UNAME == CYGWIN* ]]
|
2016-03-18 15:03:05 +00:00
|
|
|
then
|
|
|
|
IS_WINDOWS=1
|
2016-10-08 17:00:30 +00:00
|
|
|
|
|
|
|
# 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"
|
2017-08-08 17:46:12 +00:00
|
|
|
PATH_SEPARATOR="\\"
|
2016-03-18 15:03:05 +00:00
|
|
|
elif [[ $UNAME == *Darwin* ]]
|
|
|
|
then
|
|
|
|
IS_MAC=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
resolve_symlink() {
|
|
|
|
local arg=$1
|
2016-10-08 16:47:33 +00:00
|
|
|
if [ $IS_WINDOWS -eq 1 ]; then
|
2016-03-18 15:03:05 +00:00
|
|
|
printf '%s' "$arg"
|
2016-10-08 16:47:33 +00:00
|
|
|
elif [ $IS_MAC -eq 1 ]; then
|
2016-03-18 15:03:05 +00:00
|
|
|
# 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
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-06-19 17:06:55 +00:00
|
|
|
# The root directory for the git-lfs repository by default.
|
|
|
|
if [ -z "$ROOTDIR" ]; then
|
2016-03-18 15:03:05 +00:00
|
|
|
ROOTDIR=$(cd $(dirname "$0")/.. && pwd -P)
|
2015-06-19 17:06:55 +00:00
|
|
|
fi
|
2015-05-19 22:54:15 +00:00
|
|
|
|
|
|
|
# Where Git LFS outputs the compiled binaries
|
2015-05-18 23:28:58 +00:00
|
|
|
BINPATH="$ROOTDIR/bin"
|
2015-05-19 22:54:15 +00:00
|
|
|
|
|
|
|
# Put bin path on PATH
|
2015-05-18 23:28:58 +00:00
|
|
|
PATH="$BINPATH:$PATH"
|
|
|
|
|
2016-03-18 15:04:49 +00:00
|
|
|
# Always provide a test dir outside our git repo if not specified
|
2016-03-24 17:41:42 +00:00
|
|
|
TEMPDIR_PREFIX="git-lfs_TEMP.XXXXXX"
|
2016-03-18 15:04:49 +00:00
|
|
|
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
|
2016-07-15 21:38:02 +00:00
|
|
|
fi
|
2015-05-18 23:28:58 +00:00
|
|
|
# create a temporary work space
|
2016-03-18 15:04:49 +00:00
|
|
|
TMPDIR=$GIT_LFS_TEST_DIR
|
2015-05-19 22:54:15 +00:00
|
|
|
|
|
|
|
# This is unique to every test file, and cleared after every test run.
|
2015-05-18 23:28:58 +00:00
|
|
|
TRASHDIR="$TMPDIR/$(basename "$0")-$$"
|
|
|
|
|
2015-05-19 22:54:15 +00:00
|
|
|
# The directory that the test Git server works from. This cleared at the
|
|
|
|
# beginning of every test run.
|
2015-05-18 23:28:58 +00:00
|
|
|
REMOTEDIR="$ROOTDIR/test/remote"
|
2015-05-19 22:54:15 +00:00
|
|
|
|
2015-08-04 16:06:30 +00:00
|
|
|
# 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"
|
|
|
|
|
2015-05-19 22:54:15 +00:00
|
|
|
# This is the prefix for Git config files. See the "Test Suite" section in
|
|
|
|
# test/README.md
|
2015-05-18 23:28:58 +00:00
|
|
|
LFS_CONFIG="$REMOTEDIR/config"
|
|
|
|
|
2015-05-19 22:54:15 +00:00
|
|
|
# This file contains the URL of the test Git server. See the "Test Suite"
|
|
|
|
# section in test/README.md
|
|
|
|
LFS_URL_FILE="$REMOTEDIR/url"
|
|
|
|
|
2016-03-09 17:31:04 +00:00
|
|
|
# This file contains the SSL URL of the test Git server. See the "Test Suite"
|
|
|
|
# section in test/README.md
|
|
|
|
LFS_SSL_URL_FILE="$REMOTEDIR/sslurl"
|
|
|
|
|
2017-01-24 14:53:43 +00:00
|
|
|
# This file contains the client cert SSL URL of the test Git server. See the "Test Suite"
|
|
|
|
# section in test/README.md
|
|
|
|
LFS_CLIENT_CERT_URL_FILE="$REMOTEDIR/clientcerturl"
|
|
|
|
|
2016-03-09 17:31:04 +00:00
|
|
|
# This file contains the self-signed SSL cert of the TLS endpoint of the test Git server.
|
|
|
|
LFS_CERT_FILE="$REMOTEDIR/cert"
|
|
|
|
|
2017-01-24 14:53:43 +00:00
|
|
|
# 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"
|
|
|
|
|
2015-07-30 02:03:57 +00:00
|
|
|
# the fake home dir used for the initial setup
|
|
|
|
TESTHOME="$REMOTEDIR/home"
|
|
|
|
|
2015-05-26 15:47:57 +00:00
|
|
|
GIT_CONFIG_NOSYSTEM=1
|
2016-07-15 21:38:02 +00:00
|
|
|
GIT_TERMINAL_PROMPT=0
|
2017-05-19 15:25:22 +00:00
|
|
|
GIT_SSH=lfs-ssh-echo
|
2017-01-04 20:27:05 +00:00
|
|
|
APPVEYOR_REPO_COMMIT_MESSAGE="test: env test should look for GIT_SSH too"
|
2015-05-26 15:39:04 +00:00
|
|
|
|
2015-08-11 20:18:30 +00:00
|
|
|
export CREDSDIR
|
2016-09-11 15:41:06 +00:00
|
|
|
export GIT_CONFIG_NOSYSTEM
|
2017-01-04 18:16:07 +00:00
|
|
|
export GIT_SSH
|
2017-01-04 20:27:05 +00:00
|
|
|
export APPVEYOR_REPO_COMMIT_MESSAGE
|
2015-08-11 20:18:30 +00:00
|
|
|
|
2015-07-30 02:03:57 +00:00
|
|
|
mkdir -p "$TMPDIR"
|
2015-05-18 23:28:58 +00:00
|
|
|
mkdir -p "$TRASHDIR"
|
|
|
|
|
2016-10-08 16:47:33 +00:00
|
|
|
if [ $IS_WINDOWS -eq 1 ]; then
|
2016-07-15 13:53:02 +00:00
|
|
|
# prevent Windows OpenSSH from opening GUI prompts
|
|
|
|
SSH_ASKPASS=""
|
|
|
|
fi
|
2015-05-18 23:28:58 +00:00
|
|
|
. "test/testhelpers.sh"
|