aboutsummaryrefslogtreecommitdiff
path: root/runtest.exp
diff options
context:
space:
mode:
authorJacob Bachmeyer <jcb62281@gmail.com>2018-12-04 19:28:54 +1100
committerBen Elliston <bje@gnu.org>2018-12-04 19:28:54 +1100
commit91b267562d94064d00c709fcdcef29f225a80c5b (patch)
tree6faf52e868c8d2d8243eb2e487fe1dca4704b94f /runtest.exp
parentcb56b0093c860f2e66544813cd354bcb46b4ac88 (diff)
downloaddejagnu-91b267562d94064d00c709fcdcef29f225a80c5b.zip
dejagnu-91b267562d94064d00c709fcdcef29f225a80c5b.tar.gz
dejagnu-91b267562d94064d00c709fcdcef29f225a80c5b.tar.bz2
* lib/utils.exp (relative_filename): New proc.
* runtest.exp: Use it. * doc/dejagnu.texi (relative_filename procedure): Document it. * testsuite/runtest.all/utils.test: Add tests for relative_filename. Signed-off-by: Ben Elliston <bje@gnu.org>
Diffstat (limited to 'runtest.exp')
-rw-r--r--runtest.exp27
1 files changed, 4 insertions, 23 deletions
diff --git a/runtest.exp b/runtest.exp
index b0ddfed..327131a 100644
--- a/runtest.exp
+++ b/runtest.exp
@@ -1771,15 +1771,8 @@ foreach current_target $target_list {
# set subdir to the tail of the dirname after $srcdir,
# for the driver files that want it. XXX this is silly.
# drivers should get a single var, not "$srcdir/$subdir"
- set subdir [file dirname $test_name]
- set p [expr {[string length $srcdir] - 1}]
- while {0 < $p && [string index $srcdir $p] == "/"} {
- incr p -1
- }
- if {[string range $subdir 0 $p] == $srcdir} {
- set subdir [string range $subdir [expr {$p + 1}] end]
- regsub "^/" $subdir "" subdir
- }
+ set subdir [relative_filename $srcdir \
+ [file dirname $test_name]]
# XXX not the right thing to do.
set runtests [list [file tail $test_name] ""]
@@ -1860,20 +1853,8 @@ foreach current_target $target_list {
# Get the path after the $srcdir so we know
# the subdir we're in.
- set subdir [file dirname $test_name]
- # We used to do
- # regsub $srcdir [file dirname $test_name] "" subdir
- # but what if [file dirname $test_name] contains regexp
- # characters? We lose. Instead...
- set first [string first $srcdir $subdir]
- if { $first >= 0 } {
- set first [expr {$first + [string length $srcdir]}]
- set subdir [string range $subdir $first end]
- regsub "^/" "$subdir" "" subdir
- }
- if { "$srcdir" == "$subdir" || "$srcdir" == "$subdir/" } {
- set subdir ""
- }
+ set subdir [relative_filename $srcdir \
+ [file dirname $test_name]]
# Check to see if the range of tests is limited,
# set `runtests' to a list of two elements: the script name
# and any arguments ("" if none).