-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix running script from other directory #11
Merged
JackPGreen
merged 4 commits into
hazelcast:master
from
JackPGreen:fix-running-other-directory
Aug 20, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
SCRIPT_DIR=$(readlink -f "$0") | ||
SCRIPT_DIR="$(dirname "${SCRIPT_DIR}")" | ||
|
||
# Source the latest version of assert.sh unit testing library and include in current shell | ||
curl --silent https://raw.githubusercontent.com/hazelcast/assert.sh/main/assert.sh --output assert.sh | ||
|
||
# shellcheck source=/dev/null | ||
# You _should_ be able to avoid a temporary file with something like | ||
# . <(echo "${assert_script_content}") | ||
# But this doesn't work on the MacOS GitHub runner (but does on MacOS locally) | ||
. assert.sh | ||
# shellcheck source=/dev/null | ||
# . "${SCRIPT_DIR}"/backport | ||
|
||
TESTS_RESULT=0 | ||
|
||
function test_get_exit_code { | ||
local expected_exit_code=$1 | ||
local backport_arguments=( "${@:2:99}" ) | ||
local actual_exit_code | ||
("${SCRIPT_DIR}"/backport "${backport_arguments[@]:-}") && true | ||
actual_exit_code=$? | ||
local msg="Expected exit code with arguments \"${backport_arguments[*]:-}\" should be equal to \"${expected_exit_code}\"" | ||
assert_eq "${expected_exit_code}" "${actual_exit_code}" "${msg}" && log_success "${msg}" || TESTS_RESULT=$? | ||
} | ||
|
||
log_header "Tests exit code" | ||
# https://github.com/hazelcast/backport/issues/10 | ||
# Find location of a temp directory, where script is _unlikely_ to exist | ||
TMPDIR=$(mktemp) | ||
TMPDIR="$(dirname "${TMPDIR}")" | ||
(cd "${TMPDIR}"; test_get_exit_code 2) | ||
|
||
assert_eq 0 "${TESTS_RESULT}" "All tests should pass" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR=$(readlink -f "$0") | ||
SCRIPT_DIR="$(dirname "${SCRIPT_DIR}")" | ||
|
||
find "$SCRIPT_DIR" -name "*_tests" -print0 | xargs -0 -n1 bash |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To fix https://www.shellcheck.net/wiki/SC2312