Skip to content

Commit

Permalink
cargo: Bump config to 0.14.0
Browse files Browse the repository at this point in the history
Update `config` to the latest minor version.

The latest version of `config` adds more detailed error information and
platform-specific file paths that require updates to snapshot tests.
More significantly, environment config variables are no longer
case-sensitive[1]. Internally they are down-cased, so we must adjust
`test_command_args` to set lowercase environment variables.

In addition, the newly added `config::Value::origin()` method exposes
the path of config files.

[1] mehcode/config-rs#354
  • Loading branch information
Will Chandler committed Feb 13, 2024
1 parent 2701791 commit a5c67b2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
27 changes: 21 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -38,7 +38,7 @@ chrono = { version = "0.4.34", default-features = false, features = [
"std",
"clock",
] }
config = { version = "0.13.4", default-features = false, features = ["toml"] }
config = { version = "0.14.0", default-features = false, features = ["toml"] }
criterion = "0.5.1"
crossterm = { version = "0.27", default-features = false }
digest = "0.10.7"
Expand Down
4 changes: 2 additions & 2 deletions cli/src/config.rs
Expand Up @@ -584,8 +584,8 @@ mod tests {
command_args,
CommandNameAndArgs::Structured {
env: hashmap! {
"KEY1".to_string() => "value1".to_string(),
"KEY2".to_string() => "value2".to_string(),
"key1".to_string() => "value1".to_string(),
"key2".to_string() => "value2".to_string(),
},
command: NonEmptyCommandArgsVec(["emacs", "-nw",].map(|s| s.to_owned()).to_vec())
}
Expand Down
10 changes: 6 additions & 4 deletions cli/tests/test_config_command.rs
Expand Up @@ -628,14 +628,16 @@ fn test_config_get() {
"###);

let stdout = test_env.jj_cmd_failure(test_env.env_root(), &["config", "get", "table.list"]);
insta::assert_snapshot!(stdout, @r###"
Config error: invalid type: sequence, expected a value convertible to a string
insta::with_settings!({filters => vec![(r"config[/\\]config0002.toml", "config/config0002.toml")]}, {
insta::assert_snapshot!(stdout, @r###"
Config error: invalid type: sequence, expected a value convertible to a string for key `table.list` in config/config0002.toml
For help, see https://github.com/martinvonz/jj/blob/main/docs/config.md.
"###);
"###)
});

let stdout = test_env.jj_cmd_failure(test_env.env_root(), &["config", "get", "table"]);
insta::assert_snapshot!(stdout, @r###"
Config error: invalid type: map, expected a value convertible to a string
Config error: invalid type: map, expected a value convertible to a string for key `table`
For help, see https://github.com/martinvonz/jj/blob/main/docs/config.md.
"###);

Expand Down
8 changes: 7 additions & 1 deletion cli/tests/test_global_opts.rs
Expand Up @@ -386,7 +386,13 @@ fn test_invalid_config() {
test_env.add_config("[section]key = value-missing-quotes");
let stderr = test_env.jj_cmd_failure(test_env.env_root(), &["init", "repo"]);
insta::assert_snapshot!(stderr.replace('\\', "/"), @r###"
Config error: expected newline, found an identifier at line 1 column 10 in config/config0002.toml
Config error: TOML parse error at line 1, column 10
|
1 | [section]key = value-missing-quotes
| ^
invalid table header
expected newline, `#`
in config/config0002.toml
For help, see https://github.com/martinvonz/jj/blob/main/docs/config.md.
"###);
}
Expand Down

0 comments on commit a5c67b2

Please sign in to comment.