2000-08-02 Jimmy Guo <guo@hpcleara.cup.hp.com>
+ * lib/utils.exp: Add support for a -maxdepth <n>
+ option to limit find to <n> directories deep.
+
* runtest.exp: Cleanup reference to $env(MULTIPASS) and
$env(PASS). These were added by HP but unused since.
-
+ Handle multiple directories in TCL variables
+ dir_to_run and cmdline_dir_to_run; limit *.exp find to
+ one directory level to avoid foo/bar/baz.exp getting tested
+ twice (when ${dir} is 'foo', and when ${dir} is 'foo/bar').
+
* lib/framework.exp (pass): make compiler_conditional_xfail_data
a global, corresponding to a recent change to 'proc fail'.
#
# Finds all the files recursively
-# rootdir - this is the directory to start the search
-# from. This is and all subdirectories are search for
-# filenames. Directory names are not included in the
-# list, but the filenames have path information.
-# pattern - this is the pattern to match. Patterns are csh style
-# globbing rules.
-# returns: a list or a NULL.
-#
-proc find { rootdir pattern } {
+# Args:
+# [-maxdepth <n>]
+# limit recursive find depth to <n> level;
+# default is to recursively find in all subdirectories
+# rootdir
+# the directory to start the search from. This is and all
+# subdirectories are searched for filenames. Directory names
+# are not included in the list, but the filenames have path
+# information.
+# pattern
+# the pattern to match. Patterns are csh style globbing rules.
+# Returns:
+# a list or a NULL.
+#
+proc find { args } {
+ if { [lindex $args 0] == "-maxdepth" } {
+ set maxdepth [lindex $args 1]
+ set args [lrange $args 2 end]
+ } else {
+ set maxdepth 0
+ }
+ set rootdir [lindex $args 0]
+ set pattern [lindex $args 1]
+
# first find all the directories
set dirs "$rootdir "
- while 1 {
+ set depth 1
+ while { $maxdepth == 0 || $depth < $maxdepth } {
set tmp $rootdir
set rootdir ""
if [string match "" $tmp] {
}
}
set tmp ""
+ set depth [expr $depth + 1]
}
# find all the files that match the pattern
# value (for example in MULTIPASS) and the test
# directory matches that directory.
if {[info exists dir_to_run] && $dir_to_run != ""} {
- if ![string match "*${dir_to_run}*" $dir] {
+ # JYG: dir_to_run might be a space delimited list
+ # of directories. Look for match on each item.
+ set found 0
+ foreach directory $dir_to_run {
+ if [string match "*${directory}*" $dir] {
+ set found 1
+ break
+ }
+ }
+ if {!$found} {
continue
}
}
# directory matches that directory
if {[info exists cmdline_dir_to_run] \
&& $cmdline_dir_to_run != ""} {
- if ![string match "*${cmdline_dir_to_run}*" $dir] {
+ # JYG: cmdline_dir_to_run might be a space delimited
+ # list of directories. Look for match on each item.
+ set found 0
+ foreach directory $cmdline_dir_to_run {
+ if [string match "*${directory}*" $dir] {
+ set found 1
+ break
+ }
+ }
+ if {!$found} {
continue
}
}
- foreach test_name [lsort [find ${dir} *.exp]] {
+ # JYG: Limit find to one directory level to treat
+ # each test directory as a base directory.
+ # test_top_dirs includes all subdirectory paths,
+ # e.g. for gdb.hp/gdb.base-hp/, test_top_dirs
+ # has two entries: gdb.hp/, and gdb.base-hp/.
+ # If we just use '[find ${dir} *.exp]', all
+ # *.exp files in gdb.hp/gdb.base-hp/ would be
+ # picked up twice and tested twice, which is
+ # what we don't need.
+ foreach test_name [lsort [find -maxdepth 1 ${dir} *.exp]] {
if { ${test_name} == "" } {
continue
}