X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=tests%2Fintegration.rs;h=c64425fa01a42a36b8351e934ae81523d75b7129;hb=f5bbd1b5299da31532d00abb0502feb5b60f2606;hp=455965436d63a5ce99c4345f23524f25420d5016;hpb=e4d09975d0e919814edb55f35cafa4781ee42d0d;p=rust.git diff --git a/tests/integration.rs b/tests/integration.rs index 455965436d6..c64425fa01a 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1,9 +1,9 @@ #![cfg(feature = "integration")] - -use git2::Repository; -use tempfile; +#![cfg_attr(feature = "deny-warnings", deny(warnings))] +#![warn(rust_2018_idioms, unused_lifetimes)] use std::env; +use std::ffi::OsStr; use std::process::Command; #[cfg_attr(feature = "integration", test)] @@ -15,12 +15,19 @@ fn integration_test() { .nth(1) .expect("repo name should have format `/`"); - let repo_dir = tempfile::tempdir() - .expect("couldn't create temp dir") - .path() - .join(crate_name); + let mut repo_dir = tempfile::tempdir().expect("couldn't create temp dir").into_path(); + repo_dir.push(crate_name); - Repository::clone(&repo_url, &repo_dir).expect("clone of repo failed"); + let st = Command::new("git") + .args(&[ + OsStr::new("clone"), + OsStr::new("--depth=1"), + OsStr::new(&repo_url), + OsStr::new(&repo_dir), + ]) + .status() + .expect("unable to run git"); + assert!(st.success()); let root_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")); let target_dir = std::path::Path::new(&root_dir).join("target"); @@ -59,17 +66,24 @@ fn integration_test() { } else if stderr.contains("query stack during panic") { panic!("query stack during panic in the output"); } else if stderr.contains("E0463") { + // Encountering E0463 (can't find crate for `x`) did _not_ cause the build to fail in the + // past. Even though it should have. That's why we explicitly panic here. + // See PR #3552 and issue #3523 for more background. panic!("error: E0463"); + } else if stderr.contains("E0514") { + panic!("incompatible crate versions"); + } else if stderr.contains("failed to run `rustc` to learn about target-specific information") { + panic!("couldn't find librustc_driver, consider setting `LD_LIBRARY_PATH`"); + } else { + assert!( + !stderr.contains("toolchain") || !stderr.contains("is not installed"), + "missing required toolchain" + ); } match output.status.code() { - Some(code) => { - if code == 0 { - println!("Compilation successful"); - } else { - eprintln!("Compilation failed. Exit code: {}", code); - } - }, + Some(0) => println!("Compilation successful"), + Some(code) => eprintln!("Compilation failed. Exit code: {}", code), None => panic!("Process terminated by signal"), } }