[Bash-completion-commits] [SCM] bash-completion branch, master, updated. c86b336769cdc025a63c13bf3448ce5d5019a563

Freddy Vulto fvulto at gmail.com
Fri Nov 12 22:36:43 UTC 2010


The following commit has been merged in the master branch:
commit c86b336769cdc025a63c13bf3448ce5d5019a563
Author: Freddy Vulto <fvulto at gmail.com>
Date:   Fri Nov 12 23:35:36 2010 +0100

    (testuite) Fix tests to run with autotools' make distcheck
    File locations are prefixed with `$::srcdir' so that `make distcheck' can
    execute the test suite using a relative path.
    
    The current working directory is removed from the test-suite-bash-prompt.
    
    Furthermore, no more dynamic creation of files in dir $::srcdir/fixtures since
    this dir is read-only during `make distcheck'.  Instead create dynamic files in
    $TESTDIR/tmp
    
    The test suite uses these "directory" variables
    
       tcl            bash          description
       ------------   -----------   ------------------------------------
       $::srcdir      $SRCDIR       where `fixtures' reside, relative
       $::srcdirabs   $SRCDIRABS    where `fixtures' reside, absolute
       $::TESTDIR     $TESTDIR      where `runtest' is invoked, absolute

diff --git a/configure.ac b/configure.ac
index b444e7a..5e3265e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 AC_PREREQ([2.59])
 AC_INIT([bash-completion], [1.99])
-AM_INIT_AUTOMAKE([foreign dejagnu dist-bzip2 no-dist-gzip -Wall -Werror])
+AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip -Wall -Werror])
 AC_SUBST(bashcompdir, $sysconfdir/bash_completion.d)
 AC_SUBST(helpersdir, $sysconfdir/bash_completion.d/helpers)
 AC_CONFIG_FILES([Makefile completions/Makefile completions/helpers/Makefile test/Makefile])
diff --git a/test/Makefile.am b/test/Makefile.am
index 9dab219..82f6df9 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -12,3 +12,5 @@ all:
 
 distclean-local:
 	rm -rf log tmp
+
+AUTOMAKE_OPTIONS = dejagnu
diff --git a/test/completion/acroread.exp b/test/completion/acroread.exp
index ccf0053..6ee03d6 100644
--- a/test/completion/acroread.exp
+++ b/test/completion/acroread.exp
@@ -9,4 +9,4 @@ expect {
 }; # expect
 
 
-source "lib/completions/acroread.exp"
+source "$::srcdir/lib/completions/acroread.exp"
diff --git a/test/completion/finger.exp b/test/completion/finger.exp
index cc77abe..7c7b8a2 100644
--- a/test/completion/finger.exp
+++ b/test/completion/finger.exp
@@ -1,6 +1 @@
-source "lib/completions/finger.exp"
-
-# TODO: Dynamic loading of completions.  After the tests have run a first time
-#       and real completion is installed, the tests can be run a second time.
-#
-# source "lib/completions/finger.exp"
+assert_source_completions finger
diff --git a/test/config/bashrc b/test/config/bashrc
index ddf0633..fd72b81 100644
--- a/test/config/bashrc
+++ b/test/config/bashrc
@@ -7,13 +7,12 @@ set -o posix
 	# Unset `command_not_found_handle' as defined on Debian/Ubuntu, because this 
 	# troubles and slows down testing
 unset -f command_not_found_handle
-	# Set prompt to ignore current root directory; display path starting
-	# from here.  E.g. prompt: /fixtures/@
+	# Set fixed prompt `/@'
 TESTDIR=$(pwd)
-export PS1='$(wd=$(pwd); echo ${wd#$TESTDIR}/)@'
+export PS1='/@'
 export PS2='> '
 	# Configure readline
-export INPUTRC=$TESTDIR/config/inputrc
+export INPUTRC=$SRCDIR/config/inputrc
     # When not running via cron, avoid escape junk at beginning of line from
     # readline, see e.g.  http://bugs.gentoo.org/246091
 [ "$CRON" ] || export TERM=dummy
@@ -31,7 +30,7 @@ unset -v \
     COMP_TAR_INTERNAL_PATHS
 
 	# Load bash testsuite helper functions
-. lib/library.sh
+. $SRCDIR/lib/library.sh
 
 # Local variables:
 # mode: shell-script
diff --git a/test/fixtures/_filedir/a b/i b/test/fixtures/acroread/bar
similarity index 100%
copy from test/fixtures/_filedir/a b/i
copy to test/fixtures/acroread/bar
diff --git a/test/fixtures/_filedir/a b/i b/test/fixtures/acroread/t.pdf
similarity index 100%
copy from test/fixtures/_filedir/a b/i
copy to test/fixtures/acroread/t.pdf
diff --git a/test/lib/completions/acroread.exp b/test/lib/completions/acroread.exp
index f1754e9..f627d34 100644
--- a/test/lib/completions/acroread.exp
+++ b/test/lib/completions/acroread.exp
@@ -1,19 +1,17 @@
 proc setup {} {
     save_env
-    assert_bash_exec "touch fixtures/shared/default/t.pdf";  # Create temporary files
 }
 
 
 proc teardown {} {
-    assert_bash_exec "rm fixtures/shared/default/t.pdf";  # Remove temporary files
-    assert_env_unmodified
+    assert_env_unmodified {/OLDPWD/d}
 }
 
 
 setup
 
 
-assert_complete {"bar bar.d/" foo.d/ t.pdf} "acroread fixtures/shared/default/"
+assert_complete_dir {foo.d/ t.pdf} "acroread " $::srcdir/fixtures/acroread
 
 
 sync_after_int
diff --git a/test/lib/completions/cancel.exp b/test/lib/completions/cancel.exp
index fc2600b..f4a0347 100644
--- a/test/lib/completions/cancel.exp
+++ b/test/lib/completions/cancel.exp
@@ -12,7 +12,7 @@ setup
 
 
     # Adding a print job is successful?
