3 test_description
='git diagnose'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success UNZIP
'creates diagnostics zip archive' '
9 test_when_finished rm -rf report &&
11 git diagnose -o report -s test >out &&
12 grep "Available space" out &&
14 zip_path=report/git-diagnostics-test.zip &&
15 test_path_is_file "$zip_path" &&
17 # Check zipped archive content
18 "$GIT_UNZIP" -p "$zip_path" diagnostics.log >out &&
19 test_file_not_empty out &&
21 "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out &&
22 grep ".git/objects" out &&
24 "$GIT_UNZIP" -p "$zip_path" objects-local.txt >out &&
25 grep "^Total: [0-9][0-9]*" out &&
27 # Should not include .git directory contents by default
28 ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/"
31 test_expect_success UNZIP
'counts loose objects' '
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
41 test_expect_success UNZIP
'--mode=stats excludes .git dir contents' '
42 test_when_finished rm -rf report &&
44 git diagnose -o report -s test --mode=stats >out &&
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 &&
51 # Does not include .git directory contents
52 ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/"
55 test_expect_success UNZIP
'--mode=all includes .git dir contents' '
56 test_when_finished rm -rf report &&
58 git diagnose -o report -s test --mode=all >out &&
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 &&
65 # Includes .git directory contents
66 "$GIT_UNZIP" -l "$zip_path" | grep ".git/" &&
68 "$GIT_UNZIP" -p "$zip_path" .git/HEAD >out &&
69 test_file_not_empty out