summaryrefslogtreecommitdiff
path: root/tests/init.cfg
blob: e04d90f210b48d4000e58a28adf769edfd9a1828 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# This file is sourced by init.sh, *before* its initialization.

# This goes hand in hand with the "9>&2;" in tests/Makefile.am's
# TESTS_ENVIRONMENT definition.
stderr_fileno_=9

# Map settings of "none" to the empty string.
test _"$LOCALE_FR" = _none && LOCALE_FR=
test _"$LOCALE_FR_UTF8" = _none && LOCALE_FR_UTF8=

# Unset key environment variables.
if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
  as_unset=unset
else
  as_unset=false
fi

# Derive this list by searching for string literals as the first
# argument to getenv:
# git grep getenv|perl -nle '/\bgetenv *\("(.+?)"\)/ and print $1'|sort -u grep
vars_='
GREP_COLOR
GREP_COLORS
GREP_OPTIONS
TERM
'
envvar_check_fail=0
for v_ in $vars_
do
  $as_unset $v_
  if eval test \"\${$v_+set}\" = set; then
    echo "$0: the $v_ environment variable is set --" \
      ' unset it and rerun this test' >&2
    envvar_check_fail=1
  fi
done

test "$envvar_check_fail" = 1 && fail_ "failed to unset the above envvars"

require_timeout_()
{
  ( timeout 10s true ) > /dev/null 2>&1 \
    || skip_ your system lacks the timeout program
  timeout 10s false; test $? = 1 \
    || skip_ your system has a non-GNU timeout program
}

require_pcre_()
{
  echo . | grep -P . 2>err || skip_ no PCRE support
  compare err /dev/null || fail_ PCRE available, but stderr not empty.
}

# Some tests would fail without this particular locale.
# If the locale is not available, just skip the test.
require_en_utf8_locale_()
{
  path_prepend_ .
  case $(get-mb-cur-max en_US.UTF-8) in
    [3456]) ;;
    *) skip_ 'en_US.UTF-8 locale not found' ;;
  esac
}

require_ru_RU_koi8_r()
{
  path_prepend_ .
  case $(get-mb-cur-max ru_RU.KOI8-R) in
    1) ;;
    *) skip_ 'ru_RU.KOI8-R locale not found' ;;
  esac
}

require_compiled_in_MB_support()
{
  require_en_utf8_locale_
  printf 'é' | LC_ALL=en_US.UTF-8 grep '[[:lower:]]' \
    || skip_ this test requires MBS support
}