diff options
| author | hi-rustin <rustin.liu@gmail.com> | 2023-07-01 16:59:35 +0800 |
|---|---|---|
| committer | hi-rustin <rustin.liu@gmail.com> | 2023-07-01 16:59:35 +0800 |
| commit | 878eff12074621e37bef8dabc85c5a8d312fd400 (patch) | |
| tree | cd341fff1925553afeb46f62c19d54be64436f0e /src/bootstrap/config | |
| parent | e6e2825bb018baa4f0f6dfecd4206beb73d3ebf4 (diff) | |
Add tests for RustOptimize
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
Diffstat (limited to 'src/bootstrap/config')
| -rw-r--r-- | src/bootstrap/config/tests.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/bootstrap/config/tests.rs b/src/bootstrap/config/tests.rs index 3bee659abd1..6ec24530af2 100644 --- a/src/bootstrap/config/tests.rs +++ b/src/bootstrap/config/tests.rs @@ -178,3 +178,22 @@ fn profile_user_dist() { } Config::parse_inner(&["check".to_owned()], get_toml); } + +#[test] +fn rust_optimize() { + let parse = |s| Config::parse_inner(&["check".to_owned()], |&_| toml::from_str(s).unwrap()); + + 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() { + Config::parse_inner(&["check".to_owned()], |&_| { + toml::from_str("rust.optimize = \"a\"").unwrap() + }); +} |
