summaryrefslogtreecommitdiffstats
path: root/src/bootstrap/config/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bootstrap/config/tests.rs')
-rw-r--r--src/bootstrap/config/tests.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/bootstrap/config/tests.rs b/src/bootstrap/config/tests.rs
index 4de84b543..732df54cd 100644
--- a/src/bootstrap/config/tests.rs
+++ b/src/bootstrap/config/tests.rs
@@ -1,5 +1,8 @@
+use crate::config::TomlConfig;
+
use super::{Config, Flags};
use clap::CommandFactory;
+use serde::Deserialize;
use std::{env, path::Path};
fn parse(config: &str) -> Config {
@@ -159,3 +162,34 @@ fn override_toml_duplicate() {
|&_| toml::from_str("changelog-seen = 0").unwrap(),
);
}
+
+#[test]
+fn profile_user_dist() {
+ fn get_toml(file: &Path) -> TomlConfig {
+ let contents = if file.ends_with("config.toml") {
+ "profile = \"user\"".to_owned()
+ } else {
+ assert!(file.ends_with("config.dist.toml"));
+ std::fs::read_to_string(dbg!(file)).unwrap()
+ };
+ toml::from_str(&contents)
+ .and_then(|table: toml::Value| TomlConfig::deserialize(table))
+ .unwrap()
+ }
+ Config::parse_inner(&["check".to_owned()], get_toml);
+}
+
+#[test]
+fn rust_optimize() {
+ assert_eq!(parse("").rust_optimize.is_release(), true);
+ assert_eq!(parse("rust.optimize = false").rust_optimize.is_release(), false);
+ assert_eq!(parse("rust.optimize = true").rust_optimize.is_release(), true);
+ assert_eq!(parse("rust.optimize = \"1\"").rust_optimize.get_opt_level(), Some("1".to_string()));
+ assert_eq!(parse("rust.optimize = \"s\"").rust_optimize.get_opt_level(), Some("s".to_string()));
+}
+
+#[test]
+#[should_panic]
+fn invalid_rust_optimize() {
+ parse("rust.optimize = \"a\"");
+}