Skip to content

Commit

Permalink
Merge #1087
Browse files Browse the repository at this point in the history
1087: Fix env list parsing r=Aurel300 a=zgrannan

Prusti did not accept `Vec<String>` arguments passed as environment variables. This PR fixes that.

As an example, with the export `export PRUSTI_EXTRA_VERIFIER_ARGS="--proverEnableResourceBounds"`,

Prusti would crash saying:

```
thread 'rustc' panicked at 'Failed to read setting "extra_verifier_args"', prusti-common/src/config.rs:242:51
```

This PR also makes that error more descriptive (revealing the underlying error from config-rs)

Co-authored-by: Zack Grannan <[email protected]>
  • Loading branch information
bors[bot] and zgrannan authored Jul 19, 2022
2 parents 3a707bc + 0767831 commit 07c60b1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions prusti-common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,14 @@ lazy_static::lazy_static! {

// 4. Override with env variables (`PRUSTI_VIPER_BACKEND`, ...)
settings.merge(
Environment::with_prefix("PRUSTI").ignore_empty(true)
Environment::with_prefix("PRUSTI")
.ignore_empty(true)
.try_parsing(true)
.with_list_parse_key("delete_basic_blocks")
.with_list_parse_key("extra_jvm_args")
.with_list_parse_key("extra_verifier_args")
.with_list_parse_key("verify_only_basic_block_path")
.list_separator(" ")
).unwrap();
check_keys(&settings, &allowed_keys, "environment variables");

Expand Down Expand Up @@ -241,7 +248,7 @@ fn read_setting<T>(name: &'static str) -> T
where
T: Deserialize<'static>,
{
read_optional_setting(name).unwrap_or_else(|| panic!("Failed to read setting {:?}", name))
SETTINGS.read().unwrap().get(name).unwrap_or_else(|e| panic!("Failed to read setting {} due to {}", name, e))
}

// The following methods are all convenience wrappers for the actual call to
Expand Down

0 comments on commit 07c60b1

Please sign in to comment.