diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2018-09-29 18:56:35 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2018-10-01 17:35:14 -0400 |
commit | 4c1366f389d8691a82db120e54a213747e0b4647 (patch) | |
tree | 15eed14e74ebf9e327dff67b9dba53e09836fa7f /test/libremakepkg-test.sh | |
parent | 84a73785021d83078ed722942cc7aac377deb13b (diff) |
test: Normalize on "status" instead of "stat" "ret" or "r" for storing exit codes
The name "status" was chosen because BATS initializes status=0; if we
switch from Roundup to BATS, our common setup won't need set it
anymore.
Accomplish this with:
$ sed -ri -e 's/\$(stat|ret|r)\b/$status/g' -e 's/\b(stat|ret|r)=/status=/g' test/*.sh
$ sed -ri '/^\s*(local\s+)?status=0$/d' test/*-test.sh
Diffstat (limited to 'test/libremakepkg-test.sh')
-rw-r--r-- | test/libremakepkg-test.sh | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/test/libremakepkg-test.sh b/test/libremakepkg-test.sh index 0482638..58adcca 100644 --- a/test/libremakepkg-test.sh +++ b/test/libremakepkg-test.sh @@ -72,10 +72,10 @@ it_cleans_the_chroot_before_building() { libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty cd "$tmpdir/1" - testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; } + testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { status=$?; tail "$tmpdir/out"|cat -v; return $status; } cd "$tmpdir/2" - testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; } + testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { status=$?; tail "$tmpdir/out"|cat -v; return $status; } testsudo librechroot -l "$roundup_test_name" run libretools-testpkg1 'first time, pass' # This next line is actually a separate test, but it fits in well with this test, and chroot tests are slow.. @@ -83,7 +83,7 @@ it_cleans_the_chroot_before_building() { not testsudo librechroot -l "$roundup_test_name" run test -e /var/cache/pacman/pkg/libretools-testpkg1-1.0-1-any.pkg.tar.?z cd "$tmpdir/3" - testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { r=$?; tail "$tmpdir/out"|cat -v; return $r; } + testsudo libremakepkg -l "$roundup_test_name" &> "$tmpdir/out" || { status=$?; tail "$tmpdir/out"|cat -v; return $status; } not testsudo librechroot -l "$roundup_test_name" run libretools-testpkg1 'second time, fail' } @@ -110,11 +110,10 @@ it_otherwise_fails_as_normal_user() { # I do this to give it a chance of passing cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" cd "$tmpdir" - local stat=0 - libremakepkg >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + libremakepkg >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - [[ $stat != 0 ]] + [[ $status != 0 ]] empty $tmpdir/stdout not empty $tmpdir/stderr } @@ -123,15 +122,14 @@ it_fails_if_a_hook_fails() { require network sudo || return 0 cp libremakepkg.d/PKGBUILD-hello "$tmpdir/PKGBUILD" cd "$tmpdir" - local stat=0 sed -i 's/^BLACKLIST=.*/&-bogus/' "$XDG_CONFIG_HOME"/libretools/libretools.conf trap 'sed -i s/-bogus// "$XDG_CONFIG_HOME"/libretools/libretools.conf' RETURN libremessages msg 'Creating a chroot, may take a few minutes' &>/dev/tty - testsudo libremakepkg -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? + testsudo libremakepkg -l "$roundup_test_name" >$tmpdir/stdout 2>$tmpdir/stderr || status=$? - [[ $stat != 0 ]] + [[ $status != 0 ]] tail -n1 $tmpdir/stderr | grep -qF '==> ERROR: Failure(s) in check_pkgbuild: check_pkgbuild_nonfree' } @@ -152,8 +150,8 @@ it_detects_distcc_files() { # now throw a wrench in it testsudo librechroot -l "$roundup_test_name" run touch /bin/distcc-tool # and make sure that the engine broke - testsudo libremakepkg -l "$roundup_test_name" || stat=$? - [[ $stat != 0 ]] + testsudo libremakepkg -l "$roundup_test_name" || status=$? + [[ $status != 0 ]] not [[ -f $(echo libretools-hello-1.0-1-any.pkg.tar.?z) ]] } |