]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git p4 test: use 'test_atexit' to kill p4d and the watchdog process
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 13 Mar 2019 12:24:15 +0000 (13:24 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Mar 2019 03:34:39 +0000 (12:34 +0900)
Use 'test_atexit' to run cleanup commands to stop 'p4d' at the end of
the test script or upon interrupt or failure, as it is shorter,
simpler, and more robust than registering such cleanup commands in the
trap on EXIT in the test scripts.

Note that one of the test scripts, 't9801-git-p4-branch.sh', stops and
then re-starts 'p4d' twice in the middle of the script; take care that
the cleanup functions to stop 'p4d' are only registered once.

Note also that 'git p4' tests invoke different functions in the trap
on EXIT ('cleanup') and in the last test before 'test_done'
('kill_p4d').  Register both of these functions with 'test_atexit' for
now, and a a later patch in this series will then clean up the
redundancy.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
35 files changed:
t/lib-git-p4.sh
t/t9800-git-p4-basic.sh
t/t9801-git-p4-branch.sh
t/t9802-git-p4-filetype.sh
t/t9803-git-p4-shell-metachars.sh
t/t9804-git-p4-label.sh
t/t9805-git-p4-skip-submit-edit.sh
t/t9806-git-p4-options.sh
t/t9807-git-p4-submit.sh
t/t9808-git-p4-chdir.sh
t/t9809-git-p4-client-view.sh
t/t9810-git-p4-rcs.sh
t/t9811-git-p4-label-import.sh
t/t9812-git-p4-wildcards.sh
t/t9813-git-p4-preserve-users.sh
t/t9814-git-p4-rename.sh
t/t9815-git-p4-submit-fail.sh
t/t9816-git-p4-locked.sh
t/t9817-git-p4-exclude.sh
t/t9818-git-p4-block.sh
t/t9819-git-p4-case-folding.sh
t/t9820-git-p4-editor-handling.sh
t/t9821-git-p4-path-variations.sh
t/t9822-git-p4-path-encoding.sh
t/t9823-git-p4-mock-lfs.sh
t/t9824-git-p4-git-lfs.sh
t/t9825-git-p4-handle-utf16-without-bom.sh
t/t9826-git-p4-keep-empty-commits.sh
t/t9827-git-p4-change-filetype.sh
t/t9828-git-p4-map-user.sh
t/t9829-git-p4-jobs.sh
t/t9830-git-p4-symlink-dir.sh
t/t9831-git-p4-triggers.sh
t/t9832-unshelve.sh
t/t9833-errors.sh

index b3be3ba011a71ce11f11901c8472cb25ec21133a..958e33b77ee31dd5fcbda3a421ad98eab5bd5d40 100644 (file)
@@ -74,7 +74,6 @@ cleanup () {
                kill -9 $(cat "$pidfile") 2>/dev/null && exit 255
        fi
 }
-trap cleanup EXIT
 
 # git p4 submit generates a temp file, which will
 # not get cleaned up if the submission fails.  Don't
@@ -82,7 +81,16 @@ trap cleanup EXIT
 TMPDIR="$TRASH_DIRECTORY"
 export TMPDIR
 
+registered_stop_p4d_atexit_handler=
 start_p4d () {
+       # One of the test scripts stops and then re-starts p4d.
+       # Don't register and then run the same atexit handlers several times.
+       if test -z "$registered_stop_p4d_atexit_handler"
+       then
+               test_atexit 'kill_p4d; cleanup'
+               registered_stop_p4d_atexit_handler=AlreadyDone
+       fi
+
        mkdir -p "$db" "$cli" "$git" &&
        rm -f "$pidfile" &&
        (
index 729cd25770177aa52bade1100bb4ddae1456d269..5856563068c71280065c28d294a7c0a1149f6008 100755 (executable)
@@ -326,8 +326,4 @@ test_expect_success 'submit from worktree' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 6a86d6996b97de0bed0503021b76b33db8441029..50013132c855f86a156f9062a78fc000f15c98de 100755 (executable)
@@ -610,8 +610,4 @@ test_expect_success 'Update a file in git side and submit to P4 using client vie
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 9978352d7828dbd63d44d172b91193a20291c4d1..94edebe272691a72768cea14c1185c26113aad14 100755 (executable)
@@ -333,8 +333,4 @@ test_expect_success SYMLINKS 'empty symlink target' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index d5c367510049607ce33db73ffc1869a0652fe663..2913277013da56e98b9ad8b6ec3ea47ccbace103 100755 (executable)
@@ -105,8 +105,4 @@ test_expect_success 'branch with shell char' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index e30f80e617674967b1d474c1485a6570f1ef2903..32364571063d4c6001105d0929ca81fe50e2a87c 100755 (executable)
@@ -108,8 +108,4 @@ test_expect_failure 'two labels on the same changelist' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 5fbf904dc8f4df7de522d0eecbca133d7299259d..90ef647db7e610b825cc92d51ee2a5379dcf05b3 100755 (executable)
@@ -98,8 +98,4 @@ test_expect_success 'no config, edited' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 3f5291b85752e7bc78901da18c2bfa654134eb59..4e794a01bf556f97f94eaabf8cc259f333c75049 100755 (executable)
@@ -300,9 +300,4 @@ test_expect_success 'use --git-dir option and GIT_DIR' '
        test_path_is_file "$git"/cli_file2.t
 '
 
-
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 850d97911966fe78f22035dab78ac0556a82fd99..eaaae414a1ff22d127a51f047716800a8585d87a 100755 (executable)
@@ -593,8 +593,4 @@ test_expect_success 'update a shelve involving moved and copied files' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 11d2b5102cde384ad11540610a52f62c4732aa8c..58a9b3b71e6d88dfc9e3086fb515362e7c31e34a 100755 (executable)
@@ -83,8 +83,4 @@ test_expect_success SYMLINKS 'p4 client root symlink should stay symbolic' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 897b3c3034efcab3af88d8eddc4670e274361dd5..3cff1fce1b7464826412ece52ef394a551dce65e 100755 (executable)
@@ -836,8 +836,4 @@ test_expect_success 'quotes on both sides' '
        git_verify "cdir 1/file11" "cdir 1/file12"
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index cc53debe1955ece317f994b0e76f2b8470b0f4f6..57b533dc6fbaa9d9b82bdaf300b46a426c7b43b7 100755 (executable)
@@ -360,8 +360,4 @@ test_expect_failure 'Add keywords in git which do not match the default p4 value
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 602b0a5d5ceafcac6439491b463fee7867e7036f..b70e81c3cd28d824a4f4aaa758914a60bcdfd562 100755 (executable)
@@ -259,9 +259,4 @@ test_expect_success 'importing labels with missing revisions' '
        )
 '
 
-
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 0206771fbb91b734a626e628b21786805ebcfa22..254a7c244698a0140d6f5605d3013f72d9775310 100755 (executable)
@@ -211,8 +211,4 @@ test_expect_success 'wildcard files requiring keyword scrub' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 783c6ad1653142d174e4ddc6d49e1f631121be51..fd018c87a80636d7bb286fe596f299bbbbe6828b 100755 (executable)
@@ -138,8 +138,4 @@ test_expect_success 'not preserving user with mixed authorship' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 60baa06e27a0a6c45f580738e60f7fe8fa65373a..468767cbf4b93eb20f209fc25b46cc0f53d5b907 100755 (executable)
@@ -242,8 +242,4 @@ test_expect_success P4D_HAVE_CONFIGURABLE_RUN_MOVE_ALLOW \
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index eaf03a656329c7b4b9d0ed40c839232a81b310ac..9779dc0d11f33b6d8a6c5b8d8ffded834eddd8b2 100755 (executable)
@@ -422,8 +422,4 @@ test_expect_success 'cleanup chmod after submit cancel' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index d048bd33fa3c94402eb750b65553f72b955aa25f..932841003cfc4e3f6273087f8567d6c6a660bb0b 100755 (executable)
@@ -138,8 +138,4 @@ test_expect_failure 'move with lock taken' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index aac568eadfcab6198877d211d3e706cead68e302..96d25f0c02ccfb04391487b550a702751bf22a11 100755 (executable)
@@ -64,8 +64,4 @@ test_expect_success 'clone, then sync with exclude' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index ce7cb22ad37165c6976b4484f6b39a49747d4485..0db7ab99184add2c500f821659b09cc833c6a225 100755 (executable)
@@ -146,8 +146,4 @@ test_expect_success 'Clone repo with self-sizing block size' '
        test_line_count \> 10 log
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index d808c008c11700badffdcbbd34faba39428a47f1..600ce1e0b0d7edf193291a6a25450c92a5888475 100755 (executable)
@@ -53,8 +53,4 @@ test_expect_failure 'Clone UC repo with lc name' '
        test_must_fail git p4 clone //depot/uc/...
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 3c22f74bd436b7c6d94d5c29d5b2e3e3510d58e6..fa1bba1dd93614c8ad5c7f4a37c5b612440fd0eb 100755 (executable)
@@ -31,8 +31,4 @@ test_expect_success 'EDITOR with options' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 81e46acfa8ba10b8d0051acc1e7b19dc6b1de365..ef80f1690bcb9ad153df900e277ef48ce8e4e62e 100755 (executable)
@@ -193,8 +193,4 @@ test_expect_success 'Add a new file and clone path with new file (ignorecase)' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index c78477c19b4330f990c0cdd7d96997b8ed2ed02c..1bf7635016f54385912e7bd830eada93810a4bfc 100755 (executable)
@@ -67,8 +67,4 @@ test_expect_success 'Delete iso8859-1 encoded paths and clone' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 1f2dc369bfa96e767741484b421f42b56b3c0a18..88b76dc4d6c26fc99e32c91a11b2eb5bb7118e2c 100755 (executable)
@@ -185,8 +185,4 @@ test_expect_success 'Run git p4 submit in repo configured with large file system
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index ed80ca858c8f8352bd5a26b9a30e0c182d102ee9..a28dbbdd566ca69212f23958056d95b735a0127c 100755 (executable)
@@ -287,8 +287,4 @@ test_expect_success 'Add big files to repo and store files in LFS based on compr
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 1551845dc178e3cc57d31ac3e66f60db921be874..f049ff8229c6d38053dd3b3842e898e8473eaeb3 100755 (executable)
@@ -43,8 +43,4 @@ test_expect_failure 'clone depot with invalid UTF-16 file in non-verbose mode' '
        git p4 clone --dest="$git" //depot
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index fa8b9daf1fafba7498583e916cfea52d3c7207f5..fd64afe064e5a937b4a15d18f70e87cd524067c8 100755 (executable)
@@ -127,8 +127,4 @@ test_expect_success 'Clone repo subdir with all history' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 7433998f4779c7d1691e8c6fbb31fed3224c355d..d3670bd7a24dbf3cdc350939d6d130bd662f3e73 100755 (executable)
@@ -59,8 +59,4 @@ test_expect_success SYMLINKS 'change symbolic link to file' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index e20395c89f3dbc461516e22339f9fef47bd3426e..ca6c2942bdf200942cc4122e6172a120e0f1d1c1 100755 (executable)
@@ -54,8 +54,4 @@ test_expect_success 'Clone repo root path with all history' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 971aeeea1fb69ff5b73109d8b9496b5574317cd5..88cfb1fcd3f0a1401fd1cdb10f1fe697a5c4aaa3 100755 (executable)
@@ -92,8 +92,4 @@ test_expect_success 'check log message of changelist with more jobs' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 2ad1b0810df81ecaf5197e4cf860b3524d557c09..3fb6960c18fc0c2eb549f09c66d92b3f39822653 100755 (executable)
@@ -36,8 +36,4 @@ test_expect_success 'symlinked directory' '
 
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index be44c9751aefa5368d6f05d7b1c29f0c8354095f..d743ca33ee6ab29f97d328756663803824f105f5 100755 (executable)
@@ -96,8 +96,4 @@ test_expect_success 'submit description with extra info lines from verbose p4 ch
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
 test_done
index 41c09f11f4bf44ece085f952e8782d4dfe3fd169..1286a5b824b77d71061fb890d9f528b46ecc087d 100755 (executable)
@@ -174,8 +174,5 @@ test_expect_success 'unshelve specifying the origin' '
                test_path_is_file file_to_shelve
        )
 '
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
 
 test_done
index 47b312e1c9705af6f6ac6bb55ee81cb847f53d0c..e22369ccdf5f15840546269d0cdef9e8a54ce698 100755 (executable)
@@ -45,9 +45,4 @@ test_expect_success 'ticket logged out' '
        )
 '
 
-test_expect_success 'kill p4d' '
-       kill_p4d
-'
-
-
 test_done