Skip to content

Commit

Permalink
Highlight several variant values when set on single criterion
Browse files Browse the repository at this point in the history
When one variant criterion contains with multiple values in the search
query, correctly highlight each of these variant values on matching
modules.
  • Loading branch information
xdelaruelle committed Jun 28, 2023
1 parent e400ee2 commit 0cafe49
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tcl/report.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ proc prepareMapToHightlightVariant {args} {
if {[sgr hi {}] ne {}} {
foreach modspec $args {
foreach vrspec [getVariantListFromVersSpec $modspec] {
lassign $vrspec vrname vrisbool vrvalue
set vrvalues [lassign $vrspec vrname vrisbool]
if {![info exists vrname_map($vrname)]} {
set maplist [list $vrname [sgr hi $vrname]]
# also highlight shortcut if any
Expand All @@ -1252,12 +1252,14 @@ proc prepareMapToHightlightVariant {args} {
}
# adapt variant value to highlight if boolean
set maplist {}
if {$vrisbool} {
set vrshort [expr {$vrvalue ? {+} : {-}}]$vrname
lappend maplist $vrshort [sgr hi $vrshort]
set vrvalue [expr {$vrvalue ? {on} : {off}}]
foreach vrvalue $vrvalues {
if {$vrisbool} {
set vrshort [expr {$vrvalue ? {+} : {-}}]$vrname
lappend maplist $vrshort [sgr hi $vrshort]
set vrvalue [expr {$vrvalue ? {on} : {off}}]
}
lappend maplist $vrvalue [sgr hi $vrvalue]
}
lappend maplist $vrvalue [sgr hi $vrvalue]
lappend vrval_map($vrname) {*}$maplist
}
}
Expand Down
7 changes: 7 additions & 0 deletions testsuite/modules.70-maint/370-variant.exp
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val1 baz=2} OK {}
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val1} OK $tserr
set tserr "$mpre:\n[sgr 1]variant/6[sgr 22].0{[sgr 1]bar[sgr 22]=1,[sgr 1]2[sgr 22],3:[sgr 1]foo[sgr 22]=[sgr 1]val1[sgr 22],val2,[sgr 1]val3[sgr 22]}"
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val1 bar=2 foo=val3} OK $tserr
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val1,val3 bar=2} OK $tserr
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val1,val3 bar=2 foo=val3,val1,val1} OK $tserr
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val1,val1 bar=2 foo=val3} OK $tserr
set tserr "$mpre:\n[sgr 1]variant/6[sgr 22].0{[sgr 1]bar[sgr 22]=[sgr 1]1[sgr 22],[sgr 1]2[sgr 22],3:[sgr 1]foo[sgr 22]=[sgr 1]val1[sgr 22],[sgr 1]val2[sgr 22],val3}"
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val1 bar=2 foo=val2 bar=1} OK $tserr
set tserr "$mpre:\n[sgr 1]variant/6[sgr 22].0{bar=1,2,3:[sgr 1]foo[sgr 22]=[sgr 1]val1[sgr 22],[sgr 1]val2[sgr 22],[sgr 1]val3[sgr 22]}
Expand All @@ -501,9 +504,13 @@ set tserr "$mpre:\n[sgr 1]variant/6[sgr 22].0{[sgr 1]bar[sgr 22]=on,[sgr 1]off[s
testouterr_cmd_re sh {avail --color=always -t variant@6:8 +foo foo=off -bar} OK $tserr
set tserr "$mpre:\n[sgr 1]variant/6[sgr 22].0{bar=on,off:[sgr 1]foo[sgr 22]=[sgr 1]on[sgr 22],[sgr 1]off[sgr 22]}"
testouterr_cmd_re sh {avail --color=always -t variant@6:8 +foo foo=off foo=on} OK $tserr
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=on,off} OK $tserr
testouterr_cmd_re sh {avail --color=always -t variant@6:8 -foo +foo} OK $tserr
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=t foo=f} OK $tserr
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=false foo=true} OK $tserr
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=false,true} OK $tserr
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=val1,off,val2,on} OK {}
testouterr_cmd_re sh {avail --color=always -t variant@6:8 foo=on,off,val2,val1} OK {}
unsetenv_var TESTSUITE_VARIANT

setenv_var MODULES_AVAIL_OUTPUT {modulepath:alias:dirwsym:sym:tag:variantifspec:key}
Expand Down

0 comments on commit 0cafe49

Please sign in to comment.