-if {[assert_exec {lp -H hold fixtures/shared/default/foo} job "" "untested"]} {
+if {[assert_exec {lp -H hold $::srcdir/fixtures/shared/default/foo} job "" "untested"]} {
     # Yes, adding a print-job is successful;
         # Retrieve job-id, so we can cancel the job after the test
     set job_id [lindex [split $job] 3]
diff --git a/test/lib/completions/cd.exp b/test/lib/completions/cd.exp
index 6616cd8..c32e11c 100644
--- a/test/lib/completions/cd.exp
+++ b/test/lib/completions/cd.exp
@@ -12,7 +12,7 @@ setup
 
 
 set test "Tab should complete"
-assert_complete {"bar bar.d/" foo.d/} "cd fixtures/shared/default/" $test
+assert_complete {"bar bar.d/" foo.d/} "cd $::srcdir/fixtures/shared/default/" $test
 
 
 sync_after_int
@@ -20,13 +20,13 @@ sync_after_int
 
 set test "Tab should complete cd at cursor position"
     # Try completion
-set cmd "cd fixtures/shared/default/foo"
+set cmd "cd $::srcdir/fixtures/shared/default/foo"
 append cmd \002\002\002; # \002 = ^B = Move cursor left in bash emacs mode
 #append cmd \033\0133D; # Escape-[-D = Cursor left
 send "$cmd\t"
 expect {
-    -re "cd fixtures/shared/default/foo\b\b\b\r\n(\.svn/ +|)bar bar.d/ +foo.d/ *(\.svn/ *|)\r\n/@cd fixtures/shared/default/foo\b\b\b$" { pass "$test" }
-	-re "^cd fixtures/shared/default/foo\b\b\bfoo.d/foo\b\b\b$" { fail "$test: Wrong cursor position" }
+    -re "cd $::srcdir/fixtures/shared/default/foo\b\b\b\r\n(\.svn/ +|)bar bar.d/ +foo.d/ *(\.svn/ *|)\r\n/@cd $::srcdir/fixtures/shared/default/foo\b\b\b$" { pass "$test" }
+	-re "^cd $::srcdir/fixtures/shared/default/foo\b\b\bfoo.d/foo\b\b\b$" { fail "$test: Wrong cursor position" }
     -re /@ { unresolved "$test at prompt" }
     default { unresolved "$test" }
 }
@@ -39,7 +39,7 @@ set test "Tab should complete CDPATH"
     # Set CDPATH
 assert_bash_exec "declare -p CDPATH &>/dev/null && OLDCDPATH=\$CDPATH || :"
 assert_bash_exec "CDPATH=\$PWD";
-assert_complete "fixtures/shared/default/foo.d/" "cd fixtures/shared/default/fo" $test
+assert_complete "$::srcdir/fixtures/shared/default/foo.d/" "cd $::srcdir/fixtures/shared/default/fo" $test
 sync_after_int
     # Reset CDPATH
 assert_bash_exec "declare -p OLDCDPATH &>/dev/null && CDPATH=\$OLDCDPATH || unset CDPATH && unset OLDCDPATH"
diff --git a/test/lib/completions/evince.exp b/test/lib/completions/evince.exp
index 607c442..204467a 100644
--- a/test/lib/completions/evince.exp
+++ b/test/lib/completions/evince.exp
@@ -26,7 +26,7 @@ set files {
     .tga .TGA .tif .TIF .tiff .TIFF
     .xpm .XPM .xwd .XWD
 }
-assert_complete_dir $files "evince " "fixtures/evince"
+assert_complete_dir $files "evince " "$::srcdir/fixtures/evince"
 
 
 sync_after_int 
diff --git a/test/lib/completions/find.exp b/test/lib/completions/find.exp
index aab0822..9acda64 100644
--- a/test/lib/completions/find.exp
+++ b/test/lib/completions/find.exp
@@ -41,7 +41,7 @@ sync_after_int
 
 
 set test "-wholename should complete files/dirs"
-set dir fixtures/shared/default
+set dir $::srcdir/fixtures/shared/default
 set files [split [exec bash -c "cd $dir && ls -p"] "\n"]
 assert_complete_dir $files "find -wholename " $dir
 
diff --git a/test/lib/completions/finger.exp b/test/lib/completions/finger.exp
index ae86a2d..f139c96 100644
--- a/test/lib/completions/finger.exp
+++ b/test/lib/completions/finger.exp
@@ -39,7 +39,7 @@ set hosts {}
 set char ""
 foreach h [get_known_hosts] {
     set first [string range $h 0 0]
-    if {$char == "" && [string first $first $COMP_WORDBREAKS] == -1} {set char $first}
+    if {$char == "" && [string first $first $::COMP_WORDBREAKS] == -1} {set char $first}
     if {$char != ""} {
         # Only append unique hostnames starting with $char
         if {$first == $char && [lsearch -exact $hosts "test@$h"] == -1} {
diff --git a/test/lib/completions/java.exp b/test/lib/completions/java.exp
index 16b6005..8864baf 100644
--- a/test/lib/completions/java.exp
+++ b/test/lib/completions/java.exp
@@ -25,7 +25,7 @@ sync_after_int
 
 
 assert_complete "bashcomp.jarred toplevel" \
-    "java -cp fixtures/java/bashcomp.jar "
+    "java -cp $::srcdir/fixtures/java/bashcomp.jar "
 
 
 sync_after_int
@@ -37,7 +37,7 @@ assert_no_complete "java -cp \"\" "
 sync_after_int
 
 
-assert_complete "a/ bashcomp.jar" "java -jar fixtures/java/"
+assert_complete "a/ bashcomp.jar" "java -jar $::srcdir/fixtures/java/"
 
 
 sync_after_int
diff --git a/test/lib/completions/kdvi.exp b/test/lib/completions/kdvi.exp
index c7881da..fa993f5 100644
--- a/test/lib/completions/kdvi.exp
+++ b/test/lib/completions/kdvi.exp
@@ -18,7 +18,7 @@ set files {
     foo/
     .dvi  .DVI  .dvi.bz2  .DVI.bz2  .dvi.gz  .DVI.gz  .dvi.Z  .DVI.Z
 }
-assert_complete_dir $files "kdvi " "fixtures/kdvi"
+assert_complete_dir $files "kdvi " "$::srcdir/fixtures/kdvi"
 
 
 sync_after_int
diff --git a/test/lib/completions/kpdf.exp b/test/lib/completions/kpdf.exp
index 4066c9c..6f0feb6 100644
--- a/test/lib/completions/kpdf.exp
+++ b/test/lib/completions/kpdf.exp
@@ -17,7 +17,7 @@ setup
 set files {
     foo/ .eps .ps .EPS .PS .pdf .PDF
 }
-assert_complete_dir $files "kpdf " "fixtures/kpdf"
+assert_complete_dir $files "kpdf " "$::srcdir/fixtures/kpdf"
 
 
 sync_after_int 
diff --git a/test/lib/completions/lzma.exp b/test/lib/completions/lzma.exp
index 56364d1..ba57d10 100644
--- a/test/lib/completions/lzma.exp
+++ b/test/lib/completions/lzma.exp
@@ -17,7 +17,7 @@ assert_complete_any "lzma "
 sync_after_int
 
 
-assert_complete "a/ bashcomp.lzma bashcomp.tlz" "lzma -d fixtures/xz/"
+assert_complete "a/ bashcomp.lzma bashcomp.tlz" "lzma -d $::srcdir/fixtures/xz/"
 
 
 sync_after_int
diff --git a/test/lib/completions/man.exp b/test/lib/completions/man.exp
index e0056ca..c7358c6 100644
--- a/test/lib/completions/man.exp
+++ b/test/lib/completions/man.exp
@@ -1,11 +1,11 @@
 proc setup {} {
-    assert_bash_exec {export MANPATH=$TESTDIR/fixtures/man}
+    assert_bash_exec "export MANPATH=$::srcdirabs/fixtures/man"
     save_env
 }
 
 
 proc teardown {} {
-    assert_env_unmodified
+    assert_env_unmodified {/OLDPWD/d}
 }
 
 
@@ -18,7 +18,7 @@ assert_complete "bar" "man b"
 sync_after_int
 
 
-assert_complete "fixtures/man/man1/foo.1" "man fixtures/man/man1/f"
+assert_complete_dir oo.1 "man man1/f" $::srcdir/fixtures/man
 
 
 sync_after_int
diff --git a/test/lib/completions/mkdir.exp b/test/lib/completions/mkdir.exp
index 4fc7b80..8d8c881 100644
--- a/test/lib/completions/mkdir.exp
+++ b/test/lib/completions/mkdir.exp
@@ -17,7 +17,7 @@ assert_complete_any "mkdir "
 sync_after_int
 
 
-assert_complete {"bar bar.d/" foo.d/} "mkdir fixtures/shared/default/"
+assert_complete {"bar bar.d/" foo.d/} "mkdir $::srcdir/fixtures/shared/default/"
 
 
 sync_after_int
diff --git a/test/lib/completions/mount.exp b/test/lib/completions/mount.exp
index 38d93e3..bab720b 100644
--- a/test/lib/completions/mount.exp
+++ b/test/lib/completions/mount.exp
@@ -5,11 +5,10 @@ proc setup_dummy_mnt {} {
     assert_bash_exec {unset COMPREPLY cur}
     assert_bash_exec {unset -f _mnt}
 
-    global TESTDIR
     assert_bash_exec { \
         _mnt() { \
             local cur=$(_get_cword); \
-            _linux_fstab $(_get_pword) < "$TESTDIR/fixtures/mount/test-fstab"; \
+            _linux_fstab $(_get_pword) < "$SRCDIRABS/fixtures/mount/test-fstab"; \
         }; \
         complete -F _mnt mnt \
     }
@@ -53,7 +52,7 @@ sync_after_int
 set test "Check completing nfs mounts"
 set expected [list /test/path /test/path2 /second/path]
 set cmd "mount mocksrv:/"
-assert_bash_exec {OLDPATH="$PATH"; PATH="$TESTDIR/fixtures/mount/bin:$PATH";}
+assert_bash_exec {OLDPATH="$PATH"; PATH="$SRCDIRABS/fixtures/mount/bin:$PATH";}
 # This needs an explicit cword param or will output "unresolved".
 assert_complete $expected $cmd $test "/@" 20 "/"
 sync_after_int
diff --git a/test/lib/completions/mutt.exp b/test/lib/completions/mutt.exp
index 91eb245..8cb8b0c 100644
--- a/test/lib/completions/mutt.exp
+++ b/test/lib/completions/mutt.exp
@@ -19,12 +19,12 @@ sync_after_int
 
 set test "mutt should complete mailboxes" 
 set expected {foo/ bar/ muttrc}
-assert_complete_dir $expected "mutt -F muttrc -f =" fixtures/mutt
+assert_complete_dir $expected "mutt -F muttrc -f =" $::srcdir/fixtures/mutt
 
 
 set test "mutt should complete aliases" 
 set expected {a1 a2}
-assert_complete_dir $expected "mutt -F muttrc -A " fixtures/mutt
+assert_complete_dir $expected "mutt -F muttrc -A " $::srcdir/fixtures/mutt
 
 
 sync_after_int
diff --git a/test/lib/completions/perl.exp b/test/lib/completions/perl.exp
index e02bd45..8be4162 100644
--- a/test/lib/completions/perl.exp
+++ b/test/lib/completions/perl.exp
@@ -18,7 +18,7 @@ sync_after_int
 
 
 set test "Second argument should file complete"
-set cmd "perl foo fixtures/shared/default/f"
+set cmd "perl foo $::srcdir/fixtures/shared/default/f"
 send "$cmd\t"
 expect {
     -re "^$cmd\r\nfoo +foo.d/ *\r\n/@${cmd}oo$" { pass "$test" }
@@ -31,7 +31,7 @@ sync_after_int
 
 
 set test "-I without space should complete directories"
-set cmd "perl -Ifixtures/shared/default/"
+set cmd "perl -I$::srcdir/fixtures/shared/default/"
 send "$cmd\t"
 expect {
     -re "^$cmd\r\nbar bar.d/ +foo.d/ *\r\n/@$cmd$" { pass "$test" }
@@ -44,7 +44,7 @@ sync_after_int
 
 
 set test "-I with space should complete directories"
-set cmd "perl -I fixtures/shared/default/"
+set cmd "perl -I $::srcdir/fixtures/shared/default/"
 send "$cmd\t"
 expect {
     -re "^$cmd\r\nbar bar.d/ +foo.d/ *\r\n/@$cmd$" { pass "$test" }
@@ -57,7 +57,7 @@ sync_after_int
 
 
 set test "-x without space should complete directories"
-set cmd "perl -xfixtures/shared/default/b"
+set cmd "perl -x$::srcdir/fixtures/shared/default/b"
 send "$cmd\t"
 expect {
     -re "^${cmd}ar\\\\ bar.d/ *$" { pass "$test" }
@@ -70,7 +70,7 @@ sync_after_int
 
 
 set test "-x with space should complete directories"
-set cmd "perl -x fixtures/shared/default/b"
+set cmd "perl -x $::srcdir/fixtures/shared/default/b"
 send "$cmd\t"
 expect {
     -re "^${cmd}ar\\\\ bar.d/ *$" { pass "$test" }
diff --git a/test/lib/completions/pkg_deinstall.exp b/test/lib/completions/pkg_deinstall.exp
index e61d0ce..c2b3ae0 100644
--- a/test/lib/completions/pkg_deinstall.exp
+++ b/test/lib/completions/pkg_deinstall.exp
@@ -1,5 +1,5 @@
 proc setup {} {
-    assert_bash_exec {PKG_DBDIR=fixtures/pkgtools/db}
+    assert_bash_exec {PKG_DBDIR=$::srcdir/fixtures/pkgtools/db}
     save_env
 }
 
@@ -12,7 +12,7 @@ proc teardown {} {
 setup
 
 
-set pkgs [exec bash -c "cd fixtures/pkgtools/db ; compgen -d"]
+set pkgs [exec bash -c "cd $::srcdir/fixtures/pkgtools/db ; compgen -d"]
 assert_complete $pkgs "pkg_deinstall "
 
 
diff --git a/test/lib/completions/portinstall.exp b/test/lib/completions/portinstall.exp
index 9f44e96..ab14afa 100644
--- a/test/lib/completions/portinstall.exp
+++ b/test/lib/completions/portinstall.exp
@@ -1,11 +1,11 @@
 proc setup {} {
-    assert_bash_exec {PORTSDIR=fixtures/pkgtools/ports ; sed -e s,PORTSDIR,$PORTSDIR,g $PORTSDIR/INDEX.dist > $PORTSDIR/INDEX ; cp $PORTSDIR/INDEX $PORTSDIR/INDEX-5}
+    assert_bash_exec {PORTSDIR=$TESTDIR/tmp; sed -e s,PORTSDIR,$PORTSDIR,g $::srcdir/fixtures/pkgtools/ports/INDEX.dist > $PORTSDIR/INDEX; cp $PORTSDIR/INDEX $PORTSDIR/INDEX-5}
     save_env
 }
 
 
 proc teardown {} {
-    assert_bash_exec {rm fixtures/pkgtools/ports/INDEX fixtures/pkgtools/ports/INDEX-5}
+    assert_bash_exec {rm $PORTSDIR/INDEX $PORTSDIR/INDEX-5}
     assert_env_unmodified
 }
 
diff --git a/test/lib/completions/rmdir.exp b/test/lib/completions/rmdir.exp
index 6452b4b..1a904b6 100644
--- a/test/lib/completions/rmdir.exp
+++ b/test/lib/completions/rmdir.exp
@@ -17,7 +17,7 @@ assert_complete_any "rmdir "
 sync_after_int
 
 
-assert_complete {"bar bar.d/" foo.d/} "rmdir fixtures/shared/default/"
+assert_complete {"bar bar.d/" foo.d/} "rmdir $::srcdir/fixtures/shared/default/"
 
 
 sync_after_int
diff --git a/test/lib/completions/sbcl-mt.exp b/test/lib/completions/sbcl-mt.exp
index d328fec..a80e543 100644
--- a/test/lib/completions/sbcl-mt.exp
+++ b/test/lib/completions/sbcl-mt.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete {bar "bar bar.d/" foo foo.d/} "sbcl-mt fixtures/shared/default/"
+assert_complete {bar "bar bar.d/" foo foo.d/} "sbcl-mt $::srcdir/fixtures/shared/default/"
 
 
 sync_after_int
diff --git a/test/lib/completions/sbcl.exp b/test/lib/completions/sbcl.exp
index c6f908f..3adeb6b 100644
--- a/test/lib/completions/sbcl.exp
+++ b/test/lib/completions/sbcl.exp
@@ -11,7 +11,7 @@ proc teardown {} {
 setup
 
 
-assert_complete {bar "bar bar.d/" foo foo.d/} "sbcl fixtures/shared/default/"
+assert_complete {bar "bar bar.d/" foo foo.d/} "sbcl $::srcdir/fixtures/shared/default/"
 
 
 sync_after_int
diff --git a/test/lib/completions/scp.exp b/test/lib/completions/scp.exp
index 57c41b8..e6cbf8e 100644
--- a/test/lib/completions/scp.exp
+++ b/test/lib/completions/scp.exp
@@ -1,9 +1,13 @@
 proc setup {} {
     save_env
+    # NOTE: Changing dir to $SRCDIR is necessary because file locations in the
+    #       ssh config files (e.g. UserKnownHostsFile) are relative to $SRCDIR.
+    assert_bash_exec {cd $SRCDIR/fixtures/scp}
 }
 
 
 proc teardown {} {
+    assert_bash_exec {cd $TESTDIR}
     assert_env_unmodified {
         /BASH_LINENO=/d
         /BASH_SOURCE=/d
@@ -60,8 +64,7 @@ foreach host [get_hosts] {
 lappend expected blah: doo: gee: hus: ike:
     # Append local filenames
 lappend expected config known_hosts "spaced\\ \\ conf"
-set dir fixtures/scp
-assert_complete_dir $expected "scp -F config " $dir
+assert_complete $expected "scp -F config "
 
 
 sync_after_int
@@ -94,16 +97,12 @@ foreach host [get_hosts] {
 lappend expected blah: doo: gee: hus: ike: jar:
     # Append local filenames
 lappend expected config known_hosts "spaced\\ \\ conf"
-set dir fixtures/scp
-#assert_complete_dir $expected "scp -F 'spaced  conf' " $dir
-set prompt "/$dir/@"
-assert_bash_exec "cd $dir" "" $prompt
 set cmd "scp -F 'spaced  conf' "
 send "$cmd\t"
 expect -ex "$cmd\r\n"
 if {[match_items [lsort -unique $expected] -bash-sort]} {
     expect {
-        -re $prompt { pass "$test" }
+        -re /@ { pass "$test" }
         -re eof { unresolved "eof" }
     }
 } else {
@@ -111,7 +110,7 @@ if {[match_items [lsort -unique $expected] -bash-sort]} {
     # http://www.mail-archive.com/bug-bash@gnu.org/msg06095.html
     if {[lindex $::BASH_VERSINFO 0] >= 4} {xfail "$test"} {fail "$test"}
 }
-sync_after_int $prompt
+sync_after_int
 assert_bash_exec {cd "$TESTDIR"}
 
 
diff --git a/test/lib/completions/screen.exp b/test/lib/completions/screen.exp
index b814589..e5bc4c1 100644
--- a/test/lib/completions/screen.exp
+++ b/test/lib/completions/screen.exp
@@ -18,7 +18,7 @@ sync_after_int
 
 
 assert_complete {bar "bar bar.d/" foo foo.d/} \
-    "screen -c fixtures/shared/default/" "-c should complete files/dirs"
+    "screen -c $::srcdir/fixtures/shared/default/" "-c should complete files/dirs"
 
 
 sync_after_int
diff --git a/test/lib/completions/sftp.exp b/test/lib/completions/sftp.exp
index fecdaf1..27fe751 100644
--- a/test/lib/completions/sftp.exp
+++ b/test/lib/completions/sftp.exp
@@ -1,9 +1,13 @@
 proc setup {} {
     save_env
+    # NOTE: Changing dir to $SRCDIR is necessary because file locations in the
+    #       ssh config files (e.g. UserKnownHostsFile) are relative to $SRCDIR.
+    assert_bash_exec {cd $SRCDIR/fixtures/sftp}
 }
 
 
 proc teardown {} {
+    assert_bash_exec {cd $TESTDIR}
     assert_env_unmodified {
         /BASH_LINENO=/d
         /BASH_SOURCE=/d
@@ -20,8 +24,7 @@ set expected [get_hosts]
     # Hosts `gee' and `hus' are defined in ./fixtures/sftp/config
     # Hosts `10.10.10.10', `doo' and `ike' are defined in ./fixtures/sftp/known_hosts
 lappend expected 10.10.10.10 doo gee hus ike
-set dir fixtures/sftp
-assert_complete_dir $expected "sftp -F config " $dir
+assert_complete $expected "sftp -F config "
 
 
 sync_after_int
@@ -48,19 +51,14 @@ set expected [get_hosts]
     # Hosts `gee', `hus' and `jar' are defined in "./fixtures/sftp/spaced  conf"
     # Hosts `10.10.10.10', `doo' and `ike' are defined in ./fixtures/sftp/known_hosts
 lappend expected 10.10.10.10 doo gee hus ike jar
-set dir fixtures/sftp
-assert_complete_dir $expected "sftp -F spaced\\ \\ conf " $dir
+assert_complete $expected "sftp -F spaced\\ \\ conf "
 
 
 sync_after_int
 
 
-set dir fixtures/sftp
-set prompt "/$dir/@"
-assert_bash_exec "cd $dir" "" $prompt
 assert_complete "-Fspaced\\ \\ conf" "sftp -Fsp" "-F should complete filename"
-sync_after_int $prompt
-assert_bash_exec {cd "$TESTDIR"}
+sync_after_int
 
 
 teardown
diff --git a/test/lib/completions/ssh.exp b/test/lib/completions/ssh.exp
index a5a1699..d16b5f9 100644
--- a/test/lib/completions/ssh.exp
+++ b/test/lib/completions/ssh.exp
@@ -1,9 +1,13 @@
 proc setup {} {
     save_env
+    # NOTE: Changing dir to $SRCDIR is necessary because file locations in the
+    #       ssh config files (e.g. UserKnownHostsFile) are relative to $SRCDIR.
+    assert_bash_exec {cd $SRCDIR/fixtures/ssh}
 }
 
 
 proc teardown {} {
+    assert_bash_exec {cd $TESTDIR}
     assert_env_unmodified {
         /BASH_LINENO=/d
         /BASH_SOURCE=/d
@@ -17,19 +21,15 @@ setup
 
 set test "Tab should complete both commands and hostname"
     # Try completion
-set dir fixtures/ssh
-set prompt "/$dir/@"
-assert_bash_exec "cd $dir" "" $prompt
 set cmd "ssh -F config ls"
 send "$cmd\t"
-set expected "^$cmd\r\n.*ls.*ls_known_host.*\r\n$prompt$cmd$"
+set expected "^$cmd\r\n.*ls.*ls_known_host.*\r\n/@$cmd$"
 expect {
     -re $expected  { pass "$test" }
-    -re $prompt { unresolved "$test at prompt" }
+    -re /@ { unresolved "$test at prompt" }
     default { unresolved "$test" }
 }
-sync_after_int $prompt
-assert_bash_exec {cd "$TESTDIR"}
+sync_after_int
 
 
 sync_after_int
@@ -69,12 +69,8 @@ sync_after_int
 
 
 set test "-F should complete filename"
-set dir fixtures/ssh
-set prompt "/$dir/@"
-assert_bash_exec "cd $dir" "" $prompt
 assert_complete "-Fspaced\\ \\ conf" "ssh -Fsp" "-F should complete filename"
-sync_after_int $prompt
-assert_bash_exec {cd "$TESTDIR"}
+sync_after_int
 
 
 teardown
diff --git a/test/lib/completions/sudo.exp b/test/lib/completions/sudo.exp
index 1afd993..a4b7690 100644
--- a/test/lib/completions/sudo.exp
+++ b/test/lib/completions/sudo.exp
@@ -4,20 +4,20 @@ proc setup {} {
 
 
 proc teardown {} {
-    assert_env_unmodified
+    assert_env_unmodified {/OLDPWD/d}
 }
 
 
 setup
 
 
-assert_complete "fixtures/shared/default/foo.d/" "sudo cd fixtures/shared/default/fo"
+assert_complete_dir foo.d/ "sudo cd fo" $::srcdir/fixtures/shared/default
 
 
 sync_after_int
 
 
-assert_complete "fixtures/" "sudo sh fix"
+assert_complete_dir fixtures/ "sudo sh fix" $::srcdir
 
 
 sync_after_int
diff --git a/test/lib/completions/xz.exp b/test/lib/completions/xz.exp
index 83b1f35..4bc783a 100644
--- a/test/lib/completions/xz.exp
+++ b/test/lib/completions/xz.exp
@@ -17,14 +17,14 @@ assert_complete_any "xz "
 sync_after_int
 
 
-assert_complete "a/ bashcomp.lzma bashcomp.tar.xz bashcomp.tlz bashcomp.xz" \
-    "xz -d fixtures/xz/"
+assert_complete_dir "a/ bashcomp.lzma bashcomp.tar.xz bashcomp.tlz bashcomp.xz" \
+    "xz -d " $::srcdir/fixtures/xz
 
 
 sync_after_int
 
 
-assert_complete "a/ bashcomp.tar" "xz fixtures/xz/"
+assert_complete_dir "a/ bashcomp.tar" "xz " $::srcdir/fixtures/xz
 
 
 sync_after_int
diff --git a/test/lib/library.exp b/test/lib/library.exp
index c69aa2b..92aef07 100644
--- a/test/lib/library.exp
+++ b/test/lib/library.exp
@@ -295,7 +295,7 @@ proc assert_complete_any {cmd {test ""} {prompt /@}} {
 # @param string $cword  (optional) Last word of $cmd to complete.  See: assert_complete()
 # @result boolean  True if successful, False if not
 proc assert_complete_dir {expected cmd dir {test ""} {size 20} {cword ""}} {
-    set prompt "/$dir/@"
+    set prompt "/@"
     assert_bash_exec "cd $dir" "" $prompt
     assert_complete $expected $cmd $test $prompt $size $cword
     sync_after_int $prompt
@@ -510,7 +510,7 @@ proc assert_no_output {{cmd} {test ""} {prompt /@}} {
 proc assert_source_completions {command {file ""}} {
     if {[is_bash_completion_installed_for $command]} {
         if {[string length $file] == 0} {
-            set file "lib/completions/$command.exp"
+            set file "$::srcdir/lib/completions/$command.exp"
         }
         source $file
     } else {
@@ -738,9 +738,9 @@ proc _save_env {{file ""}} {
 
 # Source bash_completion package
 proc source_bash_completion {} {
-    assert_bash_exec {BASH_COMPLETION_DIR=$(cd "$TESTDIR/.."; pwd)/completions}
+    assert_bash_exec {BASH_COMPLETION_DIR=$(cd "$SRCDIR/.."; pwd)/completions}
     assert_bash_exec {BASH_COMPLETION_COMPAT_DIR=$BASH_COMPLETION_DIR}
-    assert_bash_exec {BASH_COMPLETION=$(cd "$TESTDIR/.."; pwd)/bash_completion}
+    assert_bash_exec {BASH_COMPLETION=$(cd "$SRCDIR/.."; pwd)/bash_completion}
     assert_bash_exec {source "$BASH_COMPLETION"}
 }
 
@@ -854,10 +854,13 @@ proc find_unique_completion_pair {{list} {partName} {fullName}} {
 
 # Start bash running as test environment.
 proc start_bash {} {
-    global TESTDIR TOOL_EXECUTABLE spawn_id
+    global TESTDIR TOOL_EXECUTABLE spawn_id env srcdirabs
     set TESTDIR [pwd]
+    set srcdirabs [file normalize $::srcdir];  # Absolute srcdir
     # If `--tool_exec' option not specified, use "bash"
     if {! [info exists TOOL_EXECUTABLE]} {set TOOL_EXECUTABLE bash}
+    set env(SRCDIR) $::srcdir
+    set env(SRCDIRABS) $::srcdirabs
     exp_spawn $TOOL_EXECUTABLE --rcfile $::srcdir/config/bashrc
     assert_bash_exec {} "$TOOL_EXECUTABLE --rcfile $::srcdir/config/bashrc"
     # Bash < 3.2.41 has a bug where 'history' disappears from SHELLOPTS
diff --git a/test/unit/_filedir.exp b/test/unit/_filedir.exp
index 59b536e..7c8c420 100644
--- a/test/unit/_filedir.exp
+++ b/test/unit/_filedir.exp
@@ -20,17 +20,17 @@ proc setup {} {
     # directories containing `*' or `\' aren't allowed on Cygwin/Windows
     if {! [is_cygwin]} {
         # Create directory `a*b'
-        assert_bash_exec {(cd fixtures/_filedir && [ ! -d a\*b ] && mkdir a\*b && touch a\*b/j || true)}
+        assert_bash_exec {(cd $TESTDIR/tmp && [ ! -d a\*b ] && mkdir a\*b && touch a\*b/j || true)}
         # Create directory `a\b'
-        assert_bash_exec {(cd fixtures/_filedir && [ ! -d a\\b ] && mkdir a\\b && touch a\\b/g || true)}
+        assert_bash_exec {(cd $TESTDIR/tmp && [ ! -d a\\b ] && mkdir a\\b && touch a\\b/g || true)}
     }
 }
 
 
 proc teardown {} {
     if {! [is_cygwin]} {
-        assert_bash_exec {(cd fixtures/_filedir && rm -- a\\b/g && rmdir a\\b/ || true)}
-        assert_bash_exec {(cd fixtures/_filedir && rm -- a\*b/j && rmdir a\*b/ || true)}
+        assert_bash_exec {(cd $TESTDIR/tmp && rm -- a\\b/g && rmdir a\\b/ || true)}
+        assert_bash_exec {(cd $TESTDIR/tmp && rm -- a\*b/j && rmdir a\*b/ || true)}
     }
     assert_bash_exec {unset COMPREPLY cur}
     assert_bash_exec {unset -f _f _g}
@@ -56,7 +56,7 @@ foreach name {f f2} {
 
     set test "completing $name ab/ should return e"
     set cmd "$name ab/"
-    assert_complete_dir e $cmd "fixtures/_filedir" $test
+    assert_complete_dir e $cmd "$::srcdir/fixtures/_filedir" $test
 
 
     sync_after_int
@@ -64,7 +64,7 @@ foreach name {f f2} {
 
     set test "completing $name a\\ b/ should return i"
     set cmd "$name a\\ b/"
-    assert_complete_dir i $cmd "fixtures/_filedir" $test
+    assert_complete_dir i $cmd "$::srcdir/fixtures/_filedir" $test
 
 
     sync_after_int
@@ -72,7 +72,7 @@ foreach name {f f2} {
 
     set test "completing $name a\\\'b/ should return c"
     set cmd "$name a\\\'b/"
-    assert_complete_dir c $cmd "fixtures/_filedir" $test
+    assert_complete_dir c $cmd "$::srcdir/fixtures/_filedir" $test
 
 
     sync_after_int
@@ -80,7 +80,7 @@ foreach name {f f2} {
 
     set test "completing $name a\\\"b/ should return d"; #"
     set cmd "$name a\\\"b/"; #"
-    assert_complete_dir d $cmd "fixtures/_filedir" $test
+    assert_complete_dir d $cmd "$::srcdir/fixtures/_filedir" $test
 
 
     sync_after_int
@@ -88,8 +88,8 @@ foreach name {f f2} {
 
     set test "completing $name a\\\$b/ should return h"
     set cmd "$name a\\\$b/"
-    assert_complete_dir "\b\b\b\b\b$::TESTDIR/fixtures/_filedir/a\\\\\$b/h" \
-        $cmd "fixtures/_filedir" $test
+    assert_complete_dir "\b\b\b\b\b$::srcdirabs/fixtures/_filedir/a\\\\\$b/h" \
+        $cmd "$::srcdir/fixtures/_filedir" $test
 
 
     sync_after_int
@@ -101,7 +101,7 @@ foreach name {f f2} {
     if {! [is_cygwin]} {
         set test "completing $name a\\\\b/ should return g"
         set cmd "$name a\\\\b/"
-        assert_complete_dir g $cmd "fixtures/_filedir" $test
+        assert_complete_dir g $cmd "$TESTDIR/tmp" $test
 
 
         sync_after_int
@@ -110,7 +110,7 @@ foreach name {f f2} {
 
     set test "completing $name a\\&b/ should return f"
     set cmd "$name a\\&b/"
-    assert_complete_dir f $cmd "fixtures/_filedir" $test
+    assert_complete_dir f $cmd "$::srcdir/fixtures/_filedir" $test
 
 
     sync_after_int
@@ -118,7 +118,7 @@ foreach name {f f2} {
 
     set test "completing $name a\$ should return a\\\$b/"
     set cmd "$name a\$"
-    assert_complete_dir "\b\\\\\$b/" $cmd "fixtures/_filedir" $test
+    assert_complete_dir "\b\\\\\$b/" $cmd "$::srcdir/fixtures/_filedir" $test
 
 
     sync_after_int
@@ -132,21 +132,21 @@ foreach name {f f2} {
         [lindex $::BASH_VERSINFO 2] < 35
     )} {
         set cmd "$name 'ab/"
-        assert_complete_dir {e'} $cmd "fixtures/_filedir"
+        assert_complete_dir {e'} $cmd "$::srcdir/fixtures/_filedir"
 
 
         sync_after_int
 
 
         set cmd "$name 'a b/"
-        assert_complete_dir {i'} $cmd "fixtures/_filedir"
+        assert_complete_dir {i'} $cmd "$::srcdir/fixtures/_filedir"
 
 
         sync_after_int
 
 
         set cmd "$name 'a\"b/"; #"
-        assert_complete_dir {d'} $cmd "fixtures/_filedir"
+        assert_complete_dir {d'} $cmd "$::srcdir/fixtures/_filedir"
 
 
         sync_after_int
@@ -154,9 +154,9 @@ foreach name {f f2} {
 
         set cmd "$name 'a\$b/"
         if {[lindex $::BASH_VERSINFO 0] == 4} {
-            assert_complete_dir {h'} $cmd "fixtures/_filedir"
+            assert_complete_dir {h'} $cmd "$::srcdir/fixtures/_filedir"
         } else {
-            assert_complete_dir "\b\b\b\b$::TESTDIR/fixtures/_filedir/a\$b/h'" $cmd "fixtures/_filedir"
+            assert_complete_dir "\b\b\b\b$::srcdirabs/fixtures/_filedir/a\$b/h'" $cmd "$::srcdir/fixtures/_filedir"
         }
 
 
@@ -166,8 +166,8 @@ foreach name {f f2} {
         # Execute these tests only when not running on Cygwin/Windows, because
         # directories containing `*' or `\' aren't allowed on Cygwin/Windows
         if {! [is_cygwin]} {
-            set cmd "$name 'a\\b/"
-            assert_complete_dir {g'} $cmd "fixtures/_filedir"
+            set cmd "$name '$TESTDIR/tmp/a\\b/"
+            assert_complete_dir {g'} $cmd "$TESTDIR/tmp"
 
 
             sync_after_int
@@ -175,63 +175,63 @@ foreach name {f f2} {
 
 
         set cmd "$name 'a&b/"
-        assert_complete_dir {f'} $cmd "fixtures/_filedir"
+        assert_complete_dir {f'} $cmd "$::srcdir/fixtures/_filedir"
 
 
         sync_after_int
 
 
         set cmd "$name \"ab/"; #"
-        assert_complete_dir {e"} $cmd "fixtures/_filedir"; #"
+        assert_complete_dir {e"} $cmd "$::srcdir/fixtures/_filedir"; #"
 
 
         sync_after_int
 
 
         set cmd "$name \"a b/"; #"
-        assert_complete_dir {i"} $cmd "fixtures/_filedir"; #"
+        assert_complete_dir {i"} $cmd "$::srcdir/fixtures/_filedir"; #"
 
 
         sync_after_int
 
 
         set cmd "$name \"a'b/"; #"
-        assert_complete_dir {c"} $cmd "fixtures/_filedir"; #"
+        assert_complete_dir {c"} $cmd "$::srcdir/fixtures/_filedir"; #"
 
 
         sync_after_int
 
 
         set cmd "$name \"a\\\"b/"; #"
-        assert_complete_dir {d"} $cmd "fixtures/_filedir"; #"
+        assert_complete_dir {d"} $cmd "$::srcdir/fixtures/_filedir"; #"
 
 
         sync_after_int
 
 
         set cmd "$name \"a\\\$b/"; #"
-        assert_complete_dir "\b\b\b\b\b$::TESTDIR/fixtures/_filedir/a\\\\\$b/h\\\"" $cmd "fixtures/_filedir"
+        assert_complete_dir "\b\b\b\b\b$::srcdirabs/fixtures/_filedir/a\\\\\$b/h\\\"" $cmd "$::srcdir/fixtures/_filedir"
 
 
         sync_after_int
 
 
         set cmd "$name \"a\\b/"; #"
-        assert_complete_dir "\b\b\bb/e\\\"" $cmd "fixtures/_filedir"
+        assert_complete_dir "\b\b\bb/e\\\"" $cmd "$::srcdir/fixtures/_filedir"
 
 
         sync_after_int
 
 
         set cmd "$name \"a\\\\b/"; #"
-        assert_complete_dir {g"} $cmd "fixtures/_filedir"; #"
+        assert_complete_dir {g"} $cmd "$TESTDIR/tmp"; #"
 
 
         sync_after_int
 
 
         set cmd "$name \"a&b/"; #"
-        assert_complete_dir {f"} $cmd "fixtures/_filedir"; #"
+        assert_complete_dir {f"} $cmd "$::srcdir/fixtures/_filedir"; #"
 
 
         sync_after_int
@@ -242,7 +242,7 @@ foreach name {f f2} {
 
 
 set test "completing with filter '.e1' should show completions"
-assert_complete_dir {ee.e1 foo/ gg.e1 ii.E1} "g " "fixtures/_filedir/ext" $test
+assert_complete_dir {ee.e1 foo/ gg.e1 ii.E1} "g " "$::srcdir/fixtures/_filedir/ext" $test
 
 
 sync_after_int
@@ -259,7 +259,7 @@ if {
     [string first "UTF-8" $::LC_CTYPE] != -1 &&
     [string first 5.44 [exp_version]] != 0
 } {
-    assert_complete_dir g "f aé/" "fixtures/_filedir"
+    assert_complete_dir g "f aé/" "$::srcdir/fixtures/_filedir"
 } else {
     unsupported "$test"
 }
diff --git a/test/unit/_known_hosts_real.exp b/test/unit/_known_hosts_real.exp
index 3276edb..604b2d5 100644
--- a/test/unit/_known_hosts_real.exp
+++ b/test/unit/_known_hosts_real.exp
@@ -1,4 +1,7 @@
 proc setup {} {
+    # NOTE: Changing dir to $SRCDIR is necessary because file locations in the
+    #       ssh config files (e.g. UserKnownHostsFile) are relative to $SRCDIR.
+    assert_bash_exec {cd $SRCDIR}
     save_env
 }
 
@@ -8,6 +11,7 @@ proc teardown {} {
         /COMPREPLY=/d
         /OLDHOME=/d
     }
+    assert_bash_exec {cd $TESTDIR}
 }
 
 
@@ -79,7 +83,7 @@ set hosts [get_hosts]
 lappend hosts two three
 set hosts [join [bash_sort $hosts] "\\s+"]
     # Setup environment
-set cmd {OLDHOME=$HOME; HOME=$TESTDIR}
+set cmd {OLDHOME=$HOME; HOME=$SRCDIRABS}
 send "$cmd\r"
 expect -ex "$cmd\r\n/@"
     # Call _known_hosts
diff --git a/test/unit/compgen.exp b/test/unit/compgen.exp
index 8596cfa..6e6f79c 100644
--- a/test/unit/compgen.exp
+++ b/test/unit/compgen.exp
@@ -18,9 +18,8 @@ if {[lindex $::BASH_VERSINFO 0] <= 3} {
     set test {compgen -f a\\\'b/ on bash-4 should return a\'b/c};
     set cmd {compgen -f a\\\'b/}
 }
-set dir fixtures/compgen
-set prompt "/$dir/@"
-assert_bash_exec "cd $dir" "" $prompt
+set dir $::srcdir/fixtures/compgen
+assert_bash_exec "cd $dir"
 send "$cmd\r"
 expect -ex "$cmd\r\n"
 expect {
@@ -37,13 +36,13 @@ expect {
         if {[lindex $::BASH_VERSINFO 0] <= 3 } \
             {pass $test} else {fail $test}
     }
-    -re $prompt { pass "$test" }
+    -re /@ { pass "$test" }
     -re eof { unresolved "eof" }
 }
-sync_after_int $prompt
+sync_after_int
 assert_bash_exec {cd "$TESTDIR"}
 
-#assert_bash_list_dir {a\\\'b/c} $cmd fixtures/compgen
+#assert_bash_list_dir {a\\\'b/c} $cmd $::srcdir/fixtures/compgen
 
 
 sync_after_int

-- 
bash-completion



More information about the Bash-completion-commits mailing list