-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from andersonvom/fail-build-on-any-errors
Return non-zero if any errors occur
- Loading branch information
Showing
2 changed files
with
55 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env bash | ||
|
||
# shellcheck disable=SC1091,SC2155,SC2154,SC2034 | ||
# Not following: (error message here) | ||
# Declare and assign separately to avoid masking return values. | ||
# var is referenced but not assigned. | ||
# var appears unused | ||
|
||
source ./gitrise.sh -T | ||
|
||
testExitCodeRemainsZeroWhenSuccessful() { | ||
exit_code=0 | ||
# shellcheck disable=SC2317 # Don't warn about unreachable commands in this function | ||
curl() { | ||
return 0 | ||
} | ||
|
||
download_single_artifact "some-slug" &> /dev/null | ||
local expected_code=0 | ||
assertEquals "Status codes did not match" "$expected_code" "${exit_code}" | ||
} | ||
|
||
testDoesNotOverrideExistingExitCode() { | ||
exit_code=1 | ||
# shellcheck disable=SC2317 # Don't warn about unreachable commands in this function | ||
curl() { | ||
return 0 | ||
} | ||
|
||
download_single_artifact "some-slug" &> /dev/null | ||
local expected_code=1 | ||
assertEquals "Status codes did not match" "$expected_code" "${exit_code}" | ||
} | ||
|
||
testAccumulatesErrorsOnCurlFailures() { | ||
exit_code=1 | ||
# shellcheck disable=SC2317 # Don't warn about unreachable commands in this function | ||
curl() { | ||
return 1 | ||
} | ||
|
||
download_single_artifact "some-slug" &> /dev/null | ||
local expected_code=2 | ||
assertEquals "Status codes did not match" "$expected_code" "${exit_code}" | ||
} | ||
|
||
tearDown() { | ||
build_status=0 | ||
} | ||
|
||
. ./tests/shunit2 |