diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
commit | 9835e2ae736235810b4ea1c162ca5e65c547e770 (patch) | |
tree | 3fcebf40ed70e581d776a8a4c65923e8ec20e026 /src/tools/cargo/tests/testsuite/config.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff) | |
download | rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/cargo/tests/testsuite/config.rs')
-rw-r--r-- | src/tools/cargo/tests/testsuite/config.rs | 67 |
1 files changed, 62 insertions, 5 deletions
diff --git a/src/tools/cargo/tests/testsuite/config.rs b/src/tools/cargo/tests/testsuite/config.rs index 92e1f4264..b0f9d167b 100644 --- a/src/tools/cargo/tests/testsuite/config.rs +++ b/src/tools/cargo/tests/testsuite/config.rs @@ -3,7 +3,7 @@ use cargo::core::{PackageIdSpec, Shell}; use cargo::util::config::{self, Config, Definition, SslVersionConfig, StringList}; use cargo::util::interning::InternedString; -use cargo::util::toml::{self as cargo_toml, VecStringOrBool as VSOB}; +use cargo::util::toml::{self as cargo_toml, TomlDebugInfo, VecStringOrBool as VSOB}; use cargo::CargoResult; use cargo_test_support::compare; use cargo_test_support::{panic_error, paths, project, symlink_supported, t}; @@ -401,7 +401,7 @@ lto = false opt_level: Some(cargo_toml::TomlOptLevel("s".to_string())), lto: Some(cargo_toml::StringOrBool::Bool(true)), codegen_units: Some(5), - debug: Some(cargo_toml::U32OrBool::Bool(true)), + debug: Some(cargo_toml::TomlDebugInfo::Full), debug_assertions: Some(true), rpath: Some(true), panic: Some("abort".to_string()), @@ -444,7 +444,7 @@ fn profile_env_var_prefix() { .build(); let p: cargo_toml::TomlProfile = config.get("profile.dev").unwrap(); assert_eq!(p.debug_assertions, None); - assert_eq!(p.debug, Some(cargo_toml::U32OrBool::U32(1))); + assert_eq!(p.debug, Some(cargo_toml::TomlDebugInfo::Limited)); let config = ConfigBuilder::new() .env("CARGO_PROFILE_DEV_DEBUG_ASSERTIONS", "false") @@ -452,7 +452,7 @@ fn profile_env_var_prefix() { .build(); let p: cargo_toml::TomlProfile = config.get("profile.dev").unwrap(); assert_eq!(p.debug_assertions, Some(false)); - assert_eq!(p.debug, Some(cargo_toml::U32OrBool::U32(1))); + assert_eq!(p.debug, Some(cargo_toml::TomlDebugInfo::Limited)); } #[cargo_test] @@ -1511,7 +1511,7 @@ fn all_profile_options() { lto: Some(cargo_toml::StringOrBool::String("thin".to_string())), codegen_backend: Some(InternedString::new("example")), codegen_units: Some(123), - debug: Some(cargo_toml::U32OrBool::U32(1)), + debug: Some(cargo_toml::TomlDebugInfo::Limited), split_debuginfo: Some("packed".to_string()), debug_assertions: Some(true), rpath: Some(true), @@ -1594,3 +1594,60 @@ known-hosts = [ Definition::Environment("CARGO_NET_SSH_KNOWN_HOSTS".to_string()) ); } + +#[cargo_test] +fn debuginfo_parsing() { + let config = ConfigBuilder::new().build(); + let p: cargo_toml::TomlProfile = config.get("profile.dev").unwrap(); + assert_eq!(p.debug, None); + + let env_test_cases = [ + (TomlDebugInfo::None, ["false", "0", "none"].as_slice()), + (TomlDebugInfo::LineDirectivesOnly, &["line-directives-only"]), + (TomlDebugInfo::LineTablesOnly, &["line-tables-only"]), + (TomlDebugInfo::Limited, &["1", "limited"]), + (TomlDebugInfo::Full, &["true", "2", "full"]), + ]; + for (expected, config_strs) in env_test_cases { + for &val in config_strs { + let config = ConfigBuilder::new() + .env("CARGO_PROFILE_DEV_DEBUG", val) + .build(); + let debug: TomlDebugInfo = config.get("profile.dev.debug").unwrap(); + assert_eq!(debug, expected, "failed to parse {val}"); + } + } + + let toml_test_cases = [ + (TomlDebugInfo::None, ["false", "0", "\"none\""].as_slice()), + ( + TomlDebugInfo::LineDirectivesOnly, + &["\"line-directives-only\""], + ), + (TomlDebugInfo::LineTablesOnly, &["\"line-tables-only\""]), + (TomlDebugInfo::Limited, &["1", "\"limited\""]), + (TomlDebugInfo::Full, &["true", "2", "\"full\""]), + ]; + for (expected, config_strs) in toml_test_cases { + for &val in config_strs { + let config = ConfigBuilder::new() + .config_arg(format!("profile.dev.debug={val}")) + .build(); + let debug: TomlDebugInfo = config.get("profile.dev.debug").unwrap(); + assert_eq!(debug, expected, "failed to parse {val}"); + } + } + + let toml_err_cases = ["\"\"", "\"unrecognized\"", "3"]; + for err_val in toml_err_cases { + let config = ConfigBuilder::new() + .config_arg(format!("profile.dev.debug={err_val}")) + .build(); + let err = config + .get::<TomlDebugInfo>("profile.dev.debug") + .unwrap_err(); + assert!(err + .to_string() + .ends_with("could not load config key `profile.dev.debug`")); + } +} |