#!/bin/sh global test_description := ''help.autocorrect finding a match'' source ./test-lib.sh test_expect_success 'setup' ' # An alias git config alias.lgf "log --format=%s --first-parent" && # A random user-defined command write_script git-distimdistim <<-EOF && echo distimdistim was called EOF PATH="$PATH:." && export PATH && git commit --allow-empty -m "a single log entry" && # Sanity check git lgf >actual && echo "a single log entry" >expect && test_cmp expect actual && git distimdistim >actual && echo "distimdistim was called" >expect && test_cmp expect actual ' test_expect_success 'autocorrect showing candidates' ' git config help.autocorrect 0 && test_must_fail git lfg 2>actual && grep "^ lgf" actual && test_must_fail git distimdist 2>actual && grep "^ distimdistim" actual ' test_expect_success 'autocorrect running commands' ' git config help.autocorrect -1 && git lfg >actual && echo "a single log entry" >expect && test_cmp expect actual && git distimdist >actual && echo "distimdistim was called" >expect && test_cmp expect actual ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"help.autocorrect finding a match">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\t# An alias\n"> <"\tgit config alias.lgf \"log --format=%s --first-parent\" &&\n"> <"\n"> <"\t# A random user-defined command\n"> <"\twrite_script git-distimdistim <<-EOF &&\n"> <"\t\techo distimdistim was called\n"> <"\tEOF\n"> <"\n"> <"\tPATH=\"$PATH:.\" &&\n"> <"\texport PATH &&\n"> <"\n"> <"\tgit commit --allow-empty -m \"a single log entry\" &&\n"> <"\n"> <"\t# Sanity check\n"> <"\tgit lgf >actual &&\n"> <"\techo \"a single log entry\" >expect &&\n"> <"\ttest_cmp expect actual &&\n"> <"\n"> <"\tgit distimdistim >actual &&\n"> <"\techo \"distimdistim was called\" >expect &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"autocorrect showing candidates">)} { (SQ <"\n"> <"\tgit config help.autocorrect 0 &&\n"> <"\n"> <"\ttest_must_fail git lfg 2>actual &&\n"> <"\tgrep \"^\tlgf\" actual &&\n"> <"\n"> <"\ttest_must_fail git distimdist 2>actual &&\n"> <"\tgrep \"^\tdistimdistim\" actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"autocorrect running commands">)} { (SQ <"\n"> <"\tgit config help.autocorrect -1 &&\n"> <"\n"> <"\tgit lfg >actual &&\n"> <"\techo \"a single log entry\" >expect &&\n"> <"\ttest_cmp expect actual &&\n"> <"\n"> <"\tgit distimdist >actual &&\n"> <"\techo \"distimdistim was called\" >expect &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_done)}) ] )