From a877b418a00dcc3c5b4d7584e0d85949c843c4ed Mon Sep 17 00:00:00 2001 From: Jacob Bachmeyer Date: Tue, 7 Nov 2023 21:08:04 -0600 Subject: Fix tests that attempt to determine if target_alias has been set The problem with using [info exists target_alias] is that target_alias is unconditionally initialized to the empty string and therefore always exists. --- ChangeLog | 8 ++++++++ runtest.exp | 10 ++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8a012ce..dbf90c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2023-11-07 Jacob Bachmeyer + + PR66984 + + * runtest.exp: Change tests for [info exists target_alias] to + instead test for the empty string, to which target_alias is + unconditionally initialized at early startup. + 2023-04-20 Jacob Bachmeyer PR62982 diff --git a/runtest.exp b/runtest.exp index 84c7e28..078259a 100644 --- a/runtest.exp +++ b/runtest.exp @@ -233,7 +233,7 @@ proc transform { name } { if {[target_info exists target_install]} { set target_install [target_info target_install] } - if {[info exists target_alias]} { + if {$target_alias ne ""} { set tmp $target_alias-$name } elseif {[info exists target_install]} { if { [lsearch -exact $target_install $target_alias] >= 0 } { @@ -242,6 +242,12 @@ proc transform { name } { set tmp "[lindex $target_install 0]-$name" } } + # There appears to be a possibility for tmp to be unset at this + # point, which will cause a Tcl error, but this can only occur if + # the init files invoke transform prior to defining target_alias, + # since the target_alias will be defaulted to the value of + # target_triplet before tests are run. If target_triplet is also + # empty, this point will not be reached; see test above. verbose "Transforming $name to $tmp" return $tmp } @@ -890,7 +896,7 @@ unset arg_target_triplet # # Default target_alias to target_triplet. # -if {![info exists target_alias]} { +if {$target_alias eq ""} { set target_alias $target_triplet } -- cgit v1.1