############################################################################## # Modules Revision 3.0 # Providing a flexible user environment # # File: completion.00-init/%M% # Revision: %I% # First Edition: 2026/08/07 # Last Mod.: %U%, %G% # # Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr # # Description: Testuite testsequence # Command: # Sub-Command: # # Comment: %C{ # Defines all patterns used further in the testsuite # }C% # ############################################################################## proc find_bin {name} { set path {} if {[info exists ::env(PATH)]} { foreach dir [split $::env(PATH) ":"] { if {[file executable "$dir/$name"]} { set path "$dir/$name" break } } } return $path } if {$verbose} { send_user "\tInitializing the testsuite ...\n" } set TCLSH $env(TCLSH) set MODULECMD $env(MODULECMD) # a bash binary is required to drive interactive completion tests set bashbin [find_bin bash] if {$bashbin eq {}} { unsupported {no bash binary found to drive completion tests} } # built bash completion script under test set bashcompletion "$env(OBJDIR)/init/bash_completion" if {![file exists $bashcompletion]} { unsupported "completion script not found: $bashcompletion (run 'make initdir' first)" } # a zsh binary is required to drive interactive completion tests set zshbin [find_bin zsh] if {$zshbin eq {}} { unsupported {no zsh binary found to drive completion tests} } # built zsh completion script under test set zshcompletion "$env(OBJDIR)/init/zsh-functions/_module" if {![file exists $zshcompletion]} { unsupported "completion script not found: $zshcompletion (run 'make initdir' first)" } # a fish binary is required to drive interactive completion tests set fishbin [find_bin fish] if {$fishbin eq {}} { unsupported {no fish binary found to drive completion tests} } # built fish completion script under test set fishcompletion "$env(OBJDIR)/init/fish_completion" if {![file exists $fishcompletion]} { unsupported "completion script not found: $fishcompletion (run 'make initdir' first)" } # a tcsh binary is required to drive interactive completion tests set tcshbin [find_bin tcsh] if {$tcshbin eq {}} { unsupported {no tcsh binary found to drive completion tests} } # built tcsh completion script under test set tcshcompletion_src "$env(OBJDIR)/init/tcsh_completion" if {![file exists $tcshcompletion_src]} { unsupported "completion script not found: $tcshcompletion_src (run 'make initdir' first)" } # clean modulefile fixture tree: unlike testsuite/modulefiles, this one holds # no modulefile deliberately broken to exercise error paths, which would get # in the way of straightforward completion listing checks set modpath "$env(TESTSUITEDIR)/modulefiles.3" # sandboxed $HOME for the spawned bash sessions: some completion tests (e.g. # 'module save') write real files there, which must never land under a # developer's actual home directory set completionhome "$env(TESTSUITEDIR)/completion-home" file delete -force $completionhome file mkdir $completionhome # unlike the other shells' completion scripts, init/tcsh_completion.in does # not shell out to the 'module' command itself to fetch candidates: it bakes # an absolute '@TCLSH@ "@libexecdir@/modulecmd.tcl"' invocation into every # alias (_module_avail, _module_loaded, ...) at './configure' time, pointing # at whatever install prefix this tree happened to be configured with -- # unrelated to (and, in a plain dev checkout, nonexistent relative to) the # $TCLSH/$MODULECMD this testsuite actually runs against. Rewrite just that # hardcoded interpreter invocation to route through the test's own # $TCLSH/$MODULECMD instead, leaving the real 'complete module ...'/ # 'complete ml ...' registration under test completely untouched set tcshcompletion "$completionhome/tcsh_completion" set in [open $tcshcompletion_src r] set tcshcompletion_content [read $in] close $in set tcshcompletion_content [regsub -all {[^ \t\n]*tclsh "[^"]*modulecmd\.tcl"}\ $tcshcompletion_content "'$TCLSH' '$MODULECMD'"] set out [open $tcshcompletion w] puts -nonewline $out $tcshcompletion_content close $out # scratch area for modulefiles created on the fly by completion tests set injectdir "$env(TESTSUITEDIR)/completion-inject-fixture" file delete -force $injectdir # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: