rust-config: demonstrate a bug when falling back to non-trivial default values
The default value (when the user hasn't configured anything) is not run
through the value parser, causing a programming error to happen because
of type mismatch. This will be fixed in the next commit.
--- a/rust/hg-core/src/config/mod.rs Fri Aug 18 14:34:29 2023 +0200
+++ b/rust/hg-core/src/config/mod.rs Tue Aug 08 14:14:00 2023 +0200
@@ -773,4 +773,13 @@
assert!(config.get_u32(b"section2", b"not-count").is_err());
assert!(config.get_byte_size(b"section2", b"not-size").is_err());
}
+
+ #[test]
+ fn test_default_parse() {
+ let config = Config::load_from_explicit_sources(vec![])
+ .expect("expected valid config");
+ let ret = config.get_byte_size(b"cmdserver", b"max-log-size");
+ // FIXME should be `is_ok`
+ assert!(ret.is_err(), "{:?}", ret);
+ }
}