Raw
1 #!/bin/sh
2
3 test_description='git diagnose'
4
5 . ./test-lib.sh
6
7 test_expect_success UNZIP 'creates diagnostics zip archive' '
8 test_when_finished rm -rf report &&
9
10 git diagnose -o report -s test >out &&
11 test_grep "Available space" out &&
12
13 zip_path=report/git-diagnostics-test.zip &&
14 test_path_is_file "$zip_path" &&
15
16 # Check zipped archive content
17 "$GIT_UNZIP" -p "$zip_path" diagnostics.log >out &&
18 test_file_not_empty out &&
19
20 "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out &&
21 test_grep ".git/objects" out &&
22
23 "$GIT_UNZIP" -p "$zip_path" objects-local.txt >out &&
24 test_grep "^Total: [0-9][0-9]*" out &&
25
26 # Should not include .git directory contents by default
27 ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/"
28 '
29
30 test_expect_success UNZIP 'counts loose objects' '
31 test_commit A &&
32
33 # After committing, should have non-zero loose objects
34 git diagnose -o test-count -s 1 >out &&
35 zip_path=test-count/git-diagnostics-1.zip &&
36 "$GIT_UNZIP" -p "$zip_path" objects-local.txt >out &&
37 test_grep "^Total: [1-9][0-9]* loose objects" out
38 '
39
40 test_expect_success UNZIP '--mode=stats excludes .git dir contents' '
41 test_when_finished rm -rf report &&
42
43 git diagnose -o report -s test --mode=stats >out &&
44
45 # Includes pack quantity/size info
46 zip_path=report/git-diagnostics-test.zip &&
47 "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out &&
48 test_grep ".git/objects" out &&
49
50 # Does not include .git directory contents
51 ! "$GIT_UNZIP" -l "$zip_path" | grep ".git/"
52 '
53
54 test_expect_success UNZIP '--mode=all includes .git dir contents' '
55 test_when_finished rm -rf report &&
56
57 git diagnose -o report -s test --mode=all >out &&
58
59 # Includes pack quantity/size info
60 zip_path=report/git-diagnostics-test.zip &&
61 "$GIT_UNZIP" -p "$zip_path" packs-local.txt >out &&
62 test_grep ".git/objects" out &&
63
64 # Includes .git directory contents
65 "$GIT_UNZIP" -l "$zip_path" | grep ".git/" &&
66
67 "$GIT_UNZIP" -p "$zip_path" .git/HEAD >out &&
68 test_file_not_empty out
69 '
70
71 test_done