Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ Modules 5.7.0 (not yet released)
* Improve the performance of the module’s column output by removing the costly
optimization that attempts to fit more columns within the available screen
width. (fix issue #622)
* Report the full *via* path for modules on :subcmd:`avail` and
:subcmd:`spider` sub-commands rather the last part of this via information.
JSON output is updated to report the ``via`` key as an array rather as a
string. (fix issue #586)


.. _5.6 release notes:
Expand Down
26 changes: 26 additions & 0 deletions tcl/modfind.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,15 @@ proc getLoadedUse {mod} {
}
}

proc getViaListModuleForModulepath {modpath} {
set via_list {}
while {[string length [set via [getViaModuleForModulepath $modpath]]]} {
lappend via_list $via
set modpath [getViaModuleModulepath $via]
}
return [lreverse $via_list]
}

proc getViaModuleForModulepath {modpath} {
lassign [getAllLoadedModuleUsingModulepath $modpath] via
if {![string length $via] && $modpath ni [getModulePathList]} {
Expand All @@ -2029,6 +2038,23 @@ proc getModuleUsingModulepath {modpath} {
}
}

proc setViaModuleModulepath {mod modpath} {
# global array only used during spider, no need to integrate into push/pop
# restore mechanisms
set ::g_viaModuleModulepath($mod) $modpath
}

proc getViaModuleModulepath {mod} {
# get modulepath of via module if loaded
if {[isModuleLoaded $mod]} {
return [getModulepathFromLoadedOrLoadingModule $mod]
}
# otherwise return via modulepath collected during spider processing
if {[info exists ::g_viaModuleModulepath($mod)]} {
return $::g_viaModuleModulepath($mod)
}
}

# Return all loaded module that enables given modulepath. Reference counter
# is checked to detect if modulepath was enabled prior loading the modules in
# which case modulepath is considered not enabled by loaded modules. modpath
Expand Down
19 changes: 10 additions & 9 deletions tcl/report.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -1483,8 +1483,8 @@ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\
himatcharrvrmap himatcharrvrvalmap
set clean_list {}
set vr_list {}
set via [expr {[isEltInReport via] ? [getViaModuleForModulepath $header] :\
{}}]
set via_list [expr {[isEltInReport via] ? [getViaListModuleForModulepath\
$header] : {}}]

# treat elements in specified order if any
##nagelfar ignore #2 Badly formed if statement
Expand All @@ -1510,7 +1510,7 @@ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\
if {$json} {
##nagelfar ignore +2 Found constant
set dispsgr [formatListEltToJsonDisplay $elt type s directory\
1 symbols a $sym_list 1 via s $via 1]
1 symbols a $sym_list 1 via a $via_list 1]
} elseif {$show_mtime} {
# append / char after name to clearly indicate this is a dir
lassign [formatListEltToLongDisplay $elt di / $sym_list sy {}\
Expand All @@ -1527,7 +1527,7 @@ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\
set dispsgr [formatListEltToJsonDisplay $elt type s modulefile\
1 variants o $vr_list $report_variant symbols a $sym_list 1\
tags a $tag_list 1 pathname s [lindex $mod_list($elt) 2] 1\
via s $via 1]
via a $via_list 1]
} elseif {$show_mtime} {
set clock_mtime [expr {[lindex $mod_list($elt) 1] ne {} ?\
[clock format [lindex $mod_list($elt) 1] -format {%Y/%m/%d\
Expand All @@ -1549,7 +1549,7 @@ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\
##nagelfar ignore +3 Found constant
set dispsgr [formatListEltToJsonDisplay $elt type s alias 1\
symbols a $sym_list 1 tags a $tag_list 1 target s [lindex\
$mod_list($elt) 1] 1 via s $via 1]
$mod_list($elt) 1] 1 via a $via_list 1]
} elseif {$show_mtime} {
lassign [formatListEltToLongDisplay $elt al " -> [lindex\
$mod_list($elt) 1]" $sym_list sy {} $default_colored\
Expand Down Expand Up @@ -1618,7 +1618,7 @@ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\

# output formatted elements
displayElementList $header $hsgrkey $hstyle $one_per_line $show_idx 1\
$display_list $len_list $via
$display_list $len_list $via_list
}

proc showModulePath {} {
Expand Down Expand Up @@ -1663,11 +1663,11 @@ proc displaySeparatorLine {{title {}} {sgrkey {}} {extra {}}} {
# get a list of elements and print them in a column or in a
# one-per-line fashion
proc displayElementList {header sgrkey hstyle one_per_line display_idx\
start_idx display_list {len_list {}} {via {}}} {
start_idx display_list {len_list {}} {via_list {}}} {
set elt_cnt [llength $display_list]
reportDebug "header=$header, sgrkey=$sgrkey, hstyle=$hstyle,\
elt_cnt=$elt_cnt, one_per_line=$one_per_line,\
display_idx=$display_idx, start_idx=$start_idx, via=$via"
display_idx=$display_idx, start_idx=$start_idx, via=$via_list"

# end proc if no element are to print
if {$elt_cnt == 0} {
Expand All @@ -1682,7 +1682,8 @@ proc displayElementList {header sgrkey hstyle one_per_line display_idx\
if {$json} {
report "\"$header\": \{"
} elseif {$hstyle eq {sepline}} {
set extra [expr {[string length $via] ? " (via $via)" : {}}]
set extra [expr {[string length $via_list] ? " (via [join $via_list\
{ > }])" : {}}]
displaySeparatorLine $header $sgrkey $extra
} else {
report [sgr $sgrkey $header]:
Expand Down
4 changes: 3 additions & 1 deletion tcl/subcmd.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -3137,7 +3137,9 @@ proc cmdModuleSpider {show_oneperline show_mtime show_filter search_filter\
foreach {new_modpath from_mod_list} [getScanModuleElt $modpath use] {
if {[string length $new_modpath] && $new_modpath ni $modpath_list} {
lappend modpath_list $new_modpath
setLoadedUse [lindex $from_mod_list 0] $new_modpath
set via_mod [lindex $from_mod_list 0]
setLoadedUse $via_mod $new_modpath
setViaModuleModulepath $via_mod $modpath
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions testsuite/example/siteconfig.tcl-1
Original file line number Diff line number Diff line change
Expand Up @@ -707,4 +707,8 @@ if {[info exists env(TESTSUITE_ENABLE_SITECONFIG_COMPUTEOUTPUTGRID)]} {
report [compute_output_grid 80 {} 3]
}

if {[info exists env(TESTSUITE_ENABLE_SITECONFIG_GETVIAMODULEMODULEPATH)]} {
report [string length [getViaModuleModulepath unk]]
}

}
7 changes: 7 additions & 0 deletions testsuite/modules.00-init/120-siteconfig.exp
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,13 @@ lappend ans $vers_reportre
testouterr_cmd_re sh -V OK [join $ans \n]
unsetenv_var TESTSUITE_ENABLE_SITECONFIG_COMPUTEOUTPUTGRID

setenv_var TESTSUITE_ENABLE_SITECONFIG_GETVIAMODULEMODULEPATH 1
set ans [list]
lappend ans 0
lappend ans $vers_reportre
testouterr_cmd_re sh -V OK [join $ans \n]
unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETVIAMODULEMODULEPATH

} elseif {$verbose} {
send_user "\tSkip tests relying on an excepted siteconfig file installed\n"
}
Expand Down
2 changes: 1 addition & 1 deletion testsuite/modules.50-cmds/570-modulepath-label.exp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ label/1.0 \[0-9\/]{10} \[0-9:]
testouterr_cmd_re sh {avail -l label} OK $tserr

set tserr "{\"My label\": {
\"label/1.0\": { \"name\": \"label/1.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$modpath.4/label/1.0\", \"via\": \"\"}
\"label/1.0\": { \"name\": \"label/1.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$modpath.4/label/1.0\", \"via\": \[\]}
}}"
testouterr_cmd sh {avail -j label} OK $tserr

Expand Down
24 changes: 12 additions & 12 deletions testsuite/modules.51-scan/020-avail_output-variant.exp
Original file line number Diff line number Diff line change
Expand Up @@ -377,18 +377,18 @@ testouterr_cmd sh {avail -t --no-indepth variant/} OK $tserr
setenv_var TESTSUITE_VARIANT 13

set tserr "{\"$mp\": {
\"variant/1.0\": { \"name\": \"variant/1.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/1.0\", \"via\": \"\"},
\"variant/2.0\": { \"name\": \"variant/2.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/2.0\", \"via\": \"\"},
\"variant/2.1/2/1\": { \"name\": \"variant/2.1/2/1\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/2.1/2/1\", \"via\": \"\"},
\"variant/3.0\": { \"name\": \"variant/3.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/3.0\", \"via\": \"\"},
\"variant/4.0\": { \"name\": \"variant/4.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/4.0\", \"via\": \"\"},
\"variant/5.0\": { \"name\": \"variant/5.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/5.0\", \"via\": \"\"},
\"variant/5.1\": { \"name\": \"variant/5.1\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/5.1\", \"via\": \"\"},
\"variant/6.0\": { \"name\": \"variant/6.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/6.0\", \"via\": \"\"},
\"variant/7.0\": { \"name\": \"variant/7.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/7.0\", \"via\": \"\"},
\"variant/7.1\": { \"name\": \"variant/7.1\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/7.1\", \"via\": \"\"},
\"variant/8.0\": { \"name\": \"variant/8.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/8.0\", \"via\": \"\"},
\"variant/w s\": { \"name\": \"variant/w s\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/w s\", \"via\": \"\"}
\"variant/1.0\": { \"name\": \"variant/1.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/1.0\", \"via\": \[\]},
\"variant/2.0\": { \"name\": \"variant/2.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/2.0\", \"via\": \[\]},
\"variant/2.1/2/1\": { \"name\": \"variant/2.1/2/1\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/2.1/2/1\", \"via\": \[\]},
\"variant/3.0\": { \"name\": \"variant/3.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/3.0\", \"via\": \[\]},
\"variant/4.0\": { \"name\": \"variant/4.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/4.0\", \"via\": \[\]},
\"variant/5.0\": { \"name\": \"variant/5.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/5.0\", \"via\": \[\]},
\"variant/5.1\": { \"name\": \"variant/5.1\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/5.1\", \"via\": \[\]},
\"variant/6.0\": { \"name\": \"variant/6.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/6.0\", \"via\": \[\]},
\"variant/7.0\": { \"name\": \"variant/7.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/7.0\", \"via\": \[\]},
\"variant/7.1\": { \"name\": \"variant/7.1\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/7.1\", \"via\": \[\]},
\"variant/8.0\": { \"name\": \"variant/8.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/8.0\", \"via\": \[\]},
\"variant/w s\": { \"name\": \"variant/w s\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/w s\", \"via\": \[\]}
}}"
testouterr_cmd sh {avail -j variant} OK $tserr

Expand Down
Loading