-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support fully-qualified --package arguments (#3593)
We were previously matching the name of the package, which would limit users if the name is ambiguous. Instead, use `cargo pkgid` to validate the `--package` argument and to retrieve the package id. Resolves #3563 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Zyad Hassan <[email protected]>
- Loading branch information
1 parent
373af49
commit 5e67b63
Showing
9 changed files
with
156 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
error: couldn't find package `unknown_package` | ||
error: package ID specification `unknown_package` did not match any packages | ||
error: Failed to retrieve information for `unknown_package` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
error: couldn't find package `unknown_package` | ||
error: package ID specification `unknown_package` did not match any packages | ||
error: Failed to retrieve information for `unknown_package` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
[package] | ||
name = "zerocopy" | ||
version = "0.0.1" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
zerocopy = "=0.8.4" | ||
|
||
[workspace] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
# Test how Kani handle ambiguous crate names. | ||
|
||
rm -rf target | ||
set -e | ||
cargo kani --output-format terse && echo "No package is needed" | ||
cargo kani -p [email protected] --output-format terse && echo "But passing the correct package works" | ||
|
||
# These next commands should fail so disable failures | ||
set +e | ||
cargo kani -p zerocopy || echo "Found expected ambiguous crate error" | ||
cargo kani -p [email protected] || echo "Found expected out of workspace error" | ||
|
||
rm -rf target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright Kani Contributors | ||
# SPDX-License-Identifier: Apache-2.0 OR MIT | ||
script: ambiguous.sh | ||
expected: expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Complete - 1 successfully verified harnesses, 0 failures, 1 total\ | ||
No package is needed | ||
|
||
Complete - 1 successfully verified harnesses, 0 failures, 1 total\ | ||
But passing the correct package works | ||
|
||
error: There are multiple `zerocopy` packages in your project, and the specification `zerocopy` is ambiguous. | ||
Please re-run this command with one of the following specifications: | ||
[email protected] | ||
[email protected] | ||
error: Failed to retrieve information for `zerocopy` | ||
Found expected ambiguous crate error | ||
|
||
error: The following specified packages were not found in this workspace: `[email protected]` | ||
Found expected out of workspace error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright Kani Contributors | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
// | ||
//! Test that cargo kani works when there are ambiguous packages. | ||
//! See <https://github.com/model-checking/kani/issues/3563> | ||
use zerocopy::FromZeros; | ||
|
||
#[kani::proof] | ||
fn check_zero_copy() { | ||
let opt = Option::<&char>::new_zeroed(); | ||
assert_eq!(opt, None); | ||
} |