]> git.ipfire.org Git - thirdparty/git.git/blob - t/t0092-diagnose.sh
The third batch
[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 'counts loose objects' '
32 test_commit A &&
33
34 # After committing, should have non-zero loose objects
35 git diagnose -o test-count -s 1 >out &&
36 zip_path=test-count/git-diagnostics-1.zip &&
37 "$GIT_UNZIP" -p "$zip_path" objects-local.txt >out &&
38 grep "^Total: [1-9][0-9]* loose objects" out
39 '
40
41 test_expect_success UNZIP '--mode=stats excludes .git dir contents' '
42 test_when_finished rm -rf report &&
43
44 git diagnose -o report -s test --mode=stats >out &&
45
46 # Includes pack quantity/size info
47 zip_path=report/git-diagnostics-test.zip &&
48 "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out &&
49 grep ".git/objects" out &&
50
51 # Does not include .git directory contents
52 ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/"
53 '
54
55 test_expect_success UNZIP '--mode=all includes .git dir contents' '
56 test_when_finished rm -rf report &&
57
58 git diagnose -o report -s test --mode=all >out &&
59
60 # Includes pack quantity/size info
61 zip_path=report/git-diagnostics-test.zip &&
62 "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out &&
63 grep ".git/objects" out &&
64
65 # Includes .git directory contents
66 "$GIT_UNZIP" -l "$zip_path" | grep ".git/" &&
67
68 "$GIT_UNZIP" -p "$zip_path" .git/HEAD >out &&
69 test_file_not_empty out
70 '
71
72 test_done