1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2026-10-24 00:48:56 +03:00

tests: avoid grep in init.sh

* tests/init.sh (warn_, gl_shell_test_script_):
Avoid the use of grep, as that introduces an unwanted dependency.
On older systems like Solaris there can be many greps and they
can be buggy, so it’s better to not rely on them in a central
part of the test harness.
This commit is contained in:
Paul Eggert
2025-09-21 13:49:18 -07:00
parent 8ac8a9b4f2
commit e4c911bb44
2 changed files with 18 additions and 7 deletions

View File

@@ -1,5 +1,12 @@
2025-09-21 Paul Eggert <eggert@cs.ucla.edu>
tests: avoid grep in init.sh
* tests/init.sh (warn_, gl_shell_test_script_):
Avoid the use of grep, as that introduces an unwanted dependency.
On older systems like Solaris there can be many greps and they
can be buggy, so it’s better to not rely on them in a central
part of the test harness.
tests: avoid test failure due to rmdir race
* tests/init.sh (remove_tmp_): If the rm -rf fails, wait a second
and try again. This works around a problem I observed on Solaris

View File

@@ -103,7 +103,11 @@ warn_ ()
case $IFS in
' '*) printf '%s\n' "$*" >&2
test $stderr_fileno_ = 2 \
|| { printf '%s\n' "$*" | sed 1q >&$stderr_fileno_ ; } ;;
|| { local args=$*
local firstline=${args%%"$gl_init_sh_nl_"*}
printf '%s\n' "$firstline" >&$stderr_fileno_
}
;;
*) (IFS=' '; warn_ "$@");;
esac
}
@@ -160,12 +164,12 @@ fi
# ? - not ok
gl_shell_test_script_='
test $(echo y) = y || exit 1
LC_ALL=en_US.UTF-8 printf "\\351" 2>/dev/null \
| LC_ALL=C tr "\\351" x | LC_ALL=C grep "^x$" > /dev/null \
|| exit 1
printf "\\351" 2>/dev/null \
| LC_ALL=C tr "\\351" x | LC_ALL=C grep "^x$" > /dev/null \
|| exit 1
case $({ LC_ALL=en_US.UTF-8 printf "\\351"
printf "\\351\\n"
} 2>/dev/null | LC_ALL=C tr "\\351" x) in
xx) ;;
*) exit 1;;
esac
f_local_() { local v=1; }; f_local_ || exit 1
f_dash_local_fail_() { local t=$(printf " 1"); }; f_dash_local_fail_
score_=10