Debian Codegraph @

testsuite/completion.00-init/005-init_ts.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: completion.00-init/%M%
6 # Revision: %I%
7 # First Edition: 2026/08/07
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command:
14 # Sub-Command:
15 #
16 # Comment: %C{
17 # Defines all patterns used further in the testsuite
18 # }C%
19 #
20 ##############################################################################
21
22 proc find_bin {name} {
23 set path {}
24
25 if {[info exists ::env(PATH)]} {
26 foreach dir [split $::env(PATH) ":"] {
27 if {[file executable "$dir/$name"]} {
28 set path "$dir/$name"
29 break
30 }
31 }
32 }
33
34 return $path
35 }
36
37 if {$verbose} {
38 send_user "\tInitializing the testsuite ...\n"
39 }
40
41 set TCLSH $env(TCLSH)
42 set MODULECMD $env(MODULECMD)
43
44 # a bash binary is required to drive interactive completion tests
45 set bashbin [find_bin bash]
46 if {$bashbin eq {}} {
47 unsupported {no bash binary found to drive completion tests}
48 }
49
50 # built bash completion script under test
51 set bashcompletion "$env(OBJDIR)/init/bash_completion"
52 if {![file exists $bashcompletion]} {
53 unsupported "completion script not found: $bashcompletion (run 'make initdir' first)"
54 }
55
56 # a zsh binary is required to drive interactive completion tests
57 set zshbin [find_bin zsh]
58 if {$zshbin eq {}} {
59 unsupported {no zsh binary found to drive completion tests}
60 }
61
62 # built zsh completion script under test
63 set zshcompletion "$env(OBJDIR)/init/zsh-functions/_module"
64 if {![file exists $zshcompletion]} {
65 unsupported "completion script not found: $zshcompletion (run 'make initdir' first)"
66 }
67
68 # a fish binary is required to drive interactive completion tests
69 set fishbin [find_bin fish]
70 if {$fishbin eq {}} {
71 unsupported {no fish binary found to drive completion tests}
72 }
73
74 # built fish completion script under test
75 set fishcompletion "$env(OBJDIR)/init/fish_completion"
76 if {![file exists $fishcompletion]} {
77 unsupported "completion script not found: $fishcompletion (run 'make initdir' first)"
78 }
79
80 # a tcsh binary is required to drive interactive completion tests
81 set tcshbin [find_bin tcsh]
82 if {$tcshbin eq {}} {
83 unsupported {no tcsh binary found to drive completion tests}
84 }
85
86 # built tcsh completion script under test
87 set tcshcompletion_src "$env(OBJDIR)/init/tcsh_completion"
88 if {![file exists $tcshcompletion_src]} {
89 unsupported "completion script not found: $tcshcompletion_src (run 'make initdir' first)"
90 }
91
92 # clean modulefile fixture tree: unlike testsuite/modulefiles, this one holds
93 # no modulefile deliberately broken to exercise error paths, which would get
94 # in the way of straightforward completion listing checks
95 set modpath "$env(TESTSUITEDIR)/modulefiles.3"
96
97 # sandboxed $HOME for the spawned bash sessions: some completion tests (e.g.
98 # 'module save') write real files there, which must never land under a
99 # developer's actual home directory
100 set completionhome "$env(TESTSUITEDIR)/completion-home"
101 file delete -force $completionhome
102 file mkdir $completionhome
103
104 # unlike the other shells' completion scripts, init/tcsh_completion.in does
105 # not shell out to the 'module' command itself to fetch candidates: it bakes
106 # an absolute '@TCLSH@ "@libexecdir@/modulecmd.tcl"' invocation into every
107 # alias (_module_avail, _module_loaded, ...) at './configure' time, pointing
108 # at whatever install prefix this tree happened to be configured with --
109 # unrelated to (and, in a plain dev checkout, nonexistent relative to) the
110 # $TCLSH/$MODULECMD this testsuite actually runs against. Rewrite just that
111 # hardcoded interpreter invocation to route through the test's own
112 # $TCLSH/$MODULECMD instead, leaving the real 'complete module ...'/
113 # 'complete ml ...' registration under test completely untouched
114 set tcshcompletion "$completionhome/tcsh_completion"
115 set in [open $tcshcompletion_src r]
116 set tcshcompletion_content [read $in]
117 close $in
118 set tcshcompletion_content [regsub -all {[^ \t\n]*tclsh "[^"]*modulecmd\.tcl"}\
119 $tcshcompletion_content "'$TCLSH' '$MODULECMD'"]
120 set out [open $tcshcompletion w]
121 puts -nonewline $out $tcshcompletion_content
122 close $out
123
124 # scratch area for modulefiles created on the fly by completion tests
125 set injectdir "$env(TESTSUITEDIR)/completion-inject-fixture"
126 file delete -force $injectdir
127
128 # vim:set tabstop=3 shiftwidth=3 expandtab autoindent: