t / perf / p7820-grep-engines.shon commit Merge branch 'ma/bisect-leakfix' into maint (03e8004)
   1#!/bin/sh
   2
   3test_description="Comparison of git-grep's regex engines
   4
   5Set GIT_PERF_7820_GREP_OPTS in the environment to pass options to
   6git-grep. Make sure to include a leading space,
   7e.g. GIT_PERF_7820_GREP_OPTS=' -i'. Some options to try:
   8
   9        -i
  10        -w
  11        -v
  12        -vi
  13        -vw
  14        -viw
  15"
  16
  17. ./perf-lib.sh
  18
  19test_perf_large_repo
  20test_checkout_worktree
  21
  22for pattern in \
  23        'how.to' \
  24        '^how to' \
  25        '[how] to' \
  26        '\(e.t[^ ]*\|v.ry\) rare' \
  27        'm\(ú\|u\)lt.b\(æ\|y\)te'
  28do
  29        for engine in basic extended perl
  30        do
  31                if test $engine != "basic"
  32                then
  33                        # Poor man's basic -> extended converter.
  34                        pattern=$(echo "$pattern" | sed 's/\\//g')
  35                fi
  36                if test $engine = "perl" && ! test_have_prereq PCRE
  37                then
  38                        prereq="PCRE"
  39                else
  40                        prereq=""
  41                fi
  42                test_perf $prereq "$engine grep$GIT_PERF_7820_GREP_OPTS '$pattern'" "
  43                        git -c grep.patternType=$engine grep$GIT_PERF_7820_GREP_OPTS -- '$pattern' >'out.$engine' || :
  44                "
  45        done
  46
  47        test_expect_success "assert that all engines found the same for$GIT_PERF_7820_GREP_OPTS '$pattern'" '
  48                test_cmp out.basic out.extended &&
  49                if test_have_prereq PCRE
  50                then
  51                        test_cmp out.basic out.perl
  52                fi
  53        '
  54done
  55
  56test_done