Skip to content

Let journey tests fail without find and enforce LF line endings #1676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
**/generated-archives/*.tar* filter=lfs-disabled diff=lfs merge=lfs -text

# assure line feeds don't interfere with our working copy hash
**/tests/fixtures/**/*.sh text crlf=input eol=lf
/justfile text crlf=input eol=lf
*.sh text crlf=input eol=lf
justfile text crlf=input eol=lf

# have GitHub include fixture-making scripts when it counts code
**/tests/fixtures/**/*.sh linguist-vendored=false
Expand Down
244 changes: 121 additions & 123 deletions tests/journey/ein.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,144 +28,142 @@ title "Porcelain ${kind}"
)
)
snapshot="$snapshot/porcelain"
(with_program find
(when "using the 'tool' subcommand"
title "ein tool"
(with "a repo with a tiny commit history"
(small-repo-in-sandbox
title "ein tool estimate-hours"
(when "running 'estimate-hours'"
snapshot="$snapshot/estimate-hours"
(with "no arguments"
it "succeeds and prints only a summary" && {
WITH_SNAPSHOT="$snapshot/no-args-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours 2>/dev/null"
}
)
(with "the show-pii argument"
it "succeeds and shows information identifying people before the summary" && {
WITH_SNAPSHOT="$snapshot/show-pii-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours --show-pii 2>/dev/null"
}
)
(with "the omit-unify-identities argument"
it "succeeds and doesn't show unified identities (in this case there is only one author anyway)" && {
WITH_SNAPSHOT="$snapshot/no-unify-identities-success" \
expect_run_sh $SUCCESSFULLY "$exe t estimate-hours --omit-unify-identities 2>/dev/null"
}
)
(with "the --file-stats argument"
it "succeeds and shows file statistics" && {
WITH_SNAPSHOT="$snapshot/file-stats-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours --file-stats 2>/dev/null"
}
)
(with "the --line-stats argument"
it "succeeds and shows line statistics" && {
WITH_SNAPSHOT="$snapshot/line-stats-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours --line-stats 2>/dev/null"
}
)
(with "all --stats arguments and pii"
it "succeeds and shows all statistics" && {
WITH_SNAPSHOT="$snapshot/all-stats-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours -pfl 2>/dev/null"
}
)
(with "a branch name that doesn't exist"
it "fails and shows a decent enough error message" && {
WITH_SNAPSHOT="$snapshot/invalid-branch-name-failure" \
expect_run_sh $WITH_FAILURE "$exe -q t estimate-hours . foobar"
}
)
(when "using the 'tool' subcommand"
title "ein tool"
(with "a repo with a tiny commit history"
(small-repo-in-sandbox
title "ein tool estimate-hours"
(when "running 'estimate-hours'"
snapshot="$snapshot/estimate-hours"
(with "no arguments"
it "succeeds and prints only a summary" && {
WITH_SNAPSHOT="$snapshot/no-args-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours 2>/dev/null"
}
)
(with "the show-pii argument"
it "succeeds and shows information identifying people before the summary" && {
WITH_SNAPSHOT="$snapshot/show-pii-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours --show-pii 2>/dev/null"
}
)
(with "the omit-unify-identities argument"
it "succeeds and doesn't show unified identities (in this case there is only one author anyway)" && {
WITH_SNAPSHOT="$snapshot/no-unify-identities-success" \
expect_run_sh $SUCCESSFULLY "$exe t estimate-hours --omit-unify-identities 2>/dev/null"
}
)
(with "the --file-stats argument"
it "succeeds and shows file statistics" && {
WITH_SNAPSHOT="$snapshot/file-stats-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours --file-stats 2>/dev/null"
}
)
(with "the --line-stats argument"
it "succeeds and shows line statistics" && {
WITH_SNAPSHOT="$snapshot/line-stats-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours --line-stats 2>/dev/null"
}
)
(with "all --stats arguments and pii"
it "succeeds and shows all statistics" && {
WITH_SNAPSHOT="$snapshot/all-stats-success" \
expect_run_sh $SUCCESSFULLY "$exe tool estimate-hours -pfl 2>/dev/null"
}
)
(with "a branch name that doesn't exist"
it "fails and shows a decent enough error message" && {
WITH_SNAPSHOT="$snapshot/invalid-branch-name-failure" \
expect_run_sh $WITH_FAILURE "$exe -q t estimate-hours . foobar"
}
)
)
)
(with "a mix of repositories"
(sandbox
repo-with-remotes dir/one-origin origin https://example.com/one-origin
repo-with-remotes origin-and-fork origin https://example.com/origin-and-fork fork https://example.com/other/origin-and-fork
repo-with-remotes special-origin special-name https://example.com/special-origin
repo-with-remotes no-origin
repo-with-remotes a-non-bare-repo-with-extension.git origin https://example.com/a-repo-with-extension.git
snapshot="$snapshot/tool"
)
(with "a mix of repositories"
(sandbox
repo-with-remotes dir/one-origin origin https://example.com/one-origin
repo-with-remotes origin-and-fork origin https://example.com/origin-and-fork fork https://example.com/other/origin-and-fork
repo-with-remotes special-origin special-name https://example.com/special-origin
repo-with-remotes no-origin
repo-with-remotes a-non-bare-repo-with-extension.git origin https://example.com/a-repo-with-extension.git
snapshot="$snapshot/tool"

title "ein tool find"
(when "running 'find'"
snapshot="$snapshot/find"
(with "no arguments"
it "succeeds and prints a list of repository work directories" && {
WITH_SNAPSHOT="$snapshot/no-args-success" \
expect_run_sh $SUCCESSFULLY "$exe tool find 2>/dev/null"
}
)
title "ein tool find"
(when "running 'find'"
snapshot="$snapshot/find"
(with "no arguments"
it "succeeds and prints a list of repository work directories" && {
WITH_SNAPSHOT="$snapshot/no-args-success" \
expect_run_sh $SUCCESSFULLY "$exe tool find 2>/dev/null"
}
)
title "ein tool organize"
(when "running 'organize'"
snapshot="$snapshot/organize"
(with "no arguments"
it "succeeds and informs about the operations that it WOULD do" && {
WITH_SNAPSHOT="$snapshot/no-args-success" \
expect_run_sh $SUCCESSFULLY "$exe tool organize 2>/dev/null"
}

it "does not change the directory structure at all" && {
WITH_SNAPSHOT="$snapshot/initial-directory-structure" \
expect_run_sh $SUCCESSFULLY 'find . -maxdepth 2 | sort'
}
)
)
title "ein tool organize"
(when "running 'organize'"
snapshot="$snapshot/organize"
(with "no arguments"
it "succeeds and informs about the operations that it WOULD do" && {
WITH_SNAPSHOT="$snapshot/no-args-success" \
expect_run_sh $SUCCESSFULLY "$exe tool organize 2>/dev/null"
}

(with "--execute"
it "succeeds" && {
WITH_SNAPSHOT="$snapshot/execute-success" \
expect_run_sh $SUCCESSFULLY "$exe tool organize --execute 2>/dev/null"
}
it "does not change the directory structure at all" && {
WITH_SNAPSHOT="$snapshot/initial-directory-structure" \
expect_run_sh $SUCCESSFULLY 'find . -maxdepth 2 | sort'
}
)

it "changes the directory structure" && {
WITH_SNAPSHOT="$snapshot/directory-structure-after-organize" \
expect_run_sh $SUCCESSFULLY 'find . -maxdepth 2 | sort'
}
)
(with "--execute"
it "succeeds" && {
WITH_SNAPSHOT="$snapshot/execute-success" \
expect_run_sh $SUCCESSFULLY "$exe tool organize --execute 2>/dev/null"
}

(with "--execute again"
it "succeeds" && {
WITH_SNAPSHOT="$snapshot/execute-success" \
expect_run_sh $SUCCESSFULLY "$exe tool organize --execute 2>/dev/null"
}
it "changes the directory structure" && {
WITH_SNAPSHOT="$snapshot/directory-structure-after-organize" \
expect_run_sh $SUCCESSFULLY 'find . -maxdepth 2 | sort'
}
)

it "does not alter the directory structure as these are already in place" && {
WITH_SNAPSHOT="$snapshot/directory-structure-after-organize" \
expect_run_sh $SUCCESSFULLY 'find . -maxdepth 2 | sort'
}
)
(with "--execute again"
it "succeeds" && {
WITH_SNAPSHOT="$snapshot/execute-success" \
expect_run_sh $SUCCESSFULLY "$exe tool organize --execute 2>/dev/null"
}

(with "--execute with move into subdirectory of itself"
(cd example.com
rm -Rf a-repo-with-extension origin-and-fork
mv one-origin ../
cd ..
rmdir example.com && mv one-origin example.com
)
it "succeeds" && {
WITH_SNAPSHOT="$snapshot/execute-success-new-root" \
expect_run_sh $SUCCESSFULLY "$exe tool organize --execute 2>/dev/null"
}
it "does not alter the directory structure as these are already in place" && {
WITH_SNAPSHOT="$snapshot/directory-structure-after-organize" \
expect_run_sh $SUCCESSFULLY 'find . -maxdepth 2 | sort'
}
)

it "does alter the directory structure as these are already in place" && {
WITH_SNAPSHOT="$snapshot/directory-structure-after-organize-to-new-root" \
expect_run_sh $SUCCESSFULLY 'find . -maxdepth 2 -type d | sort'
}
(with "--execute with move into subdirectory of itself"
(cd example.com
rm -Rf a-repo-with-extension origin-and-fork
mv one-origin ../
cd ..
rmdir example.com && mv one-origin example.com
)
)
if test "$kind" != "max-pure"; then
(with "running with no further arguments"
it "succeeds and informs about possible operations" && {
WITH_SNAPSHOT="$snapshot/no-args-failure" \
expect_run_sh $WITH_CLAP_FAILURE "$exe t"
it "succeeds" && {
WITH_SNAPSHOT="$snapshot/execute-success-new-root" \
expect_run_sh $SUCCESSFULLY "$exe tool organize --execute 2>/dev/null"
}

it "does alter the directory structure as these are already in place" && {
WITH_SNAPSHOT="$snapshot/directory-structure-after-organize-to-new-root" \
expect_run_sh $SUCCESSFULLY 'find . -maxdepth 2 -type d | sort'
}
)
fi
)
if test "$kind" != "max-pure"; then
(with "running with no further arguments"
it "succeeds and informs about possible operations" && {
WITH_SNAPSHOT="$snapshot/no-args-failure" \
expect_run_sh $WITH_CLAP_FAILURE "$exe t"
}
)
fi
)
)
)
Expand Down
35 changes: 15 additions & 20 deletions tests/journey/gix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -549,20 +549,17 @@ title "gix commit-graph"
expect_run $WITH_FAILURE test -e "${PACK_FILE}".idx
}

(with_program find

if test "$kind" = "small" ; then
suffix=miniz-oxide
elif test "$kind" = "max-pure"; then
suffix=miniz-oxide-max
else
suffix=zlib-ng
fi
it "creates all pack objects, but the broken ones" && {
WITH_SNAPSHOT="$snapshot/broken-with-objects-dir-skip-checks-success-tree-$suffix" \
expect_run_sh $SUCCESSFULLY 'find . -type f | sort'
}
)
if test "$kind" = "small" ; then
suffix=miniz-oxide
elif test "$kind" = "max-pure"; then
suffix=miniz-oxide-max
else
suffix=zlib-ng
fi
it "creates all pack objects, but the broken ones" && {
WITH_SNAPSHOT="$snapshot/broken-with-objects-dir-skip-checks-success-tree-$suffix" \
expect_run_sh $SUCCESSFULLY 'find . -type f | sort'
}
)
)
)
Expand All @@ -582,12 +579,10 @@ title "gix commit-graph"
"${PACK_FILE}.pack" .
}

(with_program find
it "creates all pack objects" && {
WITH_SNAPSHOT="$snapshot/with-objects-dir-success-tree" \
expect_run_sh $SUCCESSFULLY 'find . -type f | sort'
}
)
it "creates all pack objects" && {
WITH_SNAPSHOT="$snapshot/with-objects-dir-success-tree" \
expect_run_sh $SUCCESSFULLY 'find . -type f | sort'
}
)
)
)
Expand Down
15 changes: 0 additions & 15 deletions tests/utilities.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@ RED="$(tput setaf 1 2>/dev/null || echo -n '')"
OFFSET=( )
STEP=" "

function with_program () {
local program="${1:?}"
hash "$program" &>/dev/null || {
function expect_run () {
echo 1>&2 "${WHITE} - skipped (missing program)"
}
function expect_run_sh () {
echo 1>&2 "${WHITE} - skipped (missing program)"
}
function expect_run_sh_no_pipefail () {
echo 1>&2 "${WHITE} - skipped (missing program)"
}
}
}

function on_ci () {
[ -n "${CI-}" ] || {
function expect_run () {
Expand Down
Loading