Debian Codegraph @

testsuite/modules.70-maint/380-edit.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.70-maint/%M%
6 # Revision: %I%
7 # First Edition: 2021/04/24
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command:
14 # Modulefiles: foo, mfvar
15 # Sub-Command: avail
16 #
17 # Comment: %C{
18 # Test edit sub-command
19 # }C%
20 #
21 ##############################################################################
22
23 set mp $modpath.3
24 set mpre [regsub -all "\(\[.+?\]\)" $mp {\\\1}]
25
26 # setup specific environment
27 setenv_path_var MODULEPATH $mp
28
29 setenv_var MODULES_IMPLICIT_DEFAULT 1
30
31
32 # test default editor configuration
33 set dfleditorpath $env(TESTSUITEDIR)/$install_editor
34 if {$install_editor ne {} && ![file exists $dfleditorpath]} {
35 send_user "\tcreating fake default editor $dfleditorpath\n"
36 set fid [open $dfleditorpath w]
37 puts $fid "#!/bin/sh\necho \$0 \$1"
38 close $fid
39 file attributes $dfleditorpath -permissions 0755
40 setenv_var PATH $env(TESTSUITEDIR):$ORIG_PATH
41
42 # regular module
43 testouterr_cmd sh {edit bar/1.0} OK "$dfleditorpath $mp/bar/1.0"
44
45 # implicit default
46 testouterr_cmd sh {edit foo} OK "$dfleditorpath $mp/foo/2.0"
47
48 # explicit default
49 testouterr_cmd sh {edit key} OK "$dfleditorpath $mp/key/1.0"
50
51 # virtual module
52 testouterr_cmd sh {edit mfvar/Modules} OK "$dfleditorpath $mp/mfvar/2.0"
53
54 # alias
55 testouterr_cmd sh {edit key/3.0} OK "$dfleditorpath $mp/key/2.0"
56
57 # symbolic version
58 testouterr_cmd sh {edit key/foosym} OK "$dfleditorpath $mp/key/2.0"
59
60 # fullpath modulefile
61 testouterr_cmd sh "edit $mp/key/2.0" OK "$dfleditorpath $mp/key/2.0"
62
63 # advanced version spec
64 setenv_var MODULES_ADVANCED_VERSION_SPEC 1
65 testouterr_cmd sh {edit foo@:1.6} OK "$dfleditorpath $mp/foo/1.0"
66 unsetenv_var MODULES_ADVANCED_VERSION_SPEC
67
68 file delete $dfleditorpath
69 setenv_var PATH $ORIG_PATH
70 } else {
71 send_user "\tskipping default editor tests\n"
72 }
73
74 skip_if_quick_mode
75
76 # inexistent module
77 testouterr_cmd sh {edit unknown/3.0} ERR $err_path'unknown/3.0'
78
79 # forbidden module
80 testouterr_cmd sh {edit tag/1.0} ERR [err_accessdenied tag/1.0]
81
82
83 # use specific command
84 setenv_var MODULES_EDITOR echo
85 testouterr_cmd sh {edit foo} OK "$mp/foo/2.0"
86
87 # unknown command
88 setenv_var MODULES_EDITOR unkcmd
89 testouterr_cmd sh {edit foo} ERR "$error_msgs: Command 'unkcmd' cannot be found"
90
91 # empty command
92 setenv_var MODULES_EDITOR {}
93 testouterr_cmd sh {edit foo} ERR "$error_msgs: Command '' cannot be found"
94
95 # broken command
96 setenv_var MODULES_EDITOR $env(TESTSUITEDIR)/systest
97 testouterr_cmd sh {edit foo} ERR "$error_msgs: child process exited abnormally"
98
99 # test precedence between MODULES_EDITOR/VISUAL/EDITOR
100 setenv_var MODULES_EDITOR echo
101 setenv_var VISUAL true
102 setenv_var EDITOR true
103 testouterr_cmd sh {edit foo} OK "$mp/foo/2.0"
104
105 unsetenv_var MODULES_EDITOR
106 setenv_var VISUAL echo
107 setenv_var EDITOR true
108 testouterr_cmd sh {edit foo} OK "$mp/foo/2.0"
109
110 unsetenv_var MODULES_EDITOR
111 unsetenv_var VISUAL
112 setenv_var EDITOR echo
113 testouterr_cmd sh {edit foo} OK "$mp/foo/2.0"
114
115
116 #
117 # Cleanup
118 #
119
120 reset_test_env