Skip to content

Commit ef3ddee

Browse files
committed
Report full via path
Report the full "via" path for modules on avail and spider sub-commands rather the last part of this via information. On JSON output, the "via" key is changed to be reported as an array rather as a string. Closes #586 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
1 parent 82d624f commit ef3ddee

20 files changed

Lines changed: 3037 additions & 2988 deletions

NEWS.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ Modules 5.7.0 (not yet released)
8080
:mfcmd:`depends-on`, mfcmd:`always-load` and :mfcmd:`prereq-all` modulefile
8181
commands. It especially fixes module specification containing the definition
8282
of variants. (fixes issue #626)
83+
* Report the full *via* path for modules on :subcmd:`avail` and
84+
:subcmd:`spider` sub-commands rather the last part of this via information.
85+
JSON output is updated to report the ``via`` key as an array rather as a
86+
string. (fix issue #586)
8387

8488

8589
.. _5.6 release notes:

tcl/modfind.tcl.in

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,20 @@ proc getLoadedUse {mod} {
20092009
}
20102010
}
20112011

2012+
proc getViaListModuleForModulepath {modpath} {
2013+
set via_list {}
2014+
while {[string length [set via [getViaModuleForModulepath $modpath]]]} {
2015+
lappend via_list $via
2016+
set new_modpath [getViaModuleModulepath $via]
2017+
# stop if via is enabling its own modulepath
2018+
if {$modpath eq $new_modpath} {
2019+
break
2020+
}
2021+
set modpath $new_modpath
2022+
}
2023+
return [lreverse $via_list]
2024+
}
2025+
20122026
proc getViaModuleForModulepath {modpath} {
20132027
lassign [getAllLoadedModuleUsingModulepath $modpath] via
20142028
if {![string length $via] && $modpath ni [getModulePathList]} {
@@ -2029,6 +2043,23 @@ proc getModuleUsingModulepath {modpath} {
20292043
}
20302044
}
20312045

2046+
proc setViaModuleModulepath {mod modpath} {
2047+
# global array only used during spider, no need to integrate into push/pop
2048+
# restore mechanisms
2049+
set ::g_viaModuleModulepath($mod) $modpath
2050+
}
2051+
2052+
proc getViaModuleModulepath {mod} {
2053+
# get modulepath of via module if loaded
2054+
if {[isModuleLoaded $mod]} {
2055+
return [getModulepathFromLoadedOrLoadingModule $mod]
2056+
}
2057+
# otherwise return via modulepath collected during spider processing
2058+
if {[info exists ::g_viaModuleModulepath($mod)]} {
2059+
return $::g_viaModuleModulepath($mod)
2060+
}
2061+
}
2062+
20322063
# Return all loaded module that enables given modulepath. Reference counter
20332064
# is checked to detect if modulepath was enabled prior loading the modules in
20342065
# which case modulepath is considered not enabled by loaded modules. modpath

tcl/report.tcl.in

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,8 +1483,8 @@ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\
14831483
himatcharrvrmap himatcharrvrvalmap
14841484
set clean_list {}
14851485
set vr_list {}
1486-
set via [expr {[isEltInReport via] ? [getViaModuleForModulepath $header] :\
1487-
{}}]
1486+
set via_list [expr {[isEltInReport via] ? [getViaListModuleForModulepath\
1487+
$header] : {}}]
14881488
14891489
# treat elements in specified order if any
14901490
##nagelfar ignore #2 Badly formed if statement
@@ -1510,7 +1510,7 @@ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\
15101510
if {$json} {
15111511
##nagelfar ignore +2 Found constant
15121512
set dispsgr [formatListEltToJsonDisplay $elt type s directory\
1513-
1 symbols a $sym_list 1 via s $via 1]
1513+
1 symbols a $sym_list 1 via a $via_list 1]
15141514
} elseif {$show_mtime} {
15151515
# append / char after name to clearly indicate this is a dir
15161516
lassign [formatListEltToLongDisplay $elt di / $sym_list sy {}\
@@ -1527,7 +1527,7 @@ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\
15271527
set dispsgr [formatListEltToJsonDisplay $elt type s modulefile\
15281528
1 variants o $vr_list $report_variant symbols a $sym_list 1\
15291529
tags a $tag_list 1 pathname s [lindex $mod_list($elt) 2] 1\
1530-
via s $via 1]
1530+
via a $via_list 1]
15311531
} elseif {$show_mtime} {
15321532
set clock_mtime [expr {[lindex $mod_list($elt) 1] ne {} ?\
15331533
[clock format [lindex $mod_list($elt) 1] -format {%Y/%m/%d\
@@ -1549,7 +1549,7 @@ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\
15491549
##nagelfar ignore +3 Found constant
15501550
set dispsgr [formatListEltToJsonDisplay $elt type s alias 1\
15511551
symbols a $sym_list 1 tags a $tag_list 1 target s [lindex\
1552-
$mod_list($elt) 1] 1 via s $via 1]
1552+
$mod_list($elt) 1] 1 via a $via_list 1]
15531553
} elseif {$show_mtime} {
15541554
lassign [formatListEltToLongDisplay $elt al " -> [lindex\
15551555
$mod_list($elt) 1]" $sym_list sy {} $default_colored\
@@ -1618,7 +1618,7 @@ proc reportModules {search_queries header hsgrkey hstyle show_mtime show_idx\
16181618
16191619
# output formatted elements
16201620
displayElementList $header $hsgrkey $hstyle $one_per_line $show_idx 1\
1621-
$display_list $len_list $via
1621+
$display_list $len_list $via_list
16221622
}
16231623
16241624
proc showModulePath {} {
@@ -1663,11 +1663,11 @@ proc displaySeparatorLine {{title {}} {sgrkey {}} {extra {}}} {
16631663
# get a list of elements and print them in a column or in a
16641664
# one-per-line fashion
16651665
proc displayElementList {header sgrkey hstyle one_per_line display_idx\
1666-
start_idx display_list {len_list {}} {via {}}} {
1666+
start_idx display_list {len_list {}} {via_list {}}} {
16671667
set elt_cnt [llength $display_list]
16681668
reportDebug "header=$header, sgrkey=$sgrkey, hstyle=$hstyle,\
16691669
elt_cnt=$elt_cnt, one_per_line=$one_per_line,\
1670-
display_idx=$display_idx, start_idx=$start_idx, via=$via"
1670+
display_idx=$display_idx, start_idx=$start_idx, via=$via_list"
16711671
16721672
# end proc if no element are to print
16731673
if {$elt_cnt == 0} {
@@ -1682,7 +1682,8 @@ proc displayElementList {header sgrkey hstyle one_per_line display_idx\
16821682
if {$json} {
16831683
report "\"$header\": \{"
16841684
} elseif {$hstyle eq {sepline}} {
1685-
set extra [expr {[string length $via] ? " (via $via)" : {}}]
1685+
set extra [expr {[string length $via_list] ? " (via [join $via_list\
1686+
{ > }])" : {}}]
16861687
displaySeparatorLine $header $sgrkey $extra
16871688
} else {
16881689
report [sgr $sgrkey $header]:

tcl/subcmd.tcl.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3137,7 +3137,9 @@ proc cmdModuleSpider {show_oneperline show_mtime show_filter search_filter\
31373137
foreach {new_modpath from_mod_list} [getScanModuleElt $modpath use] {
31383138
if {[string length $new_modpath] && $new_modpath ni $modpath_list} {
31393139
lappend modpath_list $new_modpath
3140-
setLoadedUse [lindex $from_mod_list 0] $new_modpath
3140+
set via_mod [lindex $from_mod_list 0]
3141+
setLoadedUse $via_mod $new_modpath
3142+
setViaModuleModulepath $via_mod $modpath
31413143
}
31423144
}
31433145
}

testsuite/example/siteconfig.tcl-1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,4 +707,8 @@ if {[info exists env(TESTSUITE_ENABLE_SITECONFIG_COMPUTEOUTPUTGRID)]} {
707707
report [compute_output_grid 80 {} 3]
708708
}
709709

710+
if {[info exists env(TESTSUITE_ENABLE_SITECONFIG_GETVIAMODULEMODULEPATH)]} {
711+
report [string length [getViaModuleModulepath unk]]
712+
}
713+
710714
}

testsuite/modules.00-init/120-siteconfig.exp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ lappend ans { invoked from within}
715715
lappend ans { "displaySeparatorLine $header $sgrkey $extra"}
716716
lappend ans { (procedure "displayElementList" line 19)}
717717
lappend ans { invoked from within}
718-
lappend ans { "displayElementList $header $hsgrkey $hstyle $one_per_line $show_idx 1 $display_list $len_list $via"}
718+
lappend ans { "displayElementList $header $hsgrkey $hstyle $one_per_line $show_idx 1 $display_list $len_list $via_list"}
719719
lappend ans { (procedure "reportModules" line 151)}
720720
lappend ans { invoked from within}
721721
lappend ans { "reportModules $args $dir mp $hstyle $show_mtime 0 $one_per_line $theader_cols hidden-loaded"}
@@ -822,6 +822,13 @@ lappend ans $vers_reportre
822822
testouterr_cmd_re sh -V OK [join $ans \n]
823823
unsetenv_var TESTSUITE_ENABLE_SITECONFIG_COMPUTEOUTPUTGRID
824824

825+
setenv_var TESTSUITE_ENABLE_SITECONFIG_GETVIAMODULEMODULEPATH 1
826+
set ans [list]
827+
lappend ans 0
828+
lappend ans $vers_reportre
829+
testouterr_cmd_re sh -V OK [join $ans \n]
830+
unsetenv_var TESTSUITE_ENABLE_SITECONFIG_GETVIAMODULEMODULEPATH
831+
825832
} elseif {$verbose} {
826833
send_user "\tSkip tests relying on an excepted siteconfig file installed\n"
827834
}

testsuite/modules.50-cmds/570-modulepath-label.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ label/1.0 \[0-9\/]{10} \[0-9:]
5555
testouterr_cmd_re sh {avail -l label} OK $tserr
5656

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

testsuite/modules.51-scan/020-avail_output-variant.exp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -377,18 +377,18 @@ testouterr_cmd sh {avail -t --no-indepth variant/} OK $tserr
377377
setenv_var TESTSUITE_VARIANT 13
378378

379379
set tserr "{\"$mp\": {
380-
\"variant/1.0\": { \"name\": \"variant/1.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/1.0\", \"via\": \"\"},
381-
\"variant/2.0\": { \"name\": \"variant/2.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/2.0\", \"via\": \"\"},
382-
\"variant/2.1/2/1\": { \"name\": \"variant/2.1/2/1\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/2.1/2/1\", \"via\": \"\"},
383-
\"variant/3.0\": { \"name\": \"variant/3.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/3.0\", \"via\": \"\"},
384-
\"variant/4.0\": { \"name\": \"variant/4.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/4.0\", \"via\": \"\"},
385-
\"variant/5.0\": { \"name\": \"variant/5.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/5.0\", \"via\": \"\"},
386-
\"variant/5.1\": { \"name\": \"variant/5.1\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/5.1\", \"via\": \"\"},
387-
\"variant/6.0\": { \"name\": \"variant/6.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/6.0\", \"via\": \"\"},
388-
\"variant/7.0\": { \"name\": \"variant/7.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/7.0\", \"via\": \"\"},
389-
\"variant/7.1\": { \"name\": \"variant/7.1\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/7.1\", \"via\": \"\"},
390-
\"variant/8.0\": { \"name\": \"variant/8.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/8.0\", \"via\": \"\"},
391-
\"variant/w s\": { \"name\": \"variant/w s\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/w s\", \"via\": \"\"}
380+
\"variant/1.0\": { \"name\": \"variant/1.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/1.0\", \"via\": \[\]},
381+
\"variant/2.0\": { \"name\": \"variant/2.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/2.0\", \"via\": \[\]},
382+
\"variant/2.1/2/1\": { \"name\": \"variant/2.1/2/1\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/2.1/2/1\", \"via\": \[\]},
383+
\"variant/3.0\": { \"name\": \"variant/3.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/3.0\", \"via\": \[\]},
384+
\"variant/4.0\": { \"name\": \"variant/4.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/4.0\", \"via\": \[\]},
385+
\"variant/5.0\": { \"name\": \"variant/5.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/5.0\", \"via\": \[\]},
386+
\"variant/5.1\": { \"name\": \"variant/5.1\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/5.1\", \"via\": \[\]},
387+
\"variant/6.0\": { \"name\": \"variant/6.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/6.0\", \"via\": \[\]},
388+
\"variant/7.0\": { \"name\": \"variant/7.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/7.0\", \"via\": \[\]},
389+
\"variant/7.1\": { \"name\": \"variant/7.1\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/7.1\", \"via\": \[\]},
390+
\"variant/8.0\": { \"name\": \"variant/8.0\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/8.0\", \"via\": \[\]},
391+
\"variant/w s\": { \"name\": \"variant/w s\", \"type\": \"modulefile\", \"symbols\": \[\], \"tags\": \[\], \"pathname\": \"$mp/variant/w s\", \"via\": \[\]}
392392
}}"
393393
testouterr_cmd sh {avail -j variant} OK $tserr
394394

0 commit comments

Comments
 (0)