| 1 | # This file is sourced by init.sh, *before* its initialization.
|
|---|
| 2 |
|
|---|
| 3 | # This goes hand in hand with the "9>&2;" in tests/Makefile.am's
|
|---|
| 4 | # TESTS_ENVIRONMENT definition.
|
|---|
| 5 | stderr_fileno_=9
|
|---|
| 6 |
|
|---|
| 7 | # Map settings of "none" to the empty string.
|
|---|
| 8 | test _"$LOCALE_FR" = _none && LOCALE_FR=
|
|---|
| 9 | test _"$LOCALE_FR_UTF8" = _none && LOCALE_FR_UTF8=
|
|---|
| 10 |
|
|---|
| 11 | # Unset key environment variables.
|
|---|
| 12 | if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
|
|---|
| 13 | as_unset=unset
|
|---|
| 14 | else
|
|---|
| 15 | as_unset=false
|
|---|
| 16 | fi
|
|---|
| 17 |
|
|---|
| 18 | # Derive this list by searching for string literals as the first
|
|---|
| 19 | # argument to getenv:
|
|---|
| 20 | # git grep getenv|perl -nle '/\bgetenv *\("(.+?)"\)/ and print $1'|sort -u grep
|
|---|
| 21 | vars_='
|
|---|
| 22 | GREP_COLOR
|
|---|
| 23 | GREP_COLORS
|
|---|
| 24 | GREP_OPTIONS
|
|---|
| 25 | TERM
|
|---|
| 26 | '
|
|---|
| 27 | envvar_check_fail=0
|
|---|
| 28 | for v_ in $vars_
|
|---|
| 29 | do
|
|---|
| 30 | $as_unset $v_
|
|---|
| 31 | if eval test \"\${$v_+set}\" = set; then
|
|---|
| 32 | echo "$0: the $v_ environment variable is set --" \
|
|---|
| 33 | ' unset it and rerun this test' >&2
|
|---|
| 34 | envvar_check_fail=1
|
|---|
| 35 | fi
|
|---|
| 36 | done
|
|---|
| 37 |
|
|---|
| 38 | test "$envvar_check_fail" = 1 && fail_ "failed to unset the above envvars"
|
|---|
| 39 |
|
|---|
| 40 | require_timeout_()
|
|---|
| 41 | {
|
|---|
| 42 | ( timeout 10s true ) > /dev/null 2>&1 \
|
|---|
| 43 | || skip_ your system lacks the timeout program
|
|---|
| 44 | timeout 10s false; test $? = 1 \
|
|---|
| 45 | || skip_ your system has a non-GNU timeout program
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | require_pcre_()
|
|---|
| 49 | {
|
|---|
| 50 | echo . | grep -P . 2>err || skip_ no PCRE support
|
|---|
| 51 | compare /dev/null err || fail_ PCRE available, but stderr not empty.
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | # Some tests would fail without this particular locale.
|
|---|
| 55 | # If the locale is not available, just skip the test.
|
|---|
| 56 | require_en_utf8_locale_()
|
|---|
| 57 | {
|
|---|
| 58 | path_prepend_ .
|
|---|
| 59 | case $(get-mb-cur-max en_US.UTF-8) in
|
|---|
| 60 | [3456]) ;;
|
|---|
| 61 | *) skip_ 'en_US.UTF-8 locale not found' ;;
|
|---|
| 62 | esac
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | require_ru_RU_koi8_r()
|
|---|
| 66 | {
|
|---|
| 67 | path_prepend_ .
|
|---|
| 68 | case $(get-mb-cur-max ru_RU.KOI8-R) in
|
|---|
| 69 | 1) ;;
|
|---|
| 70 | *) skip_ 'ru_RU.KOI8-R locale not found' ;;
|
|---|
| 71 | esac
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | require_compiled_in_MB_support()
|
|---|
| 75 | {
|
|---|
| 76 | require_en_utf8_locale_
|
|---|
| 77 | printf 'é' | LC_ALL=en_US.UTF-8 grep '[[:lower:]]' \
|
|---|
| 78 | || skip_ this test requires MBS support
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | expensive_()
|
|---|
| 82 | {
|
|---|
| 83 | if test "$RUN_EXPENSIVE_TESTS" != yes; then
|
|---|
| 84 | skip_ 'expensive: disabled by default
|
|---|
| 85 | This test is relatively expensive, so it is disabled by default.
|
|---|
| 86 | To run it anyway, rerun make check with the RUN_EXPENSIVE_TESTS
|
|---|
| 87 | environment variable set to yes. E.g.,
|
|---|
| 88 |
|
|---|
| 89 | env RUN_EXPENSIVE_TESTS=yes make check
|
|---|
| 90 |
|
|---|
| 91 | or use the shortcut target of the toplevel Makefile,
|
|---|
| 92 |
|
|---|
| 93 | make check-expensive
|
|---|
| 94 | '
|
|---|
| 95 | fi
|
|---|
| 96 | }
|
|---|