]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/README
test-lib: introduce 'test_atexit'
[thirdparty/git.git] / t / README
index 7a3d582267c7f8f70f018d95dbed4d085ed89f98..0b03175c7d5f0474d26cfc529b9379727acbec58 100644 (file)
--- a/t/README
+++ b/t/README
@@ -862,6 +862,26 @@ library for your script to use.
                ...
        '
 
+ - test_atexit <script>
+
+   Prepend <script> to a list of commands to run unconditionally to
+   clean up before the test script exits, e.g. to stop a daemon:
+
+       test_expect_success 'test git daemon' '
+               git daemon &
+               daemon_pid=$! &&
+               test_atexit 'kill $daemon_pid' &&
+               hello world
+       '
+
+   The commands will be executed before the trash directory is removed,
+   i.e. the atexit commands will still be able to access any pidfiles or
+   socket files.
+
+   Note that these commands will be run even when a test script run
+   with '--immediate' fails.  Be careful with your atexit commands to
+   minimize any changes to the failed state.
+
  - test_write_lines <lines>
 
    Write <lines> on standard output, one line per argument.