Fix Config.set working with the rust table
This commit is contained in:
parent
fe76ee626f
commit
8053774ba3
1 changed files with 18 additions and 0 deletions
|
|
@ -230,6 +230,8 @@ impl Config {
|
||||||
self.book.update_value(key, value);
|
self.book.update_value(key, value);
|
||||||
} else if let Some(key) = index.strip_prefix("build.") {
|
} else if let Some(key) = index.strip_prefix("build.") {
|
||||||
self.build.update_value(key, value);
|
self.build.update_value(key, value);
|
||||||
|
} else if let Some(key) = index.strip_prefix("rust.") {
|
||||||
|
self.rust.update_value(key, value);
|
||||||
} else {
|
} else {
|
||||||
self.rest.insert(index, value);
|
self.rest.insert(index, value);
|
||||||
}
|
}
|
||||||
|
|
@ -1111,6 +1113,22 @@ mod tests {
|
||||||
assert_eq!(got, value);
|
assert_eq!(got, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn set_special_tables() {
|
||||||
|
let mut cfg = Config::default();
|
||||||
|
assert_eq!(cfg.book.title, None);
|
||||||
|
cfg.set("book.title", "my title").unwrap();
|
||||||
|
assert_eq!(cfg.book.title, Some("my title".to_string()));
|
||||||
|
|
||||||
|
assert_eq!(&cfg.build.build_dir, Path::new("book"));
|
||||||
|
cfg.set("build.build-dir", "some-directory").unwrap();
|
||||||
|
assert_eq!(&cfg.build.build_dir, Path::new("some-directory"));
|
||||||
|
|
||||||
|
assert_eq!(cfg.rust.edition, None);
|
||||||
|
cfg.set("rust.edition", "2024").unwrap();
|
||||||
|
assert_eq!(cfg.rust.edition, Some(RustEdition::E2024));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_env_vars() {
|
fn parse_env_vars() {
|
||||||
let inputs = vec![
|
let inputs = vec![
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue