t: fix contains_same_elements() fn

Previously, the contains_same_elements() function was causing
tests to immediately exit when called, meaning that portions of
many tests were being inadvertently skipped. This fixes the
contains_same_elements() function so it no longer exits the test,
and fixes the failing tests exposed by this change.
This commit is contained in:
Preben Ingvaldsen 2018-07-25 14:29:50 -07:00
parent a173629349
commit b32ab6cdb0
3 changed files with 46 additions and 17 deletions

@ -542,12 +542,17 @@ UploadTransfers=basic
contains_same_elements "$expected" "$actual4"
envVars="$(GIT_DIR=$gitDir GIT_WORK_TREE=a/b env | grep "^GIT" | sort)"
# `a/b` is an invalid relative path from where we are now and results in an
# error, so resulting output will have many fields blank or invalid
mediaDir5=$(native_path "lfs/objects")
tempDir5=$(native_path "lfs/tmp")
expected5=$(printf '%s
%s
LocalWorkingDir=%s
LocalGitDir=%s
LocalGitStorageDir=%s
LocalWorkingDir=
LocalGitDir=
LocalGitStorageDir=
LocalMediaDir=%s
LocalReferenceDirs=
TempDir=%s
@ -562,13 +567,16 @@ FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=%s
LfsStorageDir=lfs
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic
UploadTransfers=basic
%s
' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVars")
git config filter.lfs.process = ""
git config filter.lfs.smudge = ""
git config filter.lfs.clean = ""
' "$(git lfs version)" "$(git version)" "$mediaDir5" "$tempDir5" "$envVars")
actual5=$(GIT_DIR=$gitDir GIT_WORK_TREE=a/b git lfs env \
| grep -v "^GIT_EXEC_PATH=")
contains_same_elements "$expected5" "$actual5"
@ -777,7 +785,7 @@ TempDir=%s
ConcurrentTransfers=3
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=true
SkipDownloadErrors=false
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
@ -797,8 +805,37 @@ UploadTransfers=basic
contains_same_elements "$expecteddisabled" "$actual"
# now enable via env var
envVarsEnabled=$(printf "%s" "$(GIT_LFS_SKIP_DOWNLOAD_ERRORS=1 env | grep "^GIT")")
expectedenabled2=$(printf '%s
%s
LocalWorkingDir=%s
LocalGitDir=%s
LocalGitStorageDir=%s
LocalMediaDir=%s
LocalReferenceDirs=
TempDir=%s
ConcurrentTransfers=3
TusTransfers=false
BasicTransfersOnly=false
SkipDownloadErrors=true
FetchRecentAlways=false
FetchRecentRefsDays=7
FetchRecentCommitsDays=0
FetchRecentRefsIncludeRemotes=true
PruneOffsetDays=3
PruneVerifyRemoteAlways=false
PruneRemoteName=origin
LfsStorageDir=%s
AccessDownload=none
AccessUpload=none
DownloadTransfers=basic
UploadTransfers=basic
%s
%s
' "$(git lfs version)" "$(git version)" "$localwd" "$localgit" "$localgitstore" "$localmedia" "$tempdir" "$lfsstorage" "$envVarsEnabled" "$envInitConfig")
actual=$(GIT_LFS_SKIP_DOWNLOAD_ERRORS=1 git lfs env | grep -v "^GIT_EXEC_PATH=")
contains_same_elements "$expectedenabled" "$actual"
contains_same_elements "$expectedenabled2" "$actual"

@ -62,7 +62,7 @@ LocalGitDir=$(native_path_escaped "$TRASHDIR/$reponame/.git/worktrees/$worktreen
LocalGitStorageDir=$(native_path_escaped "$TRASHDIR/$reponame/.git")
LocalMediaDir=$(native_path_escaped "$TRASHDIR/$reponame/.git/lfs/objects")
LocalReferenceDirs=
TempDir=$(native_path_escaped "$TRASHDIR/$reponame/.git/worktrees/$worktreename/lfs/tmp")
TempDir=$(native_path_escaped "$TRASHDIR/$reponame/.git/lfs/tmp")
ConcurrentTransfers=3
TusTransfers=false
BasicTransfersOnly=false

@ -742,15 +742,7 @@ cat_end() {
# Compare 2 lists which are newline-delimited in a string, ignoring ordering and blank lines
contains_same_elements() {
# Remove blank lines then sort
printf '%s' "$1" | grep -v '^$' | sort > a.txt
printf '%s' "$2" | grep -v '^$' | sort > b.txt
set +e
diff -u a.txt b.txt 1>&2
res=$?
set -e
rm a.txt b.txt
exit $res
diff -u <(printf '%s' "$1" | grep -v '^$' | sort) <(printf '%s' "$2" | grep -v '^$' | sort)
}
is_stdin_attached() {