aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Bachmeyer <jcb62281+dev@gmail.com>2020-06-02 22:20:01 -0500
committerJacob Bachmeyer <jcb62281+dev@gmail.com>2020-06-02 22:20:01 -0500
commit5fafcd43b2d22b2227e62f7278584418c6449824 (patch)
tree7d188a61b884db7b8338c8ba78fe6112e9f59246
parent55765f0cea891c7282e3fc7a7a4bb70a4cbe9349 (diff)
downloaddejagnu-5fafcd43b2d22b2227e62f7278584418c6449824.zip
dejagnu-5fafcd43b2d22b2227e62f7278584418c6449824.tar.gz
dejagnu-5fafcd43b2d22b2227e62f7278584418c6449824.tar.bz2
Save and restore variables set by command arguments
This commit closes the window during which srcdir was controlled by the testsuite local init file even if specified on the command line. Allowing this override causes problems with Automake when the source directory was set using a relative file name.
-rw-r--r--ChangeLog14
-rw-r--r--NEWS8
-rw-r--r--runtest.exp54
3 files changed, 70 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 5a7eb11..69a80ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
+2020-06-02 Jacob Bachmeyer <jcb62281+dev@gmail.com>
+
+ PR 41647
+ * NEWS: Fix typo. Fix Emacs mode tag.
+ Document use of Tcl namespace ::dejagnu for internals.
+ * runtest.exp (dejagnu::command_line): New namespace.
+ (dejagnu::command_line::save_cmd_var): New procedure.
+ (dejagnu::command_line::restore_cmd_vars): New procedure.
+ (dejagnu::command_line::dump_cmd_vars): New procedure.
+ * runtest.exp: Save internal variables set by command line
+ arguments during the first pass and restore their values after
+ loading testsuite init files.
+
2020-06-01 Jacob Bachmeyer <jcb62281+dev@gmail.com>
+ PR 41647
* runtest.exp: Describe search for testsuite at verbose level 3.
Print initial working directory at verbose level 1.
diff --git a/NEWS b/NEWS
index 081f1a4..209e9c4 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
--* text -*-
+-*- text -*-
Changes since 1.6.2:
@@ -17,11 +17,15 @@ Changes since 1.6.2:
"*dir" variables in test scripts.
7. A shell command "dejagnu" is added as a place to hang various
auxiliary commands not directly involved with running tests. The
- "runtest" command will remain for that purpose for the forseeable
+ "runtest" command will remain for that purpose for the foreseeable
future.
8. The first auxiliary command is added: "report card". The "dejagnu
report card" command reads DejaGnu summary files and produces a
compact tabular summary across multiple tools.
+9. A Tcl namespace is now used for some internal procedures and variables.
+ The Tcl namespace ::dejagnu and all child namespaces are entirely
+ internal and should not be mentioned in testsuite code. Its contents
+ are subject to change without notice, even on point releases.
Changes since 1.6.1:
diff --git a/runtest.exp b/runtest.exp
index 156b1f4..ba49e73 100644
--- a/runtest.exp
+++ b/runtest.exp
@@ -410,6 +410,35 @@ proc usage { } {
# the arguments three times.
#
+namespace eval ::dejagnu::command_line {
+ variable cmd_var_list [list]
+
+ proc save_cmd_var {name} {
+ variable cmd_var_list
+
+ upvar 1 $name target_var
+ lappend cmd_var_list $name $target_var
+ }
+
+ proc restore_cmd_vars {} {
+ variable cmd_var_list
+
+ foreach {name value} $cmd_var_list {
+ uplevel 1 set $name $value
+ }
+ verbose "Variables set by command line arguments restored." 4
+ }
+
+ proc dump_cmd_vars {} {
+ variable cmd_var_list
+
+ verbose "Variables set by command line arguments:" 4
+ foreach {name value} $cmd_var_list {
+ verbose " $name -> $value" 4
+ }
+ }
+}
+
set arg_host_triplet ""
set arg_target_triplet ""
set arg_build_triplet ""
@@ -461,67 +490,81 @@ for { set i 0 } { $i < $argc } { incr i } {
"--bu*" { # (--build) the build host configuration
set arg_build_triplet $optarg
+ ::dejagnu::command_line::save_cmd_var arg_build_triplet
continue
}
"--g*" { # (--global_init) the global init file name
set global_init_file $optarg
+ ::dejagnu::command_line::save_cmd_var global_init_file
continue
}
"--host_bo*" {
set host_board $optarg
+ ::dejagnu::command_line::save_cmd_var host_board
continue
}
"--ho*" { # (--host) the host configuration
set arg_host_triplet $optarg
+ ::dejagnu::command_line::save_cmd_var arg_host_triplet
continue
}
"--loc*" { # (--local_init) the local init file name
set local_init_file $optarg
+ ::dejagnu::command_line::save_cmd_var local_init_file
continue
}
"--ob*" { # (--objdir) where the test case object code lives
set objdir $optarg
+ ::dejagnu::command_line::save_cmd_var objdir
continue
}
"--sr*" { # (--srcdir) where the testsuite source code lives
set srcdir $optarg
+ ::dejagnu::command_line::save_cmd_var srcdir
continue
}
"--target_bo*" {
set target_list $optarg
+ ::dejagnu::command_line::save_cmd_var target_list
continue
}
"--ta*" { # (--target) the target configuration
set arg_target_triplet $optarg
+ ::dejagnu::command_line::save_cmd_var arg_target_triplet
continue
}
"--tool_opt*" {
set TOOL_OPTIONS $optarg
+ ::dejagnu::command_line::save_cmd_var TOOL_OPTIONS
continue
}
"--tool_exec*" {
set TOOL_EXECUTABLE $optarg
+ ::dejagnu::command_line::save_cmd_var TOOL_EXECUTABLE
continue
}
"--to*" { # (--tool) specify tool name
set tool $optarg
set comm_line_tool $optarg
+ ::dejagnu::command_line::save_cmd_var tool
+ ::dejagnu::command_line::save_cmd_var comm_line_tool
continue
}
"--di*" {
set cmdline_dir_to_run $optarg
+ ::dejagnu::command_line::save_cmd_var cmdline_dir_to_run
continue
}
@@ -550,6 +593,8 @@ verbose "Verbose level is $verbose"
verbose [concat "Initial working directory is" [pwd]]
+::dejagnu::command_line::dump_cmd_vars
+
#
# get the users login name
#
@@ -638,10 +683,8 @@ proc load_lib { file } {
load_file [file join $base_dir $local_init_file]
-# From this point until the command line is parsed for the second time,
-# some variables are overridden by the local init file. Most notably,
-# $srcdir is *not* what was given on the command line if Automake is used.
-# Instead, $srcdir is Automake's @srcdir@ for now.
+# Ensure that command line parameters override testsuite init files.
+::dejagnu::command_line::restore_cmd_vars
#
# If objdir didn't get set in $base_dir/$local_init_file, set it to
@@ -656,6 +699,9 @@ if { $objdir eq "." || $objdir eq $srcdir } {
load_file [file join $objdir $local_init_file]
}
+# Ensure that command line parameters override testsuite init files.
+::dejagnu::command_line::restore_cmd_vars
+
#
# Find the testsuite.
#