Skip to content
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

Remove execution-specific code in sourcing-only .sh files #1436

Merged
merged 1 commit into from
Jul 1, 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
Remove execution-specific code in sourcing-only .sh files
Some of the .sh script files are only meant ever to be sourced and
not to be executed. These are already correctly not marked
executable, but some of them contained code that would only be
proper for scripts that are actually run, and not for scripts
that are only sourced:

- One contained a #! line, which this removes because it falsely
  indicated an intent to be executed, and because it was not
  effective even in principle when sourcing the script.

- Two contained `set -eu` commands affecting the behavior of the
  running interpreter, which were redundant because the script for
  which they are helpers already runs such a command. If they are
  later sourced into other scripts (a use for which they are not
  intended and would probably require further modification), those
  other scripts might not have these `set` commands, but in that
  case those commands' behavior would probably not be wanted.

This also adds "Must be sourced into the main journey test"
comments at the top of .sh files to which they apply, mirroring
the presence of such comments in other such files. Besides
consistency, this has the advantage of making clear what all the
scripts that are meant only for sourcing are being used for.
  • Loading branch information
EliahKagan committed Jun 30, 2024
commit 55d9ceb48d841fe83a5bf99daa121b2e00ed9735
2 changes: 1 addition & 1 deletion tests/helpers.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Must be sourced into the main journey test

function set-static-git-environment() {
set -a
Expand Down Expand Up @@ -66,4 +67,3 @@ function launch-git-daemon() {
done
trap 'kill $daemon_pid' EXIT
}

1 change: 0 additions & 1 deletion tests/journey/ein.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Must be sourced into the main journey test
set -eu

if test "$kind" = "max" || test "$kind" = "max-pure"; then
title "Porcelain ${kind}"
Expand Down
1 change: 0 additions & 1 deletion tests/journey/gix.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Must be sourced into the main journey test
set -eu

title plumbing "${kind}"
snapshot="$snapshot/plumbing"
Expand Down
2 changes: 1 addition & 1 deletion tests/utilities.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
# Must be sourced into the main journey test

WHITE="$(tput setaf 9 2>/dev/null || echo -n '')"
YELLOW="$(tput setaf 3 2>/dev/null || echo -n '')"
Expand Down
Loading