@@ -1175,7 +1175,11 @@ pub mod test {
1175
1175
impl TooltipTestHarness {
1176
1176
/// Creates a new `TooltipTestHarness`. The `project_dir` must contain
1177
1177
/// a valid rust project with a `Cargo.toml`.
1178
- pub fn new < O : Output > ( project_dir : PathBuf , output : & O ) -> TooltipTestHarness {
1178
+ pub fn new < O : Output > (
1179
+ project_dir : PathBuf ,
1180
+ output : & O ,
1181
+ racer_fallback_completion : bool ,
1182
+ ) -> TooltipTestHarness {
1179
1183
use env_logger;
1180
1184
let _ = env_logger:: try_init ( ) ;
1181
1185
@@ -1194,6 +1198,7 @@ pub mod test {
1194
1198
1195
1199
let temp_dir = tempfile:: tempdir ( ) . unwrap ( ) . into_path ( ) ;
1196
1200
config. target_dir = config:: Inferrable :: Specified ( Some ( temp_dir. clone ( ) ) ) ;
1201
+ config. racer_completion = racer_fallback_completion;
1197
1202
1198
1203
let config = Arc :: new ( Mutex :: new ( config) ) ;
1199
1204
let analysis = Arc :: new ( analysis:: AnalysisHost :: new ( analysis:: Target :: Debug ) ) ;
@@ -2082,7 +2087,6 @@ pub mod test {
2082
2087
Test :: new( "test_tooltip_01.rs" , 68 , 11 ) ,
2083
2088
Test :: new( "test_tooltip_01.rs" , 68 , 26 ) ,
2084
2089
Test :: new( "test_tooltip_01.rs" , 75 , 10 ) ,
2085
- Test :: new( "test_tooltip_01.rs" , 80 , 11 ) ,
2086
2090
Test :: new( "test_tooltip_01.rs" , 85 , 14 ) ,
2087
2091
Test :: new( "test_tooltip_01.rs" , 85 , 50 ) ,
2088
2092
Test :: new( "test_tooltip_01.rs" , 85 , 54 ) ,
@@ -2091,7 +2095,6 @@ pub mod test {
2091
2095
Test :: new( "test_tooltip_01.rs" , 87 , 20 ) ,
2092
2096
Test :: new( "test_tooltip_01.rs" , 88 , 18 ) ,
2093
2097
Test :: new( "test_tooltip_01.rs" , 93 , 11 ) ,
2094
- Test :: new( "test_tooltip_01.rs" , 93 , 18 ) ,
2095
2098
Test :: new( "test_tooltip_01.rs" , 95 , 25 ) ,
2096
2099
Test :: new( "test_tooltip_01.rs" , 109 , 21 ) ,
2097
2100
Test :: new( "test_tooltip_01.rs" , 113 , 21 ) ,
@@ -2100,7 +2103,38 @@ pub mod test {
2100
2103
Test :: new( "test_tooltip_mod_use.rs" , 12 , 14 ) ,
2101
2104
Test :: new( "test_tooltip_mod_use.rs" , 12 , 25 ) ,
2102
2105
Test :: new( "test_tooltip_mod_use.rs" , 13 , 28 ) ,
2103
- Test :: new( "test_tooltip_mod_use_external.rs" , 11 , 7 ) ,
2106
+ ] ;
2107
+
2108
+ let out = LineOutput :: default ( ) ;
2109
+ let proj_dir = FIXTURES_DIR . join ( "hover" ) ;
2110
+
2111
+ let save_dir_guard = tempfile:: tempdir ( ) . unwrap ( ) ;
2112
+ let save_dir = save_dir_guard. path ( ) . to_owned ( ) ;
2113
+ let load_dir = proj_dir. join ( "save_data" ) ;
2114
+
2115
+ let harness = TooltipTestHarness :: new ( proj_dir, & out, false ) ;
2116
+
2117
+ out. reset ( ) ;
2118
+
2119
+ let failures = harness. run_tests ( & tests, load_dir, save_dir) ?;
2120
+
2121
+ if failures. is_empty ( ) {
2122
+ Ok ( ( ) )
2123
+ } else {
2124
+ eprintln ! ( "{}\n \n " , out. reset( ) . join( "\n " ) ) ;
2125
+ eprintln ! ( "Failures (\x1b [91mexpected\x1b [92mactual\x1b [0m): {:#?}\n \n " , failures) ;
2126
+ Err ( format ! ( "{} of {} tooltip tests failed" , failures. len( ) , tests. len( ) ) . into ( ) )
2127
+ }
2128
+ }
2129
+
2130
+ #[ test]
2131
+ fn test_tooltip_racer ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
2132
+ let _ = env_logger:: try_init ( ) ;
2133
+ use self :: test:: { LineOutput , Test , TooltipTestHarness } ;
2134
+
2135
+ let tests = vec ! [
2136
+ Test :: new( "test_tooltip_01.rs" , 80 , 11 ) ,
2137
+ Test :: new( "test_tooltip_01.rs" , 93 , 18 ) ,
2104
2138
Test :: new( "test_tooltip_mod_use_external.rs" , 11 , 7 ) ,
2105
2139
Test :: new( "test_tooltip_mod_use_external.rs" , 12 , 7 ) ,
2106
2140
Test :: new( "test_tooltip_mod_use_external.rs" , 12 , 12 ) ,
@@ -2113,7 +2147,7 @@ pub mod test {
2113
2147
let save_dir = save_dir_guard. path ( ) . to_owned ( ) ;
2114
2148
let load_dir = proj_dir. join ( "save_data" ) ;
2115
2149
2116
- let harness = TooltipTestHarness :: new ( proj_dir, & out) ;
2150
+ let harness = TooltipTestHarness :: new ( proj_dir, & out, true ) ;
2117
2151
2118
2152
out. reset ( ) ;
2119
2153
@@ -2138,10 +2172,6 @@ pub mod test {
2138
2172
use self :: test:: { LineOutput , Test , TooltipTestHarness } ;
2139
2173
2140
2174
let tests = vec ! [
2141
- // these test std stuff
2142
- Test :: new( "test_tooltip_mod_use_external.rs" , 14 , 12 ) ,
2143
- Test :: new( "test_tooltip_mod_use_external.rs" , 15 , 12 ) ,
2144
-
2145
2175
Test :: new( "test_tooltip_std.rs" , 18 , 15 ) ,
2146
2176
Test :: new( "test_tooltip_std.rs" , 18 , 27 ) ,
2147
2177
Test :: new( "test_tooltip_std.rs" , 19 , 7 ) ,
@@ -2164,7 +2194,44 @@ pub mod test {
2164
2194
let save_dir = save_dir_guard. path ( ) . to_owned ( ) ;
2165
2195
let load_dir = proj_dir. join ( "save_data" ) ;
2166
2196
2167
- let harness = TooltipTestHarness :: new ( proj_dir, & out) ;
2197
+ let harness = TooltipTestHarness :: new ( proj_dir, & out, false ) ;
2198
+
2199
+ out. reset ( ) ;
2200
+
2201
+ let failures = harness. run_tests ( & tests, load_dir, save_dir) ?;
2202
+
2203
+ if failures. is_empty ( ) {
2204
+ Ok ( ( ) )
2205
+ } else {
2206
+ eprintln ! ( "{}\n \n " , out. reset( ) . join( "\n " ) ) ;
2207
+ eprintln ! ( "Failures (\x1b [91mexpected\x1b [92mactual\x1b [0m): {:#?}\n \n " , failures) ;
2208
+ Err ( format ! ( "{} of {} tooltip tests failed" , failures. len( ) , tests. len( ) ) . into ( ) )
2209
+ }
2210
+ }
2211
+
2212
+ /// Note: This test is ignored as it doesn't work in the rust-lang/rust repo.
2213
+ /// It is enabled on CI.
2214
+ /// Run with `cargo test test_tooltip_std -- --ignored`
2215
+ #[ test]
2216
+ #[ ignore]
2217
+ fn test_tooltip_std_racer ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
2218
+ let _ = env_logger:: try_init ( ) ;
2219
+ use self :: test:: { LineOutput , Test , TooltipTestHarness } ;
2220
+
2221
+ let tests = vec ! [
2222
+ // these test std stuff
2223
+ Test :: new( "test_tooltip_mod_use_external.rs" , 14 , 12 ) ,
2224
+ Test :: new( "test_tooltip_mod_use_external.rs" , 15 , 12 ) ,
2225
+ ] ;
2226
+
2227
+ let out = LineOutput :: default ( ) ;
2228
+ let proj_dir = FIXTURES_DIR . join ( "hover" ) ;
2229
+
2230
+ let save_dir_guard = tempfile:: tempdir ( ) . unwrap ( ) ;
2231
+ let save_dir = save_dir_guard. path ( ) . to_owned ( ) ;
2232
+ let load_dir = proj_dir. join ( "save_data" ) ;
2233
+
2234
+ let harness = TooltipTestHarness :: new ( proj_dir, & out, true ) ;
2168
2235
2169
2236
out. reset ( ) ;
2170
2237
0 commit comments