mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Regression test suite: get rid of unportable 'mktemp -dt'
The regression test suite used 'mktemp -dt' to create temporary directories, but that is not portable, e.g. it does not work on macOS, FreebSD or NetBSD. Installing a compatible 'mktemp' in another location in $PATH did not work either, as the regression test suite resets $PATH. src/cmd/ksh93/tests/*: - Replace many uses of 'mktemp -dt' by a portable and reasonably safe way to create a temporary directory. (cherry picked from commit 71f4c43703e3eff034009b4c8f4110bd32f4e209)
This commit is contained in:
parent
2e7602da2a
commit
2318de328a
31 changed files with 258 additions and 65 deletions
|
@ -28,8 +28,14 @@ alias err_exit='err_exit $LINENO'
|
|||
Command=${0##*/}
|
||||
integer Errors=0
|
||||
|
||||
tmp=$(mktemp -dt) || { err_exit mktemp -dt failed; exit 1; }
|
||||
trap "cd /; rm -rf $tmp" EXIT
|
||||
tmp=$(
|
||||
d=${TMPDIR:-/tmp}/ksh93.builtins.$$.${RANDOM:-0}
|
||||
mkdir -m700 -- "$d" && CDPATH= cd -P -- "$d" && pwd
|
||||
) || {
|
||||
err_exit 'mkdir failed'
|
||||
exit 1
|
||||
}
|
||||
trap 'cd / && rm -rf "$tmp"' EXIT
|
||||
|
||||
# test shell builtin commands
|
||||
builtin getconf
|
||||
|
@ -187,7 +193,7 @@ mkdir -p $tmp/a/b/c 2>/dev/null || err_exit "mkdir -p failed"
|
|||
$SHELL -c "cd $tmp/a/b; cd c" 2>/dev/null || err_exit "initial script relative cd fails"
|
||||
|
||||
trap 'print TERM' TERM
|
||||
exp=$'trap -- \'print TERM\' TERM\ntrap -- \'cd /; rm -rf '$tmp$'\' EXIT'
|
||||
exp=$'trap -- \'print TERM\' TERM\ntrap -- \'cd / && rm -rf "$tmp"\' EXIT'
|
||||
got=$(trap)
|
||||
[[ $got == $exp ]] || err_exit "\$(trap) failed -- expected \"$exp\", got \"$got\""
|
||||
exp='print TERM'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue