mirror of
https://github.com/rust-lang/cargo
synced 2024-11-05 18:50:39 +00:00
Be more consistent about detecting CI.
This commit is contained in:
parent
4f6553ab55
commit
51a8206c38
4 changed files with 16 additions and 7 deletions
|
@ -2,7 +2,7 @@ use std::env;
|
|||
|
||||
use cargo::core::dependency::Kind;
|
||||
use cargo::core::{enable_nightly_features, Dependency};
|
||||
use cargo::util::Config;
|
||||
use cargo::util::{is_ci, Config};
|
||||
|
||||
use resolver_tests::{
|
||||
assert_contains, assert_same, dep, dep_kind, dep_loc, dep_req, dep_req_kind, loc_names, names,
|
||||
|
@ -22,7 +22,7 @@ use proptest::prelude::*;
|
|||
proptest! {
|
||||
#![proptest_config(ProptestConfig {
|
||||
max_shrink_iters:
|
||||
if env::var("CI").is_ok() || !atty::is(atty::Stream::Stderr) {
|
||||
if is_ci() || !atty::is(atty::Stream::Stderr) {
|
||||
// This attempts to make sure that CI will fail fast,
|
||||
0
|
||||
} else {
|
||||
|
|
|
@ -82,3 +82,8 @@ pub fn validate_package_name(name: &str, what: &str, help: &str) -> CargoResult<
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Whether or not this running in a Continuous Integration environment.
|
||||
pub fn is_ci() -> bool {
|
||||
std::env::var("CI").is_ok() || std::env::var("TF_BUILD").is_ok()
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::env;
|
|||
use std::time::{Duration, Instant};
|
||||
|
||||
use crate::core::shell::Verbosity;
|
||||
use crate::util::{CargoResult, Config};
|
||||
use crate::util::{is_ci, CargoResult, Config};
|
||||
|
||||
use unicode_width::UnicodeWidthChar;
|
||||
|
||||
|
@ -45,7 +45,7 @@ impl<'cfg> Progress<'cfg> {
|
|||
Ok(term) => term == "dumb",
|
||||
Err(_) => false,
|
||||
};
|
||||
if cfg.shell().verbosity() == Verbosity::Quiet || dumb || env::var("CI").is_ok() {
|
||||
if cfg.shell().verbosity() == Verbosity::Quiet || dumb || is_ci() {
|
||||
return Progress { state: None };
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ use std::time::{self, Duration};
|
|||
use std::usize;
|
||||
|
||||
use cargo;
|
||||
use cargo::util::{CargoResult, ProcessBuilder, ProcessError, Rustc};
|
||||
use cargo::util::{is_ci, CargoResult, ProcessBuilder, ProcessError, Rustc};
|
||||
use filetime;
|
||||
use serde_json::{self, Value};
|
||||
use url::Url;
|
||||
|
@ -855,7 +855,7 @@ impl Execs {
|
|||
fn match_process(&self, process: &ProcessBuilder) -> MatchResult {
|
||||
println!("running {}", process);
|
||||
let res = if self.stream_output {
|
||||
if env::var("CI").is_ok() {
|
||||
if is_ci() {
|
||||
panic!("`.stream()` is for local debugging")
|
||||
}
|
||||
process.exec_with_streaming(
|
||||
|
@ -1746,7 +1746,7 @@ pub fn is_coarse_mtime() -> bool {
|
|||
// This should actually be a test that `$CARGO_TARGET_DIR` is on an HFS
|
||||
// filesystem, (or any filesystem with low-resolution mtimes). However,
|
||||
// that's tricky to detect, so for now just deal with CI.
|
||||
cfg!(target_os = "macos") && (env::var("CI").is_ok() || env::var("TF_BUILD").is_ok())
|
||||
cfg!(target_os = "macos") && is_ci()
|
||||
}
|
||||
|
||||
/// Some CI setups are much slower then the equipment used by Cargo itself.
|
||||
|
@ -1772,6 +1772,10 @@ pub fn clippy_is_available() -> bool {
|
|||
|
||||
#[cfg(windows)]
|
||||
pub fn symlink_supported() -> bool {
|
||||
if is_ci() {
|
||||
// We want to be absolutely sure this runs on CI.
|
||||
return true;
|
||||
}
|
||||
let src = paths::root().join("symlink_src");
|
||||
fs::write(&src, "").unwrap();
|
||||
let dst = paths::root().join("symlink_dst");
|
||||
|
|
Loading…
Reference in a new issue