]> git.notmuchmail.org Git - notmuch/commitdiff
test/test-lib.sh: execute basename(1)s lazier in test_expect_equal_file ()
authorTomi Ollila <tomi.ollila@iki.fi>
Sun, 9 Oct 2016 20:36:07 +0000 (23:36 +0300)
committerDavid Bremner <david@tethera.net>
Tue, 25 Oct 2016 21:13:29 +0000 (18:13 -0300)
Moved the 2 basename(1) executions to the test failure branch in
test_expect_equal_file ().

The output of basename(1) executions in function test_expect_equal_file ()
are only used when tests fails -- when all tests pass these 2 basename(1)
executions are no longer done at all.

test/test-lib.sh

index e7b83392f168c71ca7cb62ca19fb4ac30df1a0ba..a12c6d0a85b75c126f17eb6778fe1f092c7300b2 100644 (file)
@@ -624,15 +624,15 @@ 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_
                else
                        testname=$this_test.$test_count
+                       basename1=`basename "$file1"`
+                       basename2=`basename "$file2"`
                        cp "$file1" "$testname.$basename1"
                        cp "$file2" "$testname.$basename2"
                        test_failure_ "$(diff -u "$testname.$basename1" "$testname.$basename2")"