mirror of
git://git.code.sf.net/p/zsh/code
synced 2024-06-07 15:56:04 +02:00
6fc8e8628f
* Test/D02glob.ztst: On the "unreadable directories can be globbed (users/24619, users/24626)" test, resolve conflicts by removing the Cygwin-only skip that has been added in master, since the test is passing on this branch. This effectively reverts workers/45492. See discussion starting in workers/45504. * origin/master: unposted: Remove 'sgi', as that OpenBSD port has been discontinued. 45509: fix typos in B01cd.ztst 45490 (+45495 and a test): refactor rlimits.c github #49: Fix typo: longson should be loongson users/24710: Fix job control problem with sudo. 45492: skip test added by users/24633 on Cygwin 45488: COMP_WORDS for bash need "$@"-style quoting 45487: Missing mod_export declarations for AIX 45447: Complete vcs_info_hookadd and vcs_info_hookdel. Expose _vcs_info_hooks as a top-level helper function. 45463: test: kill: Document why we use SIGURG 45453: builtins: kill: Do not signal current process group when pid is empty 45452: builtins: kill: Add `kill ''` regression test with explicit sigspec 45451: builtins: kill: Add basic test suite github #48/0002: vcs_info git: properly detect bare repositories github #48/0001: vcs_info git: avoid warnings in bare repositories unposted: Post-release version bump unposted: Release 5.8 CVE-2019-20044: Update change log for preceding commits Update NEWS/README Add unsetopt/PRIVILEGED tests Clean up error-message white space Improve PRIVILEGED fixes (again) Improve PRIVILEGED fixes Drop privileges securely unposted: V01zmodload: Fix failing test from workers/45385 45423: _su: Improve arg handling, shell look-ups unposted: _zip: Recognise '--' 45385: Add a test for 'zmodload -Fa' preemptively disabling ("blacklisting"?) features. unposted: Test release: 5.7.1-test-3 zsh/system: Fix infinite loop in sysread _diff_options: Restore -w completion lost in workers/43351 unposted: Fix ChangeLog typo. 45368: Add tests for workers/45367's issue about double slashes in 'cd -P' and /home/daniel/in/zsh. 45373: Fix ERR_EXIT bug in else branch of if. 45372: Record a symlink loop bug involving :P 45365: _git: Fix __git_recent_branches for the case when a commit has an empty message 45343: Queue signals around arithmetic evaluations 45344: Document where third-party completion functions should be installed. 45345: internal: ztst.vim: Fix highlighting of zsh comments in test payload unposted: internal: Add some comments and fix indentation. No functional change. 45340: internal: Document the difference between paramtab and realparamtab. 45332: _git: add completion for git-version _brace_parameter: add missing \ Conflicts: ChangeLog Test/D02glob.ztst Test/V01zmodload.ztst
413 lines
9.6 KiB
Plaintext
413 lines
9.6 KiB
Plaintext
# Test basic module loading
|
|
|
|
%prep
|
|
# Figure out which modules it ought to be possible to load by looking at
|
|
# the config.modules file. This differs for static vs. dynamic builds.
|
|
|
|
mods=()
|
|
deps="$(zmodload -Ld)"
|
|
while read name modfile link auto load funcs
|
|
do
|
|
[[ $name == \#* ]] && continue
|
|
eval "$name $modfile $link $auto $load"
|
|
[[ $link == no ]] && continue
|
|
mods=($mods $name)
|
|
moddeps=
|
|
modfile=$ZTST_srcdir/../$modfile
|
|
eval ${${${(f)"$(<$modfile)"}[(r)moddeps=*]}:-:}
|
|
[[ -n $moddeps ]] && zmodload -d $name $=moddeps
|
|
done < $ZTST_testdir/../config.modules
|
|
|
|
zmodunload() {
|
|
local m n=$#
|
|
(( n == 0 )) && return 0
|
|
for m
|
|
do
|
|
if [[ -z ${(M)${(f)"$(zmodload -d)"}:#*:* $m( *|)} ]]
|
|
then
|
|
zmodload -u $m && zmodload -ud $m || return 1
|
|
shift
|
|
else
|
|
set $@[2,-1] $m
|
|
fi
|
|
done
|
|
if (( $# < n ))
|
|
then
|
|
zmodunload $*
|
|
else
|
|
zmodload -u $*
|
|
fi
|
|
}
|
|
|
|
mkdir zmodload.tmp
|
|
cd zmodload.tmp
|
|
|
|
%test
|
|
|
|
# This first test depends on knowing that zsh is run with +Z from the
|
|
# Makefile, and that ztst.zsh loads the parameter module.
|
|
|
|
zmodload -L
|
|
0:List the loaded modules
|
|
>zmodload zsh/main
|
|
>zmodload zsh/parameter
|
|
|
|
# You used to need zmodload -i to avoid an error.
|
|
# That has been deemed pointless, so now an attempt
|
|
# to load a loaded module should succeed.
|
|
zmodload zsh/main
|
|
0:Test reloading an already-loaded module
|
|
|
|
# Loop over the modules found above and attempt to load each one. Use
|
|
# the -i flag in case dependencies cause multiple modules to be loaded,
|
|
# or in case some previous test suite loaded a module.
|
|
|
|
for m in $mods
|
|
do
|
|
zmodload $m || mods[(r)$m]=()
|
|
done
|
|
0d:Test loading of all compiled modules
|
|
|
|
zmodload -e $mods
|
|
0d:Check that zsh believes the modules did load
|
|
|
|
# Now check for proper failure conditions by trying some operations on
|
|
# a nonexistent module.
|
|
|
|
zmodload bogus/notamodule
|
|
1D:Check that loading a nonexistent module fails
|
|
|
|
zmodload -u bogus/notamodule
|
|
1D:Check that unloading a nonexistent module fails
|
|
|
|
# Test adding and removing autoloads, using a nonexistent module.
|
|
|
|
zmodload -ab bogus
|
|
zmodload -ub bogus
|
|
0:Add/remove autoloaded builtin
|
|
|
|
zmodload -ub bogus
|
|
1:Fail to remove unautoloaded builtin
|
|
?(eval):zmodload:1: bogus: no such builtin
|
|
|
|
zmodload -ac bogus
|
|
zmodload -uc bogus
|
|
0:Add/remove autoloaded condition
|
|
|
|
zmodload -uc bogus
|
|
1:Fail to remove unautoloaded condition
|
|
?(eval):zmodload:1: bogus: no such condition
|
|
|
|
zmodload -ap bogus
|
|
zmodload -up bogus
|
|
0:Add/remove autoloaded parameter
|
|
|
|
zmodload -up bogus
|
|
1:Fail to remove unautoloaded parameter
|
|
?(eval):zmodload:1: bogus: no such parameter
|
|
|
|
zmodload -af bogus
|
|
zmodload -uf bogus
|
|
0:Add/remove autoloaded math function
|
|
|
|
zmodload -uf bogus
|
|
1:Fail to remove unautoloaded math function
|
|
?(eval):zmodload:1: bogus: no such math function
|
|
|
|
# If the "example" module is available, test various autoloading behavior.
|
|
|
|
if [[ $mods[(r)zsh/example] == zsh/example ]]; then
|
|
zmodload -u zsh/example
|
|
zmodload -ab zsh/example example
|
|
builtin example
|
|
zmodload -e zsh/example
|
|
else print -u$ZTST_fd Warning: zsh/example not linked: not checking autoloading
|
|
fi
|
|
0d:Autoload a module via a builtin
|
|
|
|
if [[ $mods[(r)zsh/example] == zsh/example ]]; then
|
|
zmodload -u zsh/example
|
|
builtin example
|
|
fi
|
|
0d:Autoloads are persistent
|
|
|
|
(zmodload -u zsh/parameter
|
|
zmodload -aF zsh/parameter b:fail
|
|
fail
|
|
print "Shouldn't get here.")
|
|
1:Failed builtin autoload
|
|
?(eval):3: module `zsh/parameter' has no such feature: `b:fail': autoload cancelled
|
|
?(eval):3: autoloading module zsh/parameter failed to define builtin: fail
|
|
|
|
(zmodload -u zsh/parameter
|
|
zmodload -aF zsh/parameter p:fail
|
|
print $fail
|
|
print "Shouldn't get here.")
|
|
1:Failed parameter autoload
|
|
?(eval):3: module `zsh/parameter' has no such feature: `p:fail': autoload cancelled
|
|
?(eval):3: autoloading module zsh/parameter failed to define parameter: fail
|
|
|
|
(zmodload -u zsh/parameter
|
|
zmodload -aF zsh/parameter c:fail
|
|
[[ -fail foo ]]
|
|
print "Shouldn't get here.")
|
|
2:Failed condition autoload
|
|
?(eval):3: module `zsh/parameter' has no such feature: `c:fail': autoload cancelled
|
|
?(eval):3: unknown condition: -fail
|
|
|
|
(zmodload -u zsh/parameter
|
|
zmodload -aF zsh/parameter f:fail
|
|
(( fail() )) )
|
|
2:Failed math function autoload
|
|
?(eval):3: module `zsh/parameter' has no such feature: `f:fail': autoload cancelled
|
|
?(eval):3: autoloading module zsh/parameter failed to define math function: fail
|
|
|
|
zmodload -aF zsh/parameter f:fail2
|
|
1:Immediate autoload failure on non-existent feature when module loaded
|
|
?(eval):zmodload:1: module `zsh/parameter' has no such feature: `f:fail2'
|
|
|
|
(zmodload -u zsh/parameter
|
|
zmodload -aF zsh/parameter p:fail
|
|
print $(( ${#modules} > 1 )) )
|
|
0:Autoloads checked on loading but don't necessarily effect current command
|
|
>1
|
|
?(eval):3: module `zsh/parameter' has no such feature: `p:fail': autoload cancelled
|
|
|
|
zmodload -laF zsh/parameter
|
|
0:List default autoloads
|
|
>p:aliases
|
|
>p:builtins
|
|
>p:commands
|
|
>p:dirstack
|
|
>p:dis_aliases
|
|
>p:dis_builtins
|
|
>p:dis_functions
|
|
>p:dis_functions_source
|
|
>p:dis_galiases
|
|
>p:dis_patchars
|
|
>p:dis_reswords
|
|
>p:dis_saliases
|
|
>p:funcfiletrace
|
|
>p:funcsourcetrace
|
|
>p:funcstack
|
|
>p:functions
|
|
>p:functions_source
|
|
>p:functrace
|
|
>p:galiases
|
|
>p:history
|
|
>p:historywords
|
|
>p:jobdirs
|
|
>p:jobstates
|
|
>p:jobtexts
|
|
>p:modules
|
|
>p:nameddirs
|
|
>p:options
|
|
>p:parameters
|
|
>p:patchars
|
|
>p:reswords
|
|
>p:saliases
|
|
>p:userdirs
|
|
>p:usergroups
|
|
|
|
if [[ $mods[(r)zsh/example] == zsh/example ]]; then
|
|
zmodload -u zsh/example
|
|
zmodload -ac -I zsh/example ex
|
|
[[ exam -ex ple ]]
|
|
zmodload -e zsh/example
|
|
else :
|
|
fi
|
|
0d:Autoload a module via a condition
|
|
|
|
if [[ $mods[(r)zsh/example] == zsh/example ]]; then
|
|
zmodload -u zsh/example
|
|
zmodload -ap zsh/example exint
|
|
: $exint
|
|
zmodload -e zsh/example
|
|
else :
|
|
fi
|
|
0d:Autoload a module via a parameter
|
|
|
|
if [[ $mods[(r)zsh/example] == zsh/example ]]; then
|
|
zmodload -u zsh/example
|
|
zmodload -af zsh/example sum
|
|
(( sum(1) ))
|
|
zmodload -e zsh/example
|
|
else :
|
|
fi
|
|
0d:Autoload a module via a math function
|
|
|
|
# Test module aliases
|
|
|
|
zmodload -A example=zsh/example
|
|
zmodload -A
|
|
0:Test creating a module alias
|
|
>example -> zsh/example
|
|
|
|
if [[ $mods[(r)zsh/example] == zsh/example ]]; then
|
|
zmodload -u example
|
|
zmodload -ab example
|
|
builtin example
|
|
zmodload -e example
|
|
else :
|
|
fi
|
|
0d:Unload/autoload the module via its alias
|
|
|
|
zmodload -R example
|
|
zmodload -e example
|
|
1:Delete the module alias again
|
|
|
|
zmodload >zmodload_list
|
|
print -l ${(o)mods} >mods_list
|
|
diff zmodload_list mods_list
|
|
0:Listing with zmodload should give all our modules.
|
|
|
|
# Don't unload the main module.
|
|
# Do unload zsh/parameter, but reload it as it is needed.
|
|
|
|
mods[(r)zsh/main]=()
|
|
zmodunload $mods
|
|
zmodload zsh/parameter
|
|
0d:Unload the modules loaded by this test suite
|
|
|
|
zmodload -aF zsh/zftp b:zftp
|
|
zmodload -LaF | grep zftp
|
|
0:Listing feature autoloads includes unloaded modules
|
|
>zmodload -Fa zsh/zftp b:zftp
|
|
|
|
if ! zmodload zsh/system >/dev/null 2>&1; then
|
|
ZTST_skip="zsh/system module not available"
|
|
else
|
|
zmodload -lF zsh/system
|
|
zmodload -F zsh/system -p:errnos
|
|
print ${+errnos}
|
|
zmodload -lF zsh/system
|
|
zmodload -F zsh/system +p:errnos
|
|
print ${+errnos}
|
|
zmodload -lF zsh/system
|
|
fi
|
|
0:Regression tests for index bug with math functions.
|
|
>+b:syserror
|
|
>+b:sysread
|
|
>+b:syswrite
|
|
>+b:sysopen
|
|
>+b:sysseek
|
|
>+b:zsystem
|
|
>+f:systell
|
|
>+p:errnos
|
|
>+p:sysparams
|
|
>0
|
|
>+b:syserror
|
|
>+b:sysread
|
|
>+b:syswrite
|
|
>+b:sysopen
|
|
>+b:sysseek
|
|
>+b:zsystem
|
|
>+f:systell
|
|
>-p:errnos
|
|
>+p:sysparams
|
|
>1
|
|
>+b:syserror
|
|
>+b:sysread
|
|
>+b:syswrite
|
|
>+b:sysopen
|
|
>+b:sysseek
|
|
>+b:zsystem
|
|
>+f:systell
|
|
>+p:errnos
|
|
>+p:sysparams
|
|
|
|
if ! zmodload zsh/system >/dev/null 2>&1; then
|
|
ZTST_skip="zsh/system module not available"
|
|
else
|
|
zmodload -F zsh/system -f:systell
|
|
zmodload -lF zsh/system
|
|
(print $(( systell(-1) )))
|
|
zmodload -F zsh/system +f:systell
|
|
zmodload -lF zsh/system
|
|
(print $(( systell(-1) )))
|
|
fi
|
|
1:Module Features for math functions
|
|
>+b:syserror
|
|
>+b:sysread
|
|
>+b:syswrite
|
|
>+b:sysopen
|
|
>+b:sysseek
|
|
>+b:zsystem
|
|
>-f:systell
|
|
>+p:errnos
|
|
>+p:sysparams
|
|
>+b:syserror
|
|
>+b:sysread
|
|
>+b:syswrite
|
|
>+b:sysopen
|
|
>+b:sysseek
|
|
>+b:zsystem
|
|
>+f:systell
|
|
>+p:errnos
|
|
>+p:sysparams
|
|
?(eval):6: unknown function: systell
|
|
?(eval):9: file descriptor out of range
|
|
|
|
$ZTST_testdir/../Src/zsh -fc '
|
|
if zmodload -e zsh/parameter; then zmodload -u zsh/parameter; fi
|
|
unset options
|
|
zmodload zsh/parameter
|
|
echo $+options
|
|
'
|
|
-f:can unset a non-readonly autoloadable parameter before loading the module
|
|
>0
|
|
# Currently prints '1'.
|
|
|
|
$ZTST_testdir/../Src/zsh -fc '
|
|
zmodload zsh/parameter
|
|
unset options
|
|
echo $+options
|
|
'
|
|
0:can unset a non-readonly autoloadable parameter after loading the module
|
|
>0
|
|
|
|
$ZTST_testdir/../Src/zsh -fc '
|
|
if zmodload -e zsh/parameter; then zmodload -u zsh/parameter; fi
|
|
unset builtins
|
|
'
|
|
-f:can't unset a readonly autoloadable parameter before loading the module
|
|
*?zsh:?: read-only variable: builtins
|
|
# Currently, the 'unset' succeeds.
|
|
|
|
$ZTST_testdir/../Src/zsh -fc '
|
|
zmodload zsh/parameter
|
|
unset builtins
|
|
'
|
|
1:can't unset a readonly autoloadable parameter after loading the module
|
|
?zsh:3: read-only variable: builtins
|
|
|
|
$ZTST_testdir/../Src/zsh -fc '
|
|
zmodload zsh/parameter
|
|
zmodload -u zsh/parameter
|
|
echo $options
|
|
'
|
|
0:unloading a module doesn't implicitly unset autoloadable parameters
|
|
*>(on|off) *
|
|
|
|
$ZTST_testdir/../Src/zsh -fc "
|
|
MODULE_PATH=${(q)MODULE_PATH}
|
|
#
|
|
zmodload zsh/zutil
|
|
zmodload -Fal zsh/zutil | grep parse
|
|
zmodload -u zsh/zutil
|
|
#
|
|
zmodload -Fa zsh/zutil -b:zregexparse
|
|
zmodload zsh/zutil
|
|
zmodload -Fal zsh/zutil | grep parse >&2
|
|
"
|
|
0:zmodload -Fa can disable features from being loaded
|
|
>b:zparseopts
|
|
>b:zregexparse
|
|
?b:zparseopts
|
|
|
|
%clean
|
|
|
|
eval "$deps"
|
|
unset deps name modfile link auto load funcs mods moddeps
|
|
unfunction zmodunload
|