| 1 |
############################################################################## |
| 2 |
# Modules Revision 3.0 |
| 3 |
# Providing a flexible user environment |
| 4 |
# |
| 5 |
# File: install.00-init/%M% |
| 6 |
# Revision: %I% |
| 7 |
# First Edition: 2017/05/06 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Test procedures |
| 13 |
# Command: |
| 14 |
# Sub-Command: |
| 15 |
# |
| 16 |
# Comment: %C{ |
| 17 |
# Defines the testprocedures for probing the outputs |
| 18 |
# on stdout and stderr of the test target |
| 19 |
# }C% |
| 20 |
# |
| 21 |
############################################################################## |
| 22 |
|
| 23 |
|
| 24 |
# |
| 25 |
# Test subprocedures |
| 26 |
# |
| 27 |
|
| 28 |
proc _test_sub {test_shell cmd} { |
| 29 |
global comp_output |
| 30 |
global comp_error |
| 31 |
global comp_exit |
| 32 |
global shell |
| 33 |
global autoinit_mode |
| 34 |
global verbose |
| 35 |
|
| 36 |
set comp_output "" |
| 37 |
set comp_error "" |
| 38 |
set comp_exit "" |
| 39 |
|
| 40 |
if { ![info exists test_shell] || ![info exists cmd] } { |
| 41 |
unresolved "$cmd ($test_shell) internal error" |
| 42 |
} |
| 43 |
|
| 44 |
# enable autoinit initialization when asked |
| 45 |
set shell_args [split $test_shell ":"] |
| 46 |
if { [llength $shell_args] == 2 && [lindex $shell_args 0] eq "autoinit" } { |
| 47 |
set autoinit_mode 1 |
| 48 |
set test_shell [lindex $shell_args 1] |
| 49 |
} else { |
| 50 |
set autoinit_mode 0 |
| 51 |
} |
| 52 |
|
| 53 |
set shell $test_shell |
| 54 |
install_test_xxx_ "$cmd" |
| 55 |
|
| 56 |
# if environment is found undefined, initrc is evaluated so the default |
| 57 |
# module to load will appear on every test output |
| 58 |
if {![info exists ::no_loadedmodules_inject] && $::install_loadedmodules\ |
| 59 |
ne {} && (![info exists ::env(LOADEDMODULES)] && ![info exists\ |
| 60 |
::env(MODULEPATH)])} { |
| 61 |
foreach lm [split $::install_loadedmodules :] { |
| 62 |
lappend anserrpre "Loading $lm" |
| 63 |
} |
| 64 |
upvar anserr anserr |
| 65 |
if {$anserr ne {.*}} { |
| 66 |
if {[string length $anserr]} { |
| 67 |
set startmatch [expr {[string index $anserr 0] eq {^}}] |
| 68 |
set anserr \n[string range $anserr $startmatch end] |
| 69 |
} else { |
| 70 |
set startmatch 0 |
| 71 |
} |
| 72 |
set anserr [expr {$startmatch ? {^} : {}}][join $anserrpre \n]$anserr |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
if { $verbose > 1 } { |
| 77 |
set ol [string length $comp_output] |
| 78 |
set oe [string length $comp_error] |
| 79 |
send_user "OUT\[$ol\]: '$comp_output'#>\n" |
| 80 |
send_user "ERR\[$oe\]: '$comp_error'#>\n" |
| 81 |
send_user "EXIT: '$comp_exit'#>\n" |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
# vim:set tabstop=3 shiftwidth=3 expandtab autoindent: |