From e46eadf09b2ab79d59d0cc50b6a8372c8843c031 Mon Sep 17 00:00:00 2001 From: guo Date: Wed, 2 Aug 2000 22:35:10 +0000 Subject: [PATCH] * runtest.exp: 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/utils.exp (find): Add support for a -maxdepth option to limit find to directories deep. --- dejagnu/ChangeLog | 9 ++++++++- dejagnu/lib/utils.exp | 37 +++++++++++++++++++++++++++---------- dejagnu/runtest.exp | 33 ++++++++++++++++++++++++++++++--- 3 files changed, 65 insertions(+), 14 deletions(-) diff --git a/dejagnu/ChangeLog b/dejagnu/ChangeLog index a3339d7695..98f004f5a0 100644 --- a/dejagnu/ChangeLog +++ b/dejagnu/ChangeLog @@ -1,8 +1,15 @@ 2000-08-02 Jimmy Guo + * lib/utils.exp: Add support for a -maxdepth + option to limit find to 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'. diff --git a/dejagnu/lib/utils.exp b/dejagnu/lib/utils.exp index 565f18ead0..1f84fbd92e 100644 --- a/dejagnu/lib/utils.exp +++ b/dejagnu/lib/utils.exp @@ -87,18 +87,34 @@ proc getdirs { args } { # # 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 ] +# limit recursive find depth to 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] { @@ -115,6 +131,7 @@ proc find { rootdir pattern } { } } set tmp "" + set depth [expr $depth + 1] } # find all the files that match the pattern diff --git a/dejagnu/runtest.exp b/dejagnu/runtest.exp index 4fcc102d0c..47e0a4e1f4 100644 --- a/dejagnu/runtest.exp +++ b/dejagnu/runtest.exp @@ -1730,7 +1730,16 @@ foreach current_target $target_list { # 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 } } @@ -1740,12 +1749,30 @@ foreach current_target $target_list { # 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 } -- 2.11.0