mirror of
https://github.com/envmodules/modules.git
synced 2026-06-14 00:42:43 +08:00
ts: fix json whatis error test with random output order
Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
This commit is contained in:
@@ -836,6 +836,31 @@ proc _test_err_re {test_shell cmd answer force_nl failcmd} {
|
||||
}
|
||||
}
|
||||
|
||||
proc _test_err_re_sort {test_shell cmd answer failcmd} {
|
||||
global comp_error
|
||||
global verbose
|
||||
|
||||
# newline is expected at end of answer
|
||||
if {$answer ne {} && $answer ne "\n"} {
|
||||
append answer \n
|
||||
}
|
||||
|
||||
set comp_error_sort [join [lsort [split $comp_error \n]] \n]
|
||||
set answer_sort [join [lsort [split $answer \n]] \n]
|
||||
set answer_sort "^$answer_sort\$"
|
||||
|
||||
if {![regexp -- $answer_sort $comp_error_sort]} {
|
||||
$failcmd "$cmd ($test_shell)"
|
||||
set ol [string length $comp_error_sort]
|
||||
set oe [string length $answer_sort]
|
||||
send_user "ERR\[$ol\]: '$comp_error_sort'#>\n"
|
||||
send_user "EXP\[$oe\]: '$answer_sort'#>\n"
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
proc _test_out {test_shell cmd answer failcmd} {
|
||||
global comp_output
|
||||
global verbose
|
||||
@@ -1118,6 +1143,25 @@ proc testouterr_cmd {test_shell cmd answer anserr {failcmd {fail}}} {
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Test procedure for matching with regular expressions in the stdout and sorted stderr
|
||||
#
|
||||
|
||||
proc testouterr_cmd_re_sort {test_shell cmd answer anserr {failcmd {fail}}} {
|
||||
if {$test_shell eq "ALL"} {
|
||||
global supported_shells
|
||||
foreach shell $supported_shells {
|
||||
testouterr_cmd_re_sort $shell $cmd $answer $anserr
|
||||
}
|
||||
} else {
|
||||
_test_sub $test_shell "$cmd"
|
||||
if { [_test_out_re $test_shell "$cmd" "$answer" $failcmd]
|
||||
&& [_test_err_re_sort $test_shell "$cmd" "$anserr" $failcmd] } {
|
||||
_test_ok $test_shell "$cmd"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Test procedure for full text matching with stdout and specified file
|
||||
#
|
||||
|
||||
@@ -246,12 +246,12 @@ if {$is_file_perms_editable && $tcl_platform(user) ne {root} && !$is_locked_dir_
|
||||
change_file_perms $mp/iCaSe/1 ugo-rx
|
||||
change_file_perms $mp/icASE/1 ugo-rx
|
||||
change_file_perms $mp/icase/1 ugo-rx
|
||||
testouterr_cmd sh {whatis --json -i ICASE/1} ERR "{\"errors\": \[
|
||||
{ \"severity\": \"ERROR\", \"message\": \[ \"Permission denied on '$mp/iCaSe/1'\" \] },
|
||||
{ \"severity\": \"ERROR\", \"message\": \[ \"Permission denied on '$mp/ICASE/1'\" \] },
|
||||
{ \"severity\": \"ERROR\", \"message\": \[ \"Permission denied on '$mp/IcAsE/1'\" \] },
|
||||
{ \"severity\": \"ERROR\", \"message\": \[ \"Permission denied on '$mp/icASE/1'\" \] },
|
||||
{ \"severity\": \"ERROR\", \"message\": \[ \"Permission denied on '$mp/icase/1'\" \] } \]
|
||||
testouterr_cmd_re_sort sh {whatis --json -i ICASE/1} ERR "{\"errors\": \\\[
|
||||
{ \"severity\": \"ERROR\", \"message\": \\\[ \"Permission denied on '$mpre/iCaSe/1'\" \\\] }.*
|
||||
{ \"severity\": \"ERROR\", \"message\": \\\[ \"Permission denied on '$mpre/ICASE/1'\" \\\] }.*
|
||||
{ \"severity\": \"ERROR\", \"message\": \\\[ \"Permission denied on '$mpre/IcAsE/1'\" \\\] }.*
|
||||
{ \"severity\": \"ERROR\", \"message\": \\\[ \"Permission denied on '$mpre/icASE/1'\" \\\] }.*
|
||||
{ \"severity\": \"ERROR\", \"message\": \\\[ \"Permission denied on '$mpre/icase/1'\" \\\] }.*
|
||||
}"
|
||||
testouterr_cmd sh {whatis --json -i -s ICASE/1} ERR "{}"
|
||||
restore_file_perms $mp/IcAsE/1
|
||||
|
||||
Reference in New Issue
Block a user