dir: report number of visited directories and paths with trace2
[git] / t / t9003-help-autocorrect.sh
1 #!/bin/sh
2
3 test_description='help.autocorrect finding a match'
4 . ./test-lib.sh
5
6 test_expect_success 'setup' '
7         # An alias
8         git config alias.lgf "log --format=%s --first-parent" &&
9
10         # A random user-defined command
11         write_script git-distimdistim <<-EOF &&
12                 echo distimdistim was called
13         EOF
14
15         PATH="$PATH:." &&
16         export PATH &&
17
18         git commit --allow-empty -m "a single log entry" &&
19
20         # Sanity check
21         git lgf >actual &&
22         echo "a single log entry" >expect &&
23         test_cmp expect actual &&
24
25         git distimdistim >actual &&
26         echo "distimdistim was called" >expect &&
27         test_cmp expect actual
28 '
29
30 test_expect_success 'autocorrect showing candidates' '
31         git config help.autocorrect 0 &&
32
33         test_must_fail git lfg 2>actual &&
34         grep "^ lgf" actual &&
35
36         test_must_fail git distimdist 2>actual &&
37         grep "^ distimdistim" actual
38 '
39
40 for immediate in -1 immediate
41 do
42         test_expect_success 'autocorrect running commands' '
43                 git config help.autocorrect $immediate &&
44
45                 git lfg >actual &&
46                 echo "a single log entry" >expect &&
47                 test_cmp expect actual &&
48
49                 git distimdist >actual &&
50                 echo "distimdistim was called" >expect &&
51                 test_cmp expect actual
52         '
53 done
54
55 test_expect_success 'autocorrect can be declined altogether' '
56         git config help.autocorrect never &&
57
58         test_must_fail git lfg 2>actual &&
59         grep "is not a git command" actual &&
60         test_line_count = 1 actual
61 '
62
63 test_done