Skip to content

Commit 0805270

Browse files
authored
Allow cargo-kani to run outside a Cargo project (rust-lang#1192)
* Allow cargo-kani to run outside a Cargo project * Add test in docker
1 parent 8c848e2 commit 0805270

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.github/workflows/kani.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ jobs:
103103
- name: Run installed tests
104104
if: ${{ matrix.os == 'ubuntu-20.04' }}
105105
run: |
106+
docker run kani-latest cargo kani --version
106107
docker run -w /tmp/kani/tests/cargo-kani/simple-lib kani-latest cargo kani
107108
docker run -w /tmp/kani/tests/cargo-kani/simple-visualize kani-latest cargo kani
108109
docker run -w /tmp/kani/tests/cargo-kani/build-rs-works kani-latest cargo kani

kani-driver/src/args_toml.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ use toml::Value;
1313
///
1414
/// The arguments passed via command line have precedence over the ones from the Cargo.toml.
1515
pub fn join_args(input_args: Vec<OsString>) -> Result<Vec<OsString>> {
16-
let file = std::fs::read_to_string(cargo_locate_project()?)?;
16+
let toml_path = cargo_locate_project();
17+
if toml_path.is_err() {
18+
// We're not inside a Cargo project. Don't error... yet.
19+
return Ok(input_args);
20+
}
21+
let file = std::fs::read_to_string(toml_path?)?;
1722
let (kani_args, cbmc_args) = toml_to_args(&file)?;
1823
merge_args(input_args, kani_args, cbmc_args)
1924
}

0 commit comments

Comments
 (0)