File: 02-allow-to-retry-failed-test-runs.patch

package info (click to toggle)
vim-youcompleteme 0%2B20240827%2Bgitb6e8c64%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,436 kB
  • sloc: python: 10,914; sh: 204; cpp: 141; makefile: 26; f90: 5; xml: 1
file content (113 lines) | stat: -rw-r--r-- 3,176 bytes parent folder | download | duplicates (3)
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
Description: Allow retrying failed vim tests automatically
 The vim tests are somewhat sensitive to timing, so if the machine isn't
 the fastest or does other things concurrently it can happen that the
 timing in the tests fail to match reality.
 .
 Ideally the tests would not be sensitive to timing issues, but that is
 a bigger and more involved problem to solve for upstream. So as a tiny
 downstream we just cop out here and allow the tests to be retried a
 bunch of times likely hitting the 'PASS' jackpot in a retry.
Author: David Kalnischkies <donkult@debian.org>
Forwarded: no

--- a/test/run_vim_tests
+++ b/test/run_vim_tests
@@ -7,17 +7,20 @@
   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
-elif [ "$1" == "--stdout" ]; then
-  export YCM_TEST_STDOUT=1
-  shift
 fi
 
 VIM=vim
-if [ "$1" == "--vim" ]; then
-  VIM=$2
-  shift
+RETRY=0
+
+while [ -n "$1" ]; do
+  case "$1" in
+  '--stdout') export YCM_TEST_STDOUT=1;;
+  '--vim') VIM="$2"; shift;;
+  '--retry') RETRY=$2; shift;;
+  *) break;;
+  esac
   shift
-fi
+done
 
 RUN_VIM="${VIM} --clean --not-a-term"
 RUN_TEST="${RUN_VIM} -S lib/run_test.vim"
@@ -46,31 +49,50 @@
   else
     TESTLOGDIR="$(pwd)/logs/$t"
   fi
+  rm -rf "$TESTLOGDIR"
 
-  if ${RUN_TEST} --cmd 'au SwapExists * let v:swapchoice = "e"' $t $T \
-     && [ -f $t.res ];  then
-    echo "%PASS: $t PASSED"
-  else
-    echo "%FAIL: $t FAILED - see $TESTLOGDIR"
-    RESULT=1
-  fi
+  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
 
-  rm -rf $TESTLOGDIR
-  mkdir -p $TESTLOGDIR
-  ${RUN_VIM} --version > ${TESTLOGDIR}/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 ***"
+    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
-      mv $l $TESTLOGDIR
+    done
+
+    if [ $RESULT_RUN = 0 ]; then
+       break
     fi
   done
+  RESULT=$(($RESULT + $RESULT_RUN))
 
   if [ -n "${COVERAGE}" ]; then
     covimerage write_coverage --append \