]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t5710: arrange to delete the client before cloning
authorChristian Couder <christian.couder@gmail.com>
Tue, 18 Mar 2025 11:00:05 +0000 (12:00 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Mar 2025 19:22:33 +0000 (12:22 -0700)
If `test_when_finished "rm -rf client"` is run after we clone, it
will not run if the clone failed, so the "client" directory might
not be removed at the end of the test.

`git clone` does try to remove the directory when it fails, but
let's be safe and try to protect against possibly weird clone
failures by moving `test_when_finished "rm -rf client"` before
the clone. It just makes more sense this way around.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5710-promisor-remote-capability.sh

index d2cc69a17e4668b087d862a6b46e960b7cff0d8d..e26a97f588fd5bda26a92996fb8d3355da6e50ac 100755 (executable)
@@ -93,6 +93,7 @@ test_expect_success "setup for testing promisor remote advertisement" '
 
 test_expect_success "clone with promisor.advertise set to 'true'" '
        git -C server config promisor.advertise true &&
+       test_when_finished "rm -rf client" &&
 
        # Clone from server to create a client
        GIT_NO_LAZY_FETCH=0 git clone -c remote.lop.promisor=true \
@@ -100,7 +101,6 @@ test_expect_success "clone with promisor.advertise set to 'true'" '
                -c remote.lop.url="file://$(pwd)/lop" \
                -c promisor.acceptfromserver=All \
                --no-local --filter="blob:limit=5k" server client &&
-       test_when_finished "rm -rf client" &&
 
        # Check that the largest object is still missing on the server
        check_missing_objects server 1 "$oid"
@@ -108,6 +108,7 @@ test_expect_success "clone with promisor.advertise set to 'true'" '
 
 test_expect_success "clone with promisor.advertise set to 'false'" '
        git -C server config promisor.advertise false &&
+       test_when_finished "rm -rf client" &&
 
        # Clone from server to create a client
        GIT_NO_LAZY_FETCH=0 git clone -c remote.lop.promisor=true \
@@ -115,7 +116,6 @@ test_expect_success "clone with promisor.advertise set to 'false'" '
                -c remote.lop.url="file://$(pwd)/lop" \
                -c promisor.acceptfromserver=All \
                --no-local --filter="blob:limit=5k" server client &&
-       test_when_finished "rm -rf client" &&
 
        # Check that the largest object is not missing on the server
        check_missing_objects server 0 "" &&
@@ -126,6 +126,7 @@ test_expect_success "clone with promisor.advertise set to 'false'" '
 
 test_expect_success "clone with promisor.acceptfromserver set to 'None'" '
        git -C server config promisor.advertise true &&
+       test_when_finished "rm -rf client" &&
 
        # Clone from server to create a client
        GIT_NO_LAZY_FETCH=0 git clone -c remote.lop.promisor=true \
@@ -133,7 +134,6 @@ test_expect_success "clone with promisor.acceptfromserver set to 'None'" '
                -c remote.lop.url="file://$(pwd)/lop" \
                -c promisor.acceptfromserver=None \
                --no-local --filter="blob:limit=5k" server client &&
-       test_when_finished "rm -rf client" &&
 
        # Check that the largest object is not missing on the server
        check_missing_objects server 0 "" &&
@@ -144,8 +144,8 @@ test_expect_success "clone with promisor.acceptfromserver set to 'None'" '
 
 test_expect_success "init + fetch with promisor.advertise set to 'true'" '
        git -C server config promisor.advertise true &&
-
        test_when_finished "rm -rf client" &&
+
        mkdir client &&
        git -C client init &&
        git -C client config remote.lop.promisor true &&
@@ -162,6 +162,7 @@ test_expect_success "init + fetch with promisor.advertise set to 'true'" '
 
 test_expect_success "clone with promisor.acceptfromserver set to 'KnownName'" '
        git -C server config promisor.advertise true &&
+       test_when_finished "rm -rf client" &&
 
        # Clone from server to create a client
        GIT_NO_LAZY_FETCH=0 git clone -c remote.lop.promisor=true \
@@ -169,7 +170,6 @@ test_expect_success "clone with promisor.acceptfromserver set to 'KnownName'" '
                -c remote.lop.url="file://$(pwd)/lop" \
                -c promisor.acceptfromserver=KnownName \
                --no-local --filter="blob:limit=5k" server client &&
-       test_when_finished "rm -rf client" &&
 
        # Check that the largest object is still missing on the server
        check_missing_objects server 1 "$oid"
@@ -177,6 +177,7 @@ test_expect_success "clone with promisor.acceptfromserver set to 'KnownName'" '
 
 test_expect_success "clone with 'KnownName' and different remote names" '
        git -C server config promisor.advertise true &&
+       test_when_finished "rm -rf client" &&
 
        # Clone from server to create a client
        GIT_NO_LAZY_FETCH=0 git clone -c remote.serverTwo.promisor=true \
@@ -184,7 +185,6 @@ test_expect_success "clone with 'KnownName' and different remote names" '
                -c remote.serverTwo.url="file://$(pwd)/lop" \
                -c promisor.acceptfromserver=KnownName \
                --no-local --filter="blob:limit=5k" server client &&
-       test_when_finished "rm -rf client" &&
 
        # Check that the largest object is not missing on the server
        check_missing_objects server 0 "" &&
@@ -195,6 +195,7 @@ test_expect_success "clone with 'KnownName' and different remote names" '
 
 test_expect_success "clone with promisor.acceptfromserver set to 'KnownUrl'" '
        git -C server config promisor.advertise true &&
+       test_when_finished "rm -rf client" &&
 
        # Clone from server to create a client
        GIT_NO_LAZY_FETCH=0 git clone -c remote.lop.promisor=true \
@@ -202,7 +203,6 @@ test_expect_success "clone with promisor.acceptfromserver set to 'KnownUrl'" '
                -c remote.lop.url="file://$(pwd)/lop" \
                -c promisor.acceptfromserver=KnownUrl \
                --no-local --filter="blob:limit=5k" server client &&
-       test_when_finished "rm -rf client" &&
 
        # Check that the largest object is still missing on the server
        check_missing_objects server 1 "$oid"
@@ -212,6 +212,7 @@ test_expect_success "clone with 'KnownUrl' and different remote urls" '
        ln -s lop serverTwo &&
 
        git -C server config promisor.advertise true &&
+       test_when_finished "rm -rf client" &&
 
        # Clone from server to create a client
        GIT_NO_LAZY_FETCH=0 git clone -c remote.lop.promisor=true \
@@ -219,7 +220,6 @@ test_expect_success "clone with 'KnownUrl' and different remote urls" '
                -c remote.lop.url="file://$(pwd)/serverTwo" \
                -c promisor.acceptfromserver=KnownUrl \
                --no-local --filter="blob:limit=5k" server client &&
-       test_when_finished "rm -rf client" &&
 
        # Check that the largest object is not missing on the server
        check_missing_objects server 0 "" &&