File: run_vim_tests

package info (click to toggle)
vim-youcompleteme 0%2B20230109%2Bgit7620d87%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,404 kB
  • sloc: python: 10,569; sh: 203; cpp: 121; makefile: 24; f90: 5; xml: 1
file content (126 lines) | stat: -rwxr-xr-x 2,668 bytes parent folder | download
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env bash

if [ "$1" == "--help" ]; then
  echo "$(basename $0) <optional list of tests in form file:func>"
  echo "e.g.: "
  echo " - run all tests: $0"
  echo " - run specific tests script: $0 signature_help.test.vim"
  echo " - run specific tests fun: $0 signature_help.test.vim:Test_signatures_TopLine\(\)"
  exit 0
fi

VIM=vim
RETRY=0
SKIP=','

while [ -n "$1" ]; do
  case "$1" in
  '--stdout') export YCM_TEST_STDOUT=1;;
  '--vim') VIM="$2"; shift;;
  '--retry') RETRY=$2; shift;;
  '--skip') SKIP="${SKIP}${2},"; shift;;
  *) break;;
  esac
  shift
done

RUN_VIM="${VIM} --clean --not-a-term"
RUN_TEST="${RUN_VIM} -S lib/run_test.vim"

pushd $(dirname $0) > /dev/null

echo "Running YouCompleteMe Vim tests"

RESULT=0

TESTS="$@"

if [ -z "$TESTS" ]; then
  TESTS=*.test.vim
fi

for t in ${TESTS}; do
  echo ""
  echo "%RUN: $t"

  if [ "${SKIP#*${t}}" != "$SKIP" ]; then
    echo '%SKIP: Requested via command line'
    continue
  fi

  # split on : into fileName and testName
  IFS=: read -s t T <<< "$t"

  if [ -n "${AUTOPKGTEST_ARTIFACTS}" ]; then
    TESTLOGDIR="${AUTOPKGTEST_ARTIFACTS}/$t"
  else
    TESTLOGDIR="$(pwd)/logs/$t"
  fi
  rm -rf "$TESTLOGDIR"

  RESULT_RUN=0
  for RETRY_RUN in $(seq 0 $RETRY); do
    TESTLOGDIR_RUN="$TESTLOGDIR"
    if [ $RETRY != 0 ]; then
      TESTLOGDIR_RUN="${TESTLOGDIR_RUN}/${RETRY_RUN}"
    fi
    if ${RUN_TEST} --cmd 'au SwapExists * let v:swapchoice = "e"' $t $T \
       && [ -f $t.res ];  then
      echo -n "%PASS: $t PASSED"
      RESULT_RUN=0
    else
      echo -n "%FAIL: $t FAILED - see $TESTLOGDIR_RUN"
      RESULT_RUN=1
    fi

    if [ $RETRY = 0 ]; then
      echo
    else
      echo " (try: ${RETRY_RUN}/${RETRY})"
    fi

    mkdir -p "$TESTLOGDIR_RUN"
    ${RUN_VIM} --version > "${TESTLOGDIR_RUN}/vimversion"
    for l in messages debuglog test.log *.testlog; do
      # In CI we can't view the output files, so we just have to cat them
      if [ -f "$l" ]; then
        if [ "$YCM_TEST_STDOUT" ]; then
          echo ""
          echo ""
          echo "*** START: $l ***"
          cat "$l"
          echo "*** END: $l ***"
        fi
        mv "$l" "$TESTLOGDIR_RUN"
      fi
    done

    if [ $RESULT_RUN = 0 ]; then
       break
    fi
  done
  RESULT=$(($RESULT + $RESULT_RUN))

  if [ -n "${COVERAGE}" ]; then
    covimerage write_coverage --append \
                              --source $(pwd)/.. \
                              --data-file .coverage.vim \
                              .vim_profile
  fi

  rm -f $t.res
done

echo "Done running tests"

if [ -n "${COVERAGE}" ]; then
  mv .coverage.* ../
fi

popd > /dev/null

echo ""
echo "All done."


exit $RESULT