@@ -54,9 +54,12 @@ def GetCompletions_Basic_test( app ):
54
54
CompletionEntryMatcher ( 'build_shuttle' ) ) )
55
55
56
56
57
- @SharedYcmd
57
+ @IsolatedYcmd ()
58
+ @patch ( 'ycmd.completers.rust.rust_completer._GetRustSysroot' ,
59
+ return_value = '/non/existing/rust/src/path' )
58
60
def GetCompletions_WhenStandardLibraryCompletionFails_MentionRustSrcPath_test (
59
- app ):
61
+ app , * args ):
62
+ WaitUntilCompleterServerReady ( app , 'rust' )
60
63
filepath = PathToTestFile ( 'std_completions.rs' )
61
64
contents = ReadFile ( filepath )
62
65
@@ -74,8 +77,11 @@ def GetCompletions_WhenStandardLibraryCompletionFails_MentionRustSrcPath_test(
74
77
ErrorMatcher ( RuntimeError , ERROR_FROM_RACERD_MESSAGE ) )
75
78
76
79
77
- @SharedYcmd
78
- def GetCompletions_WhenNoCompletionsFound_MentionRustSrcPath_test ( app ):
80
+ @IsolatedYcmd ()
81
+ @patch ( 'ycmd.completers.rust.rust_completer._GetRustSysroot' ,
82
+ return_value = '/non/existing/rust/src/path' )
83
+ def GetCompletions_WhenNoCompletionsFound_MentionRustSrcPath_test ( app , * args ):
84
+ WaitUntilCompleterServerReady ( app , 'rust' )
79
85
filepath = PathToTestFile ( 'test.rs' )
80
86
contents = ReadFile ( filepath )
81
87
@@ -132,3 +138,41 @@ def GetCompletions_NonExistingRustSrcPathFromEnvironmentVariable_test( app ):
132
138
assert_that ( response ,
133
139
ErrorMatcher ( RuntimeError ,
134
140
NON_EXISTING_RUST_SOURCES_PATH_MESSAGE ) )
141
+
142
+
143
+ @IsolatedYcmd ()
144
+ @patch ( 'ycmd.completers.rust.rust_completer.FindExecutable' ,
145
+ return_value = None )
146
+ def GetCompletions_WhenRustcNotFound_MentionRustSrcPath_test ( app , * args ):
147
+ WaitUntilCompleterServerReady ( app , 'rust' )
148
+ filepath = PathToTestFile ( 'test.rs' )
149
+ contents = ReadFile ( filepath )
150
+
151
+ completion_data = BuildRequest ( filepath = filepath ,
152
+ filetype = 'rust' ,
153
+ contents = contents ,
154
+ force_semantic = True ,
155
+ line_num = 1 ,
156
+ column_num = 1 )
157
+
158
+ response = app .post_json ( '/completions' ,
159
+ completion_data ,
160
+ expect_errors = True ).json
161
+ assert_that ( response ,
162
+ ErrorMatcher ( RuntimeError , ERROR_FROM_RACERD_MESSAGE ) )
163
+
164
+
165
+ @IsolatedYcmd ()
166
+ @patch ( 'ycmd.completers.rust.rust_completer._GetRustSysroot' ,
167
+ return_value = PathToTestFile ( 'rustup-toolchain' ) )
168
+ def GetCompletions_RustupPathHeuristics_test ( app , * args ):
169
+ request_data = BuildRequest ( filetype = 'rust' )
170
+
171
+ assert_that ( app .post_json ( '/debug_info' , request_data ).json ,
172
+ has_entry ( 'completer' , has_entry ( 'items' , has_items (
173
+ has_entry ( 'value' , PathToTestFile ( 'rustup-toolchain' ,
174
+ 'lib' ,
175
+ 'rustlib' ,
176
+ 'src' ,
177
+ 'rust' ,
178
+ 'src' ) ) ) ) ) )
0 commit comments