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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
|
From 5646bc3b9f2d43b6eec2bd62042718a0b810cab2 Mon Sep 17 00:00:00 2001
From: Boris Staletic <boris.staletic@protonmail.com>
Date: Thu, 12 Dec 2024 22:45:08 +0100
Subject: [PATCH] Correct where WithRetry decorator is applied
A TestCase.subTest() context manager will swallow exceptions, so
applying @WithRetry on the entire test does not work.
Instead, it needs to be applied on whatever the subTest is doing.
---
ycmd/tests/clangd/subcommands_test.py | 5 ++-
ycmd/tests/java/subcommands_test.py | 49 +++++++++++----------------
ycmd/tests/rust/subcommands_test.py | 5 +--
3 files changed, 23 insertions(+), 36 deletions(-)
diff --git a/ycmd/tests/clangd/subcommands_test.py b/ycmd/tests/clangd/subcommands_test.py
index 34bb8742..5920a509 100644
--- a/ycmd/tests/clangd/subcommands_test.py
+++ b/ycmd/tests/clangd/subcommands_test.py
@@ -543,6 +543,7 @@ def FixIt_Check_AutoExpand_Resolved( results ):
} ) )
+@WithRetry()
def RunRangedFixItTest( app, rng, expected, chosen_fixit = 0 ):
contents = ReadFile( PathToTestFile( 'FixIt_Clang_cpp11.cpp' ) )
args = {
@@ -616,7 +617,6 @@ class SubcommandsTest( TestCase ):
} )
- @WithRetry()
@SharedYcmd
def test_Subcommands_ServerNotInitialized( self, app ):
for cmd in [
@@ -646,6 +646,7 @@ class SubcommandsTest( TestCase ):
with self.subTest( cmd = cmd ):
completer = handlers._server_state.GetFiletypeCompleter( [ 'cpp' ] )
+ @WithRetry()
@patch.object( completer, '_ServerIsInitialized', return_value = False )
def Test( app, cmd, *args ):
request = {
@@ -1177,7 +1178,6 @@ class SubcommandsTest( TestCase ):
RunFixItTest( app, line, column, language, filepath, check )
- @WithRetry()
@SharedYcmd
def test_Subcommands_FixIt_Ranged( self, app ):
for test in [
@@ -1237,7 +1237,6 @@ class SubcommandsTest( TestCase ):
assert_that( actual, equal_to( expected ) )
- @WithRetry()
@IsolatedYcmd( { 'clangd_args': [ '-hidden-features' ] } )
def test_Subcommands_FixIt_ClangdTweaks( self, app ):
selection = {
diff --git a/ycmd/tests/java/subcommands_test.py b/ycmd/tests/java/subcommands_test.py
index f47be8e2..4b124f7d 100644
--- a/ycmd/tests/java/subcommands_test.py
+++ b/ycmd/tests/java/subcommands_test.py
@@ -155,6 +155,7 @@ def RunHierarchyTest( app, kind, direction, location, expected, code ):
RunTest( app, test )
+@WithRetry()
def RunFixItTest( app,
description,
filepath,
@@ -679,7 +680,6 @@ class SubcommandsTest( TestCase ):
'Cannot jump to location' ) )
- @WithRetry()
@IsolatedYcmd( {
'extra_conf_globlist': PathToTestFile( 'multiple_projects', '*' )
} )
@@ -722,14 +722,11 @@ class SubcommandsTest( TestCase ):
'com',
'test',
'TestWidgetImpl.java' )
- for desc, request, expect in [
+ for desc, filepath, line, column, expect in [
( 'GoToReferences works across multiple projects',
- {
- 'command': 'GoToReferences',
- 'filepath': utils_java,
- 'line_num': 5,
- 'column_num': 22,
- },
+ utils_java,
+ 5,
+ 22,
{
'response': requests.codes.ok,
'data': contains_inanyorder(
@@ -739,12 +736,9 @@ class SubcommandsTest( TestCase ):
)
} ),
( 'GoToReferences works in an unrelated project at the same time',
- {
- 'command': 'GoToReferences',
- 'filepath': abstract_test_widget,
- 'line_num': 10,
- 'column_num': 15,
- },
+ abstract_test_widget,
+ 10,
+ 15,
{
'response': requests.codes.ok,
'data': contains_inanyorder(
@@ -755,16 +749,20 @@ class SubcommandsTest( TestCase ):
)
} ),
]:
- with self.subTest( desc = desc, request = request, expect = expect ):
- filepath = request[ 'filepath' ]
+ with self.subTest( desc = desc,
+ filepath = filepath,
+ line = line,
+ column = column,
+ expect = expect ):
StartJavaCompleterServerWithFile( app, filepath )
-
- RunTest( app, {
- 'description': desc,
- 'request': request,
- 'expect': expect
- } )
+ RunGoToTest( app,
+ desc,
+ filepath,
+ line,
+ column,
+ 'GoToReferences',
+ expect )
@WithRetry()
@@ -1102,7 +1100,6 @@ class SubcommandsTest( TestCase ):
- @WithRetry()
@SharedYcmd
def test_Subcommands_FixIt_SingleDiag_MultipleOption_Insertion( self, app ):
import os
@@ -1259,7 +1256,6 @@ class SubcommandsTest( TestCase ):
RunFixItTest( app, description, filepath, 19, column, fixits_for_line )
- @WithRetry()
@SharedYcmd
def test_Subcommands_FixIt_SingleDiag_SingleOption_Modify( self, app ):
filepath = PathToTestFile( 'simple_eclipse_project',
@@ -1327,7 +1323,6 @@ class SubcommandsTest( TestCase ):
filepath, 27, 12, fixits )
- @WithRetry()
@SharedYcmd
def test_Subcommands_FixIt_SingleDiag_MultiOption_Delete( self, app ):
filepath = PathToTestFile( 'simple_eclipse_project',
@@ -1404,7 +1399,6 @@ class SubcommandsTest( TestCase ):
filepath, 15, 29, fixits )
- @WithRetry()
@SharedYcmd
def test_Subcommands_FixIt_MultipleDiags( self, app ):
for description, column, expect_fixits in [
@@ -1626,7 +1620,6 @@ class SubcommandsTest( TestCase ):
)
- @WithRetry()
@SharedYcmd
def test_Subcommands_FixIt_NoDiagnostics( self, app ):
filepath = PathToTestFile( 'simple_eclipse_project',
@@ -1652,7 +1645,6 @@ class SubcommandsTest( TestCase ):
'chunks': instance_of( list ) } ) ) } ) )
- @WithRetry()
@SharedYcmd
def test_Subcommands_FixIt_Unicode( self, app ):
fixits = has_entries( {
@@ -1720,7 +1712,6 @@ class SubcommandsTest( TestCase ):
TEST_JAVA, 13, 1, fixits )
- @WithRetry()
@IsolatedYcmd()
def test_Subcommands_FixIt_InvalidURI( self, app ):
filepath = PathToTestFile( 'simple_eclipse_project',
diff --git a/ycmd/tests/rust/subcommands_test.py b/ycmd/tests/rust/subcommands_test.py
index 3a5d0118..3b422a18 100644
--- a/ycmd/tests/rust/subcommands_test.py
+++ b/ycmd/tests/rust/subcommands_test.py
@@ -138,6 +138,7 @@ def RunHierarchyTest( app, kind, direction, location, expected, code ):
RunTest( app, test )
+@WithRetry()
def RunGoToTest( app, command, test, *, project_root = 'common' ):
folder = PathToTestFile( project_root, 'src' )
filepath = os.path.join( folder, test[ 'req' ][ 0 ] )
@@ -423,7 +424,6 @@ class SubcommandsTest( TestCase ):
RunGoToTest( app, 'GoToType', test )
- @WithRetry()
@SharedYcmd
def test_Subcommands_GoTo( self, app ):
for test, command in itertools.product(
@@ -442,7 +442,6 @@ class SubcommandsTest( TestCase ):
RunGoToTest( app, command, test )
- @WithRetry()
@SharedYcmd
def test_Subcommands_GoToImplementation( self, app ):
for test in [
@@ -456,7 +455,6 @@ class SubcommandsTest( TestCase ):
RunGoToTest( app, 'GoToImplementation', test )
- @WithRetry()
@SharedYcmd
def test_Subcommands_GoToImplementation_Failure( self, app ):
RunGoToTest( app,
@@ -587,7 +585,6 @@ class SubcommandsTest( TestCase ):
} )
- @WithRetry()
@IsolatedYcmd()
def test_Subcommands_GoTo_WorksAfterChangingProject( self, app ):
filepath = PathToTestFile( 'macro', 'src', 'main.rs' )
--
2.45.2
|