|
1 |
| -use cargotest::ChannelChanger; |
2 |
| -use cargotest::support::{execs, project}; |
3 |
| -use hamcrest::assert_that; |
4 | 1 | use std::path::Path;
|
5 |
| -use std::fs; |
| 2 | +use std::fs::{self, File}; |
| 3 | +use std::env; |
| 4 | +use std::io::Write; |
| 5 | + |
| 6 | +use hamcrest::assert_that; |
| 7 | + |
| 8 | +use cargotest::{process, ChannelChanger}; |
| 9 | +use cargotest::support::{execs, project}; |
6 | 10 |
|
7 | 11 | #[test]
|
8 | 12 | fn binary_with_debug() {
|
@@ -195,6 +199,74 @@ fn include_only_the_binary_from_the_current_package() {
|
195 | 199 | );
|
196 | 200 | }
|
197 | 201 |
|
| 202 | +#[test] |
| 203 | +fn out_dir_is_a_file() { |
| 204 | + let p = project("foo") |
| 205 | + .file( |
| 206 | + "Cargo.toml", |
| 207 | + r#" |
| 208 | + [project] |
| 209 | + name = "foo" |
| 210 | + version = "0.0.1" |
| 211 | + authors = [] |
| 212 | + "#, |
| 213 | + ) |
| 214 | + .file("src/main.rs", r#"fn main() { println!("Hello, World!") }"#) |
| 215 | + .build(); |
| 216 | + File::create(p.root().join("out")).unwrap(); |
| 217 | + |
| 218 | + assert_that( |
| 219 | + p.cargo("build -Z out-dir --out-dir out") |
| 220 | + .masquerade_as_nightly_cargo(), |
| 221 | + execs() |
| 222 | + .with_status(101) |
| 223 | + .with_stderr_contains("[ERROR] failed to link or copy [..]"), |
| 224 | + ); |
| 225 | +} |
| 226 | + |
| 227 | +#[test] |
| 228 | +fn replaces_artifacts() { |
| 229 | + let p = project("foo") |
| 230 | + .file( |
| 231 | + "Cargo.toml", |
| 232 | + r#" |
| 233 | + [project] |
| 234 | + name = "foo" |
| 235 | + version = "0.0.1" |
| 236 | + authors = [] |
| 237 | + "#, |
| 238 | + ) |
| 239 | + .file("src/main.rs", r#"fn main() { println!("foo") }"#) |
| 240 | + .build(); |
| 241 | + |
| 242 | + assert_that( |
| 243 | + p.cargo("build -Z out-dir --out-dir out") |
| 244 | + .masquerade_as_nightly_cargo(), |
| 245 | + execs().with_status(0), |
| 246 | + ); |
| 247 | + assert_that( |
| 248 | + process(&p.root() |
| 249 | + .join(&format!("out/foo{}", env::consts::EXE_SUFFIX))), |
| 250 | + execs().with_stdout("foo"), |
| 251 | + ); |
| 252 | + |
| 253 | + fs::File::create(p.root().join("src/main.rs")) |
| 254 | + .unwrap() |
| 255 | + .write_all(br#"fn main() { println!("bar") }"#) |
| 256 | + .unwrap(); |
| 257 | + |
| 258 | + assert_that( |
| 259 | + p.cargo("build -Z out-dir --out-dir out") |
| 260 | + .masquerade_as_nightly_cargo(), |
| 261 | + execs().with_status(0), |
| 262 | + ); |
| 263 | + assert_that( |
| 264 | + process(&p.root() |
| 265 | + .join(&format!("out/foo{}", env::consts::EXE_SUFFIX))), |
| 266 | + execs().with_stdout("bar"), |
| 267 | + ); |
| 268 | +} |
| 269 | + |
198 | 270 | fn check_dir_contents(
|
199 | 271 | out_dir: &Path,
|
200 | 272 | expected_linux: &[&str],
|
|
0 commit comments