Skip to content

Commit

Permalink
Hold module not found error message when report is held
Browse files Browse the repository at this point in the history
Update held report mechanism when loading requirement to also hold error
messages occurring outside of sub evaluation. Module not found error
message is now held and dropped if an alternative requirement module is
found and loaded afterward.

Fixes #511.
  • Loading branch information
xdelaruelle committed Sep 12, 2023
1 parent 9ce0392 commit 6e89a61
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
7 changes: 5 additions & 2 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,13 @@ Modules 5.4.0 (not yet released)
* Update requirement load error report to place it only under the message
block of the module requiring this load. This change helps to better
understand the chronology of actions and from where an error occurs.
* Do not report requirement load error when an an alternative requirement
module is found and loaded afterward. (fix issue #509)
* Do not report requirement load error when an alternative requirement module
is found and loaded afterward. (fix issue #509)
* Do not render an error exit code on multi-module option requirement when
one module option fails to load but another does. (fix issue #510)
* Do not report *module not found* error when loading a requirement if an
alternative requirement module is found and loaded afterward. (fix issue
#511)


.. _5.3 release notes:
Expand Down
7 changes: 6 additions & 1 deletion tcl/modeval.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,10 @@ proc loadRequirementModuleList {tryload optional tag_list args} {
for {set i 0} {$i<$imax && $prereqloaded==0} {incr i 1} {
set arg [lindex $args $i]

# hold output of each evaluation until they are all done to drop
# hold output from current evaluation to catch 'module not found'
# message that occurs outside of sub evaluation
lappendState reportholdrecid [currentState msgrecordid]
# hold output of each sub evaluation until they are all done to drop
# those that failed if one succeed or if optional
set curholdid load-$i-$arg
lappendState reportholdid $curholdid
Expand All @@ -665,6 +668,7 @@ proc loadRequirementModuleList {tryload optional tag_list args} {
# if an error is raised, release output and rethrow the error
# (could be raised if no modulepath defined for instance)
lpopState reportholdid
lpopState reportholdrecid
lappend holdidlist $curholdid report
releaseHeldReport {*}$holdidlist
knerror $errorMsg
Expand All @@ -674,6 +678,7 @@ proc loadRequirementModuleList {tryload optional tag_list args} {
set ret $retlo
}
lpopState reportholdid
lpopState reportholdrecid

if {[is-loaded $arg]} {
set prereqloaded 1
Expand Down
11 changes: 9 additions & 2 deletions tcl/report.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,15 @@ proc __reportSeparateNextContent {} {

# save message for block rendering
proc recordMessage {message {recordtop 0}} {
lappend ::g_msgRecord([expr {$recordtop ? [topState msgrecordid] :\
[currentState msgrecordid]}]) $message
set recid [expr {$recordtop ? [topState msgrecordid] : [currentState\
msgrecordid]}]

if {$recid eq [currentState reportholdrecid]} {
lappend ::g_holdReport([currentState reportholdid]) [list\
recordMessage $message $recordtop]
} else {
lappend ::g_msgRecord($recid) $message
}
}

# check if some msg have been recorded for current evaluation
Expand Down

0 comments on commit 6e89a61

Please sign in to comment.