summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2018-02-22 21:15:39 -0500
committerEli Schwartz <eschwartz@archlinux.org>2018-03-15 21:58:38 -0400
commit4ae3ea2f71344045fa4990c0524b4c662ab83cfc (patch)
treefb53ac6ab64e869cc83ecd48b1af71fc110415a4
parent33aae318542016f66d2f0e09654606649d404ff2 (diff)
test: common.bash:__getCheckSum: Don't rely on IFS
I managed to stumble across a bug in BATS where the run() function screwed with the global IFS. The bug has been fixed in git, but isn't in a release yet. https://github.com/sstephenson/bats/issues/89 Anyway, this bug breaks __getCheckSum(). Fortunately, we have avoided tripping it so far because luck has it that we never call __getCheckSum() after run() in the same test. So, there's nothing actually broken here, but it makes me nervous. So go ahead and modify __getCheckSum to not rely on IFS. And, while we're at it: declare the result variable and set it as separate commands. Doing both in the same command masks the exit code of the subshell expansion. We don't explicitly check the exit code, but BATS runs the test suite with `set -e`, so splitting it does mean that BATS will now detect errors from sha1sum. We don't really expect that to happen, but if BATS will give us error checking on it for free, why not?
-rw-r--r--test/lib/common.bash5
1 files changed, 3 insertions, 2 deletions
diff --git a/test/lib/common.bash b/test/lib/common.bash
index 568a541..5411641 100644
--- a/test/lib/common.bash
+++ b/test/lib/common.bash
@@ -9,8 +9,9 @@ __updatePKGBUILD() {
}
__getCheckSum() {
- local result=($(sha1sum $1))
- echo ${result[0]}
+ local result
+ result="$(sha1sum "$1")"
+ echo "${result%% *}"
}
__buildPackage() {