Skip to content
This repository was archived by the owner on May 20, 2024. It is now read-only.

Commit 1349bb5

Browse files
CodingMarkusCodingMarkus
CodingMarkus
authored and
CodingMarkus
committed
Ensure all print tests run in a subshell
1 parent fc5e7cb commit 1349bb5

File tree

2 files changed

+39
-22
lines changed

2 files changed

+39
-22
lines changed

test/basic/bin/test_perror.sh

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,25 @@ fi
1111

1212
# =============================================================================
1313

14-
# perror_i must accept at least one argument
15-
set +e
16-
( perror_i_psst 2>/dev/null )
17-
[ $? = 127 ] || test_fail_psst $LINENO
18-
set -e
14+
(
15+
# shellcheck disable=SC2030 disable=SC2031
16+
export COLUMNS=30
1917

20-
# Argument must not be empty
21-
set +e
22-
( perror_i_psst "" 2>/dev/null )
23-
[ $? = 127 ] || test_fail_psst $LINENO
24-
set -e
18+
# shellcheck source=../../../lib/psst/basic.inc.sh
19+
. "$INCLUDE_PSST/basic.inc.sh"
20+
21+
# perror_i must accept at least one argument
22+
set +e
23+
( perror_i_psst 2>/dev/null )
24+
[ $? = 127 ] || test_fail_psst $LINENO
25+
set -e
26+
27+
# Argument must not be empty
28+
set +e
29+
( perror_i_psst "" 2>/dev/null )
30+
[ $? = 127 ] || test_fail_psst $LINENO
31+
set -e
32+
)
2533

2634

2735
# Must respect columns setting

test/basic/bin/test_print.sh

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,28 @@ then
99
INCLUDE_PSST="$cmdBase/../../../lib/psst"
1010
fi
1111

12+
1213
# =============================================================================
1314

14-
# print_i must accept at least one argument
15-
set +e
16-
( print_i_psst 2>/dev/null )
17-
[ $? = 127 ] || test_fail_psst $LINENO
18-
set -e
15+
(
16+
# shellcheck disable=SC2030 disable=SC2031
17+
export COLUMNS=30
1918

20-
# Argument must not be empty
21-
set +e
22-
( print_i_psst "" 2>/dev/null )
23-
[ $? = 127 ] || test_fail_psst $LINENO
24-
set -e
19+
# shellcheck source=../../../lib/psst/basic.inc.sh
20+
. "$INCLUDE_PSST/basic.inc.sh"
21+
22+
# print_i must accept at least one argument
23+
set +e
24+
( print_i_psst 2>/dev/null )
25+
[ $? = 127 ] || test_fail_psst $LINENO
26+
set -e
27+
28+
# Argument must not be empty
29+
set +e
30+
( print_i_psst "" 2>/dev/null )
31+
[ $? = 127 ] || test_fail_psst $LINENO
32+
set -e
33+
)
2534

2635

2736
# Must respect columns setting
@@ -57,7 +66,7 @@ fi
5766
. "$INCLUDE_PSST/basic.inc.sh"
5867

5968
tmpDir="/tmp"
60-
tmpdir_psst "tmpDir"
69+
tmpdir_psst tmpDir
6170

6271
printDst="$tmpDir/print_psst"
6372
print_psst "This is a very long test sentence, that should be split" \
@@ -78,7 +87,7 @@ fi
7887
. "$INCLUDE_PSST/basic.inc.sh"
7988

8089
tmpDir="/tmp"
81-
tmpdir_psst "tmpDir"
90+
tmpdir_psst tmpDir
8291

8392
printDst="$tmpDir/print_psst"
8493
print_i_psst 5 "This is a very long test sentence, that should be" \

0 commit comments

Comments
 (0)