Skip to content

Commit 122039e

Browse files
committed
ts: add install tests to check redirect_output
1 parent 83f8490 commit 122039e

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ set modlin "\[-\]+"
9595
# properties to test the different available shells
9696
set shell_list {}
9797
set shell_sh_family {}
98+
set shell_redir_list {}
9899
array set shell_init {}
99100
array set shell_path {}
100101
array set shell_opts {}
@@ -174,6 +175,11 @@ foreach shell [list sh bash basheu ksh zsh csh tcsh fish tcl perl python ruby cm
174175
set shell_test($shell) "$env(TESTSUITEDIR)/bin/install_test_${shell}"
175176
}
176177
}
178+
switch -- $shell {
179+
sh - bash - ksh - zsh - fish {
180+
lappend shell_redir_list $shell
181+
}
182+
}
177183
} else {
178184
send_user "\t'$shell' shell is not installed, relative tests will be skipped\n"
179185
}

testsuite/install.00-init/070-stderrtty.exp

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,60 @@ file delete $disruptive_dir2
142142

143143

144144
} elseif {$verbose > 0} {
145-
send_user "\tSkip test as STDERR is not attached to a TTY\n"
145+
send_user "\tSkip most tests as STDERR is not attached to a TTY\n"
146146
}
147147

148+
149+
# test output redirection when shell is found or not attached to tty
150+
set tserr "Modules Release \\S+ (\\S+)"
151+
if {$is_stderr_tty} {
152+
set dflout $tserr
153+
set dflerr {}
154+
} else {
155+
set dflout {}
156+
set dflerr $tserr
157+
}
158+
159+
foreach shell $shell_redir_list {
160+
testall_cmd_re $shell {module --version} $dflout $dflerr 0
161+
testall_cmd_re autoinit:$shell {module --version} $dflout $dflerr 0
162+
testall_cmd_re $shell {module --version --redirect} $tserr {} 0
163+
testall_cmd_re autoinit:$shell {module --version --redirect} $tserr {} 0
164+
testall_cmd_re $shell {module --version --no-redirect} {} $tserr 0
165+
testall_cmd_re autoinit:$shell {module --version --no-redirect} {} $tserr 0
166+
# if --no-redirect is part of arg list it wins even if --redirect is set after
167+
testall_cmd_re $shell {module --version --redirect --no-redirect} {} $tserr 0
168+
testall_cmd_re $shell {module --version --no-redirect --redirect} {} $tserr 0
169+
170+
setenv_var MODULES_REDIRECT_OUTPUT 0
171+
testall_cmd_re $shell {module --version} {} $tserr 0
172+
testall_cmd_re $shell {module --version --redirect} $tserr {} 0
173+
testall_cmd_re $shell {module --version --no-redirect} {} $tserr 0
174+
testall_cmd_re $shell {module --version --redirect --no-redirect} {} $tserr 0
175+
testall_cmd_re $shell {module --version --no-redirect --redirect} {} $tserr 0
176+
177+
setenv_var MODULES_REDIRECT_OUTPUT 1
178+
testall_cmd_re $shell {module --version} $tserr {} 0
179+
testall_cmd_re $shell {module --version --redirect} $tserr {} 0
180+
testall_cmd_re $shell {module --version --no-redirect} {} $tserr 0
181+
testall_cmd_re $shell {module --version --redirect --no-redirect} {} $tserr 0
182+
testall_cmd_re $shell {module --version --no-redirect --redirect} {} $tserr 0
183+
184+
# bad value set on MODULES_REDIRECT_OUTPUT env var
185+
# any value different than 0 or 1 is ignored
186+
setenv_var MODULES_REDIRECT_OUTPUT foo
187+
testall_cmd_re $shell {module --version} $dflout $dflerr 0
188+
testall_cmd_re $shell {module --version --redirect} $tserr {} 0
189+
testall_cmd_re $shell {module --version --no-redirect} {} $tserr 0
190+
setenv_var MODULES_REDIRECT_OUTPUT {}
191+
testall_cmd_re $shell {module --version} $dflout $dflerr 0
192+
testall_cmd_re $shell {module --version --redirect} $tserr {} 0
193+
testall_cmd_re $shell {module --version --no-redirect} {} $tserr 0
194+
195+
unsetenv_var MODULES_REDIRECT_OUTPUT
196+
}
197+
198+
148199
#
149200
# Clean up variables used in this test case
150201
#

0 commit comments

Comments
 (0)