From cf6dc742b77b86a95b78d5e40dfe2e080282863f Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Mon, 24 Feb 2025 11:20:13 +0300 Subject: [PATCH] add coverage for explicit stage fields Signed-off-by: onur-ozkan --- src/bootstrap/src/core/config/tests.rs | 57 ++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/bootstrap/src/core/config/tests.rs b/src/bootstrap/src/core/config/tests.rs index f0a185ee3a7eb..726abe1627f97 100644 --- a/src/bootstrap/src/core/config/tests.rs +++ b/src/bootstrap/src/core/config/tests.rs @@ -454,3 +454,60 @@ fn check_rustc_if_unchanged_paths() { assert!(config.src.join(p).exists(), "{p} doesn't exist."); } } + +#[test] +fn test_explicit_stage() { + let config = Config::parse_inner( + Flags::parse(&["check".to_owned(), "--config=/does/not/exist".to_owned()]), + |&_| { + toml::from_str( + r#" + [build] + test-stage = 1 + "#, + ) + }, + ); + + assert!(!config.explicit_stage_from_cli); + assert!(config.explicit_stage_from_config); + + let config = Config::parse_inner( + Flags::parse(&[ + "check".to_owned(), + "--stage=2".to_owned(), + "--config=/does/not/exist".to_owned(), + ]), + |&_| toml::from_str(""), + ); + + assert!(config.explicit_stage_from_cli); + assert!(!config.explicit_stage_from_config); + + let config = Config::parse_inner( + Flags::parse(&[ + "check".to_owned(), + "--stage=2".to_owned(), + "--config=/does/not/exist".to_owned(), + ]), + |&_| { + toml::from_str( + r#" + [build] + test-stage = 1 + "#, + ) + }, + ); + + assert!(config.explicit_stage_from_cli); + assert!(config.explicit_stage_from_config); + + let config = Config::parse_inner( + Flags::parse(&["check".to_owned(), "--config=/does/not/exist".to_owned()]), + |&_| toml::from_str(""), + ); + + assert!(!config.explicit_stage_from_cli); + assert!(!config.explicit_stage_from_config); +}