15
15
16
16
use std:: collections:: HashSet ;
17
17
use std:: env;
18
+ use std:: ffi:: OsString ;
18
19
use std:: iter;
19
20
use std:: fmt;
20
21
use std:: fs:: { self , File } ;
@@ -117,14 +118,7 @@ pub fn cargotest(build: &Build, stage: u32, host: &str) {
117
118
118
119
/// Runs `cargo test` for `cargo` packaged with Rust.
119
120
pub fn cargo ( build : & Build , stage : u32 , host : & str ) {
120
- let ref compiler = Compiler :: new ( stage, host) ;
121
-
122
- // Configure PATH to find the right rustc. NB. we have to use PATH
123
- // and not RUSTC because the Cargo test suite has tests that will
124
- // fail if rustc is not spelled `rustc`.
125
- let path = build. sysroot ( compiler) . join ( "bin" ) ;
126
- let old_path = env:: var_os ( "PATH" ) . unwrap_or_default ( ) ;
127
- let newpath = env:: join_paths ( iter:: once ( path) . chain ( env:: split_paths ( & old_path) ) ) . expect ( "" ) ;
121
+ let compiler = & Compiler :: new ( stage, host) ;
128
122
129
123
let mut cargo = build. cargo ( compiler, Mode :: Tool , host, "test" ) ;
130
124
cargo. arg ( "--manifest-path" ) . arg ( build. src . join ( "src/tools/cargo/Cargo.toml" ) ) ;
@@ -139,7 +133,31 @@ pub fn cargo(build: &Build, stage: u32, host: &str) {
139
133
// available.
140
134
cargo. env ( "CFG_DISABLE_CROSS_TESTS" , "1" ) ;
141
135
142
- try_run ( build, cargo. env ( "PATH" , newpath) ) ;
136
+ try_run ( build, cargo. env ( "PATH" , & path_for_cargo ( build, compiler) ) ) ;
137
+ }
138
+
139
+ /// Runs `cargo test` for the rls.
140
+ pub fn rls ( build : & Build , stage : u32 , host : & str ) {
141
+ let compiler = & Compiler :: new ( stage, host) ;
142
+
143
+ let mut cargo = build. cargo ( compiler, Mode :: Tool , host, "test" ) ;
144
+ cargo. arg ( "--manifest-path" ) . arg ( build. src . join ( "src/tools/rls/Cargo.toml" ) ) ;
145
+
146
+ // Don't build tests dynamically, just a pain to work with
147
+ cargo. env ( "RUSTC_NO_PREFER_DYNAMIC" , "1" ) ;
148
+
149
+ build. add_rustc_lib_path ( compiler, & mut cargo) ;
150
+
151
+ try_run ( build, & mut cargo) ;
152
+ }
153
+
154
+ fn path_for_cargo ( build : & Build , compiler : & Compiler ) -> OsString {
155
+ // Configure PATH to find the right rustc. NB. we have to use PATH
156
+ // and not RUSTC because the Cargo test suite has tests that will
157
+ // fail if rustc is not spelled `rustc`.
158
+ let path = build. sysroot ( compiler) . join ( "bin" ) ;
159
+ let old_path = env:: var_os ( "PATH" ) . unwrap_or_default ( ) ;
160
+ env:: join_paths ( iter:: once ( path) . chain ( env:: split_paths ( & old_path) ) ) . expect ( "" )
143
161
}
144
162
145
163
/// Runs the `tidy` tool as compiled in `stage` by the `host` compiler.
0 commit comments