Skip to content

Commit 9f4bdff

Browse files
committed
Script tests with ISO 8859-1
1 parent fa9c6ba commit 9f4bdff

File tree

7 files changed

+88
-13
lines changed

7 files changed

+88
-13
lines changed

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ jobs:
8383
- name: Install Shells (linux only)
8484
if: ${{ matrix.os=='linux' }}
8585
run: |
86-
sudo apt-get install -y -qq ksh zsh yash
86+
sudo apt-get install -y -qq ksh zsh yash x11-utils
8787
sudo apt-get install -y mksh || true
8888
8989
- name: Install Shells & Shellcheck (macos only)
9090
if: ${{ matrix.os=='macos' }}
91-
run: brew install bash ksh93 shellcheck
91+
run: brew install bash ksh93 shellcheck luit
9292

9393
- name: Install Shellcheck (windows only)
9494
if: ${{ matrix.os=='windows' }}

.github/workflows/snapshot-release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ jobs:
7777
- name: Install Shells (linux only)
7878
if: ${{ matrix.os=='linux' }}
7979
run: |
80-
sudo apt-get install -y -qq ksh zsh yash
80+
sudo apt-get install -y -qq ksh zsh yash x11-utils
8181
sudo apt-get install -y mksh || true
8282
8383
- name: Install Shells & Shellcheck (macos only)
8484
if: ${{ matrix.os=='macos' }}
85-
run: brew install bash ksh93 shellcheck
85+
run: brew install bash ksh93 shellcheck luit
8686

8787
- name: Install Shellcheck (windows only)
8888
if: ${{ matrix.os=='windows' }}

.github/workflows/verify.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ jobs:
3838
- name: Install Shells (linux only)
3939
if: ${{ matrix.os=='linux' }}
4040
run: |
41-
sudo apt-get install -y -qq ksh zsh yash
41+
sudo apt-get install -y -qq ksh zsh yash x11-utils
4242
sudo apt-get install -y mksh || true
4343
4444
- name: Install Shells & Shellcheck (macos only)
4545
if: ${{ matrix.os=='macos' }}
46-
run: brew install bash ksh93 shellcheck
46+
run: brew install bash ksh93 shellcheck luit
4747

4848
- name: Install Shellcheck (windows only)
4949
if: ${{ matrix.os=='windows' }}

script-test/_test.shinc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ start_test()
5252
echo "Testing: $(command -v parseargs)"
5353
}
5454

55+
skip_test()
56+
{
57+
printf '\033[01;33mTEST SKIPPED - %s\033[0m\n' "$*"
58+
exit 0
59+
}
60+
5561
end_test()
5662
{
5763
rc=0
@@ -99,6 +105,7 @@ test_pa()
99105
ok "parseargs $args"
100106
else
101107
failed "parseargs $args"
108+
parseargs "$@"
102109
fi
103110

104111
return $rc

script-test/run.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ echo "Test Environment: $(uname -a)"
1313
case "$(uname -s | tr '[:upper:]' '[:lower:]')" in
1414
*cygwin*)
1515
IS_CYGWIN=TRUE
16-
export IS_CYGWIN
16+
IS_WINDOWS=TRUE
17+
export IS_CYGWIN IS_WINDOWS
1718
;;
1819
*msys* | *mingw*)
1920
IS_MSYS=TRUE
20-
export IS_MSYS
21+
IS_WINDOWS=TRUE
22+
export IS_MSYS IS_WINDOWS
2123
;;
2224
esac
2325

script-test/test-invalid-utf8.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ script_name="$(basename "$0")"
1515
start_test
1616

1717

18-
if [ -n "$IS_MSYS" ] || [ -n "$IS_CYGWIN" ]; then
19-
echo "Skipped on Windows"
18+
if [ -n "$IS_WINDOWS" ]; then
19+
skip_test "on Windows"
2020
elif [ "$TEST_SHELL" = "yash" ]; then
21-
echo "Skipped with shell Yash, as it can't handle invalid UTF-8"
21+
skip_test "shell Yash, as it can't handle invalid UTF-8"
2222
else
23-
24-
2523
inv_1="$(printf '\303\050')"
2624
inv_2="$(printf '\240\241')"
2725
inv_3="$(printf '\342\050\241')"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/sh
2+
#
3+
# Test parseargs with single byte
4+
#
5+
# shellcheck disable=SC2016
6+
7+
script_dir="$(cd "$(dirname "$0")" && pwd)" || exit 1
8+
script_name="$(basename "$0")"
9+
script_file="$script_dir/$script_name"
10+
11+
. "$script_dir/_test.shinc"
12+
13+
14+
check_single_byte()
15+
{
16+
# print the bytes for the UTF-8 Euro sign and check whether this results in
17+
# a single character
18+
x="$(printf '\342\202\254' | sed "s/./X/g")"
19+
if [ ${#x} = 1 ]; then
20+
return 1
21+
else
22+
return 0
23+
fi
24+
}
25+
26+
if ! check_single_byte; then
27+
# set ISO-8859-1 if available
28+
SB_LOCALE=$(locale -a | grep 'iso88591$' | head -n1)
29+
if [ -n "$SB_LOCALE" ]; then
30+
echo "Setting LC_ALL to $SB_LOCALE"
31+
export LC_ALL="$SB_LOCALE"
32+
fi
33+
34+
# If still no single byte char set -> exit
35+
if ! check_single_byte; then
36+
echo "No ISO-8859-1 character encoding available ... skipping"
37+
exit 0
38+
fi
39+
luit -encoding 'ISO 8859-1' "$script_file"
40+
exit $?
41+
fi
42+
43+
start_test
44+
45+
if [ -n "$IS_WINDOWS" ]; then
46+
skip_test "on Windows"
47+
elif [ "$TEST_SHELL" = "yash" ]; then
48+
skip_test "shell Yash, can't handle this"
49+
fi
50+
51+
test_pa 'test "${#1}" = 3' -o "n:name=name" -- "$(printf '\342\202\254')"
52+
53+
test_pa 'test "$1" = "Ä"' -o "n:name=name" -- Ä
54+
test_pa 'test "$name" = "Ä"' -o "n:name=name" -- -n Ä
55+
test_pa 'test "$name" = "Ä"' -o "n:name=name" -- -nÄ
56+
test_pa 'test "$name" = "Ä"' -o "n:name=name" -- --name Ä
57+
test_pa 'test "$name" = "Ä"' -o "n:name=name" -- --name=Ä
58+
59+
test_pa 'test "$1" = "Ä'\''Ö"' -o "n:name=name" -- Ä\'Ö
60+
test_pa 'test "$name" = "Ä'\''Ö"' -o "n:name=name" -- -n Ä\'Ö
61+
test_pa 'test "$name" = "Ä'\''Ö"' -o "n:name=name" -- -nÄ\'Ö
62+
test_pa 'test "$name" = "Ä'\''Ö"' -o "n:name=name" -- --name Ä\'Ö
63+
test_pa 'test "$name" = "Ä'\''Ö"' -o "n:name=name" -- --name=Ä\'Ö
64+
65+
end_test
66+
67+
# vim:fileencoding=latin1
68+

0 commit comments

Comments
 (0)