]> git.ipfire.org Git - thirdparty/git.git/blob - t/t0092-diagnose.sh
builtin/diagnose.c: add '--mode' option
[thirdparty/git.git] / t / t0092-diagnose.sh
1 #!/bin/sh
2
3 test_description='git diagnose'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 test_expect_success UNZIP 'creates diagnostics zip archive' '
9 test_when_finished rm -rf report &&
10
11 git diagnose -o report -s test >out &&
12 grep "Available space" out &&
13
14 zip_path=report/git-diagnostics-test.zip &&
15 test_path_is_file "$zip_path" &&
16
17 # Check zipped archive content
18 "$GIT_UNZIP" -p "$zip_path" diagnostics.log >out &&
19 test_file_not_empty out &&
20
21 "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out &&
22 grep ".git/objects" out &&
23
24 "$GIT_UNZIP" -p "$zip_path" objects-local.txt >out &&
25 grep "^Total: [0-9][0-9]*" out &&
26
27 # Should not include .git directory contents by default
28 ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/"
29 '
30
31 test_expect_success UNZIP '--mode=stats excludes .git dir contents' '
32 test_when_finished rm -rf report &&
33
34 git diagnose -o report -s test --mode=stats >out &&
35
36 # Includes pack quantity/size info
37 "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out &&
38 grep ".git/objects" out &&
39
40 # Does not include .git directory contents
41 ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/"
42 '
43
44 test_expect_success UNZIP '--mode=all includes .git dir contents' '
45 test_when_finished rm -rf report &&
46
47 git diagnose -o report -s test --mode=all >out &&
48
49 # Includes pack quantity/size info
50 "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out &&
51 grep ".git/objects" out &&
52
53 # Includes .git directory contents
54 "$GIT_UNZIP" -l "$zip_path" | grep ".git/" &&
55
56 "$GIT_UNZIP" -p "$zip_path" .git/HEAD >out &&
57 test_file_not_empty out
58 '
59
60 test_done