@@ -153,7 +153,7 @@ fn run_cargo(
153
153
154
154
// TODO: It might be feasible to keep this CargoOptions structure cached and regenerate
155
155
// it on every relevant configuration change
156
- let ( opts, rustflags, clear_env_rust_log) =
156
+ let ( opts, rustflags, clear_env_rust_log, cfg_test ) =
157
157
{
158
158
// We mustn't lock configuration for the whole build process
159
159
let rls_config = rls_config. lock ( ) . unwrap ( ) ;
@@ -182,7 +182,7 @@ fn run_cargo(
182
182
}
183
183
}
184
184
185
- ( opts, rustflags, rls_config. clear_env_rust_log )
185
+ ( opts, rustflags, rls_config. clear_env_rust_log , rls_config . cfg_test )
186
186
} ;
187
187
188
188
let spec = Packages :: from_flags ( false , Vec :: new ( ) , packages) ?;
@@ -196,7 +196,7 @@ fn run_cargo(
196
196
opts. bins ,
197
197
// TODO: Support more crate target types
198
198
Vec :: new ( ) ,
199
- false ,
199
+ cfg_test , // Check all integration tests under tests/
200
200
Vec :: new ( ) ,
201
201
false ,
202
202
Vec :: new ( ) ,
@@ -207,7 +207,7 @@ fn run_cargo(
207
207
all_features : opts. all_features ,
208
208
no_default_features : opts. no_default_features ,
209
209
jobs : opts. jobs ,
210
- ..CompileOptions :: default ( & config, CompileMode :: Check { test : false } )
210
+ ..CompileOptions :: default ( & config, CompileMode :: Check { test : cfg_test } )
211
211
} ;
212
212
213
213
// Create a custom environment for running cargo, the environment is reset
@@ -460,7 +460,7 @@ impl Executor for RlsExecutor {
460
460
// Because we only try to emulate `cargo test` using `cargo check`, so for now
461
461
// assume crate_type arg (i.e. in `cargo test` it isn't specified for --test targets)
462
462
// and build test harness only for final crate type
463
- let crate_type = if config. all_targets {
463
+ let crate_type = if config. all_targets || config . cfg_test {
464
464
// Crate type may be undefined when `all_targets` is true, for example for integration tests
465
465
crate_type. unwrap_or_else ( || "undefined" . to_owned ( ) )
466
466
} else {
@@ -470,15 +470,6 @@ impl Executor for RlsExecutor {
470
470
let build_lib = * config. build_lib . as_ref ( ) ;
471
471
let is_final_crate_type = crate_type == "bin" || ( crate_type == "lib" && build_lib) ;
472
472
473
- if config. cfg_test {
474
- // FIXME(#351) allow passing --test to lib crate-type when building a dependency
475
- if is_final_crate_type {
476
- args. push ( "--test" . to_owned ( ) ) ;
477
- } else {
478
- args. push ( "--cfg" . to_owned ( ) ) ;
479
- args. push ( "test" . to_owned ( ) ) ;
480
- }
481
- }
482
473
if config. sysroot . is_none ( ) {
483
474
args. push ( "--sysroot" . to_owned ( ) ) ;
484
475
args. push ( sysroot) ;
0 commit comments