Skip to content

handle --release flag separately for tools #136048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test coverage
Signed-off-by: onur-ozkan <work@onurozkan.dev>
  • Loading branch information
onur-ozkan committed Jan 25, 2025
commit 4ba2bcff49ee577b18d5fb957c673c113d227f54
49 changes: 48 additions & 1 deletion src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::thread;

use super::*;
use crate::Flags;
use crate::core::build_steps::doc::DocumentationFormat;
use crate::core::config::Config;
use crate::{Flags, Mode};

static TEST_TRIPLE_1: &str = "i686-unknown-haiku";
static TEST_TRIPLE_2: &str = "i686-unknown-hurd-gnu";
Expand Down Expand Up @@ -861,3 +861,50 @@ fn test_test_coverage() {
assert_eq!(modes, expected);
}
}

#[test]
fn test_release_directory() {
let config = Config::parse_inner(
Flags::parse(&["check".into(), "--config=/does/not/exist".into()]),
|&_| toml::from_str(""),
);
let build = Build::new(config.clone());
let builder = Builder::new(&build);

assert_eq!(builder.cargo_dir(&Mode::Rustc), "release");
assert_eq!(builder.cargo_dir(&Mode::ToolStd), "debug");

let config = Config::parse_inner(
Flags::parse(&["check".into(), "--config=/does/not/exist".into(), "--release".into()]),
|&_| {
toml::from_str(
r#"
[rust]
optimize = false
"#,
)
},
);
let build = Build::new(config.clone());
let builder = Builder::new(&build);

assert_eq!(builder.cargo_dir(&Mode::Std), "release");
assert_eq!(builder.cargo_dir(&Mode::ToolBootstrap), "release");

let config = Config::parse_inner(
Flags::parse(&["check".into(), "--config=/does/not/exist".into()]),
|&_| {
toml::from_str(
r#"
[rust]
optimize = false
"#,
)
},
);
let build = Build::new(config.clone());
let builder = Builder::new(&build);

assert_eq!(builder.cargo_dir(&Mode::Rustc), "debug");
assert_eq!(builder.cargo_dir(&Mode::Codegen), "debug");
}
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ impl Config {
config.llvm_profile_generate = flags.llvm_profile_generate;
config.enable_bolt_settings = flags.enable_bolt_settings;
config.bypass_bootstrap_lock = flags.bypass_bootstrap_lock;
config.enable_release_build = flags.release || CiEnv::is_ci();
config.enable_release_build = flags.release || (CiEnv::is_ci() && !cfg!(test));

// Infer the rest of the configuration.

Expand Down
33 changes: 33 additions & 0 deletions src/bootstrap/src/core/config/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,36 @@ fn check_rustc_if_unchanged_paths() {
assert!(config.src.join(p).exists(), "{p} doesn't exist.");
}
}

#[test]
fn test_release_options() {
let config = Config::parse_inner(
Flags::parse(&["check".into(), "--config=/does/not/exist".into()]),
|&_| {
toml::from_str(
r#"
[rust]
optimize = false
"#,
)
},
);

assert!(!config.enable_release_build);
assert!(!config.rust_optimize.is_release());

let config = Config::parse_inner(
Flags::parse(&["check".into(), "--config=/does/not/exist".into(), "--release".into()]),
|&_| {
toml::from_str(
r#"
[rust]
optimize = false
"#,
)
},
);

assert!(config.enable_release_build);
assert!(config.rust_optimize.is_release());
}