OSDN Git Service

* runtest.exp: Handle multiple directories in TCL variables
authorguo <guo>
Wed, 2 Aug 2000 22:35:10 +0000 (22:35 +0000)
committerguo <guo>
Wed, 2 Aug 2000 22:35:10 +0000 (22:35 +0000)
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 <n>
option to limit find to <n> directories deep.

dejagnu/ChangeLog
dejagnu/lib/utils.exp
dejagnu/runtest.exp

index a3339d7..98f004f 100644 (file)
@@ -1,8 +1,15 @@
 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'.
        
index 565f18e..1f84fbd 100644 (file)
@@ -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 <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] {
@@ -115,6 +131,7 @@ proc find { rootdir pattern } {
            }
        }
        set tmp ""
+        set depth [expr $depth + 1]
     }
     
     # find all the files that match the pattern
index 4fcc102..47e0a4e 100644 (file)
@@ -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
                        }