test: handle filenames that have directories in them
authorEthan Glasser-Camp <ethan.glasser.camp@gmail.com>
Fri, 12 Oct 2012 20:43:28 +0000 (16:43 -0400)
committerDavid Bremner <bremner@debian.org>
Thu, 18 Oct 2012 11:44:37 +0000 (08:44 -0300)
Since $TEST_DIRECTORY is an absolute path, any filenames generated
with it will be complete paths. Only use the basename to generate
suffixes for filenames.

Signed-off-by: Ethan Glasser-Camp <ethan@betacantrips.com>
test/test-lib.sh

index 7448b454a023231947688a542d701438728b8497..8de5e32fd920e83ed1015d2337a19387ddb16ca2 100644 (file)
@@ -498,16 +498,18 @@ test_expect_equal_file ()
        error "bug in the test script: not 2 or 3 parameters to test_expect_equal"
 
        file1="$1"
+       basename1=`basename "$file1"`
        file2="$2"
+       basename2=`basename "$file2"`
        if ! test_skip "$test_subtest_name"
        then
                if diff -q "$file1" "$file2" >/dev/null ; then
                        test_ok_ "$test_subtest_name"
                else
                        testname=$this_test.$test_count
-                       cp "$file1" "$testname.$file1"
-                       cp "$file2" "$testname.$file2"
-                       test_failure_ "$test_subtest_name" "$(diff -u "$testname.$file1" "$testname.$file2")"
+                       cp "$file1" "$testname.$basename1"
+                       cp "$file2" "$testname.$basename2"
+                       test_failure_ "$test_subtest_name" "$(diff -u "$testname.$basename1" "$testname.$basename2")"
                fi
     fi
 }