@@ -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,11 @@ 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;
1202
+ // FIXME(#1195): This led to spurious failures on macOS; possibly
1203
+ // because regular build and #[cfg(test)] did race or rls-analysis
1204
+ // didn't lower them properly?
1205
+ config. all_targets = false ;
1197
1206
1198
1207
let config = Arc :: new ( Mutex :: new ( config) ) ;
1199
1208
let analysis = Arc :: new ( analysis:: AnalysisHost :: new ( analysis:: Target :: Debug ) ) ;
@@ -2047,10 +2056,53 @@ pub mod test {
2047
2056
assert_eq ! ( expected, actual) ;
2048
2057
}
2049
2058
2059
+ enum RacerFallback {
2060
+ Yes ,
2061
+ No ,
2062
+ }
2063
+
2064
+ impl From < RacerFallback > for bool {
2065
+ fn from ( arg : RacerFallback ) -> bool {
2066
+ match arg {
2067
+ RacerFallback :: Yes => true ,
2068
+ RacerFallback :: No => false ,
2069
+ }
2070
+ }
2071
+ }
2072
+
2073
+ // Common logic used in `test_tooltip_*` tests below
2074
+ fn run_tooltip_tests (
2075
+ tests : & [ Test ] ,
2076
+ proj_dir : PathBuf ,
2077
+ racer_completion : RacerFallback ,
2078
+ ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
2079
+ let out = LineOutput :: default ( ) ;
2080
+
2081
+ let save_dir_guard = tempfile:: tempdir ( ) . unwrap ( ) ;
2082
+ let save_dir = save_dir_guard. path ( ) . to_owned ( ) ;
2083
+ let load_dir = proj_dir. join ( "save_data" ) ;
2084
+
2085
+ let harness = TooltipTestHarness :: new ( proj_dir, & out, racer_completion. into ( ) ) ;
2086
+
2087
+ out. reset ( ) ;
2088
+
2089
+ let failures = harness. run_tests ( tests, load_dir, save_dir) ?;
2090
+
2091
+ if failures. is_empty ( ) {
2092
+ Ok ( ( ) )
2093
+ } else {
2094
+ eprintln ! ( "{}\n \n " , out. reset( ) . join( "\n " ) ) ;
2095
+ eprintln ! (
2096
+ "Failures (\x1b [91mexpected\x1b [92mactual\x1b [0m): {:#?}\n \n " ,
2097
+ failures
2098
+ ) ;
2099
+ Err ( format ! ( "{} of {} tooltip tests failed" , failures. len( ) , tests. len( ) ) . into ( ) )
2100
+ }
2101
+ }
2102
+
2050
2103
#[ test]
2051
2104
fn test_tooltip ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
2052
2105
let _ = env_logger:: try_init ( ) ;
2053
- use self :: test:: { LineOutput , Test , TooltipTestHarness } ;
2054
2106
2055
2107
let tests = vec ! [
2056
2108
Test :: new( "test_tooltip_01.rs" , 13 , 11 ) ,
@@ -2082,7 +2134,6 @@ pub mod test {
2082
2134
Test :: new( "test_tooltip_01.rs" , 68 , 11 ) ,
2083
2135
Test :: new( "test_tooltip_01.rs" , 68 , 26 ) ,
2084
2136
Test :: new( "test_tooltip_01.rs" , 75 , 10 ) ,
2085
- Test :: new( "test_tooltip_01.rs" , 80 , 11 ) ,
2086
2137
Test :: new( "test_tooltip_01.rs" , 85 , 14 ) ,
2087
2138
Test :: new( "test_tooltip_01.rs" , 85 , 50 ) ,
2088
2139
Test :: new( "test_tooltip_01.rs" , 85 , 54 ) ,
@@ -2091,7 +2142,6 @@ pub mod test {
2091
2142
Test :: new( "test_tooltip_01.rs" , 87 , 20 ) ,
2092
2143
Test :: new( "test_tooltip_01.rs" , 88 , 18 ) ,
2093
2144
Test :: new( "test_tooltip_01.rs" , 93 , 11 ) ,
2094
- Test :: new( "test_tooltip_01.rs" , 93 , 18 ) ,
2095
2145
Test :: new( "test_tooltip_01.rs" , 95 , 25 ) ,
2096
2146
Test :: new( "test_tooltip_01.rs" , 109 , 21 ) ,
2097
2147
Test :: new( "test_tooltip_01.rs" , 113 , 21 ) ,
@@ -2100,32 +2150,24 @@ pub mod test {
2100
2150
Test :: new( "test_tooltip_mod_use.rs" , 12 , 14 ) ,
2101
2151
Test :: new( "test_tooltip_mod_use.rs" , 12 , 25 ) ,
2102
2152
Test :: new( "test_tooltip_mod_use.rs" , 13 , 28 ) ,
2103
- Test :: new( "test_tooltip_mod_use_external.rs" , 11 , 7 ) ,
2104
- Test :: new( "test_tooltip_mod_use_external.rs" , 11 , 7 ) ,
2105
- Test :: new( "test_tooltip_mod_use_external.rs" , 12 , 7 ) ,
2106
- Test :: new( "test_tooltip_mod_use_external.rs" , 12 , 12 ) ,
2107
2153
] ;
2108
2154
2109
- let out = LineOutput :: default ( ) ;
2110
- let proj_dir = FIXTURES_DIR . join ( "hover" ) ;
2111
-
2112
- let save_dir_guard = tempfile:: tempdir ( ) . unwrap ( ) ;
2113
- let save_dir = save_dir_guard. path ( ) . to_owned ( ) ;
2114
- let load_dir = proj_dir. join ( "save_data" ) ;
2115
-
2116
- let harness = TooltipTestHarness :: new ( proj_dir, & out) ;
2155
+ run_tooltip_tests ( & tests, FIXTURES_DIR . join ( "hover" ) , RacerFallback :: No )
2156
+ }
2117
2157
2118
- out. reset ( ) ;
2158
+ #[ test]
2159
+ fn test_tooltip_racer ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
2160
+ let _ = env_logger:: try_init ( ) ;
2119
2161
2120
- let failures = harness. run_tests ( & tests, load_dir, save_dir) ?;
2162
+ let tests = vec ! [
2163
+ Test :: new( "test_tooltip_01.rs" , 80 , 11 ) ,
2164
+ Test :: new( "test_tooltip_01.rs" , 93 , 18 ) ,
2165
+ Test :: new( "test_tooltip_mod_use_external.rs" , 11 , 7 ) ,
2166
+ Test :: new( "test_tooltip_mod_use_external.rs" , 12 , 7 ) ,
2167
+ Test :: new( "test_tooltip_mod_use_external.rs" , 12 , 12 ) ,
2168
+ ] ;
2121
2169
2122
- if failures. is_empty ( ) {
2123
- Ok ( ( ) )
2124
- } else {
2125
- eprintln ! ( "{}\n \n " , out. reset( ) . join( "\n " ) ) ;
2126
- eprintln ! ( "Failures (\x1b [91mexpected\x1b [92mactual\x1b [0m): {:#?}\n \n " , failures) ;
2127
- Err ( format ! ( "{} of {} tooltip tests failed" , failures. len( ) , tests. len( ) ) . into ( ) )
2128
- }
2170
+ run_tooltip_tests ( & tests, FIXTURES_DIR . join ( "hover" ) , RacerFallback :: Yes )
2129
2171
}
2130
2172
2131
2173
/// Note: This test is ignored as it doesn't work in the rust-lang/rust repo.
@@ -2135,13 +2177,8 @@ pub mod test {
2135
2177
#[ ignore]
2136
2178
fn test_tooltip_std ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
2137
2179
let _ = env_logger:: try_init ( ) ;
2138
- use self :: test:: { LineOutput , Test , TooltipTestHarness } ;
2139
2180
2140
2181
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
2182
Test :: new( "test_tooltip_std.rs" , 18 , 15 ) ,
2146
2183
Test :: new( "test_tooltip_std.rs" , 18 , 27 ) ,
2147
2184
Test :: new( "test_tooltip_std.rs" , 19 , 7 ) ,
@@ -2157,25 +2194,23 @@ pub mod test {
2157
2194
Test :: new( "test_tooltip_std.rs" , 25 , 25 ) ,
2158
2195
] ;
2159
2196
2160
- let out = LineOutput :: default ( ) ;
2161
- let proj_dir = FIXTURES_DIR . join ( "hover" ) ;
2162
-
2163
- let save_dir_guard = tempfile:: tempdir ( ) . unwrap ( ) ;
2164
- let save_dir = save_dir_guard. path ( ) . to_owned ( ) ;
2165
- let load_dir = proj_dir. join ( "save_data" ) ;
2166
-
2167
- let harness = TooltipTestHarness :: new ( proj_dir, & out) ;
2197
+ run_tooltip_tests ( & tests, FIXTURES_DIR . join ( "hover" ) , RacerFallback :: No )
2198
+ }
2168
2199
2169
- out. reset ( ) ;
2200
+ /// Note: This test is ignored as it doesn't work in the rust-lang/rust repo.
2201
+ /// It is enabled on CI.
2202
+ /// Run with `cargo test test_tooltip_std -- --ignored`
2203
+ #[ test]
2204
+ #[ ignore]
2205
+ fn test_tooltip_std_racer ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
2206
+ let _ = env_logger:: try_init ( ) ;
2170
2207
2171
- let failures = harness. run_tests ( & tests, load_dir, save_dir) ?;
2208
+ let tests = vec ! [
2209
+ // these test std stuff
2210
+ Test :: new( "test_tooltip_mod_use_external.rs" , 14 , 12 ) ,
2211
+ Test :: new( "test_tooltip_mod_use_external.rs" , 15 , 12 ) ,
2212
+ ] ;
2172
2213
2173
- if failures. is_empty ( ) {
2174
- Ok ( ( ) )
2175
- } else {
2176
- eprintln ! ( "{}\n \n " , out. reset( ) . join( "\n " ) ) ;
2177
- eprintln ! ( "Failures (\x1b [91mexpected\x1b [92mactual\x1b [0m): {:#?}\n \n " , failures) ;
2178
- Err ( format ! ( "{} of {} tooltip tests failed" , failures. len( ) , tests. len( ) ) . into ( ) )
2179
- }
2214
+ run_tooltip_tests ( & tests, FIXTURES_DIR . join ( "hover" ) , RacerFallback :: Yes )
2180
2215
}
2181
2216
}
0 commit comments