generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 142
Fix workspace feature handling to filter features per-package #4545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tautschnig
wants to merge
2
commits into
model-checking:main
Choose a base branch
from
tautschnig:fix-4544
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,6 @@ | ||
| # Copyright Kani Contributors | ||
| # SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| [workspace] | ||
| members = ["mylib", "mytests"] | ||
| resolver = "2" |
This file contains hidden or 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: workspace_features.sh | ||
| expected: workspace_features.expected |
11 changes: 11 additions & 0 deletions
11
tests/script-based-pre/workspace_features/mylib/Cargo.toml
This file contains hidden or 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 = "mylib" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
|
|
||
| # This package has NO features defined intentionally | ||
| # to test that --workspace --features works when some packages | ||
| # don't have the requested features |
14 changes: 14 additions & 0 deletions
14
tests/script-based-pre/workspace_features/mylib/src/lib.rs
This file contains hidden or 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,14 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| //! A simple library without any features defined. | ||
|
|
||
| pub fn add(a: u32, b: u32) -> u32 { | ||
| a + b | ||
| } | ||
|
|
||
| #[kani::proof] | ||
| fn check_add() { | ||
| let result = add(1, 2); | ||
| assert!(result == 3); | ||
| } |
13 changes: 13 additions & 0 deletions
13
tests/script-based-pre/workspace_features/mytests/Cargo.toml
This file contains hidden or 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 | ||
|
|
||
| [package] | ||
| name = "mytests" | ||
| version = "0.1.0" | ||
| edition = "2021" | ||
|
|
||
| [features] | ||
| use_mylib = [] | ||
|
|
||
| [dependencies] | ||
| mylib = { path = "../mylib" } |
19 changes: 19 additions & 0 deletions
19
tests/script-based-pre/workspace_features/mytests/src/lib.rs
This file contains hidden or 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,19 @@ | ||
| // Copyright Kani Contributors | ||
| // SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| //! A test crate with the use_mylib feature defined. | ||
|
|
||
| #[cfg(feature = "use_mylib")] | ||
| use mylib::add; | ||
|
|
||
| #[cfg(feature = "use_mylib")] | ||
| #[kani::proof] | ||
| fn check_mylib_add() { | ||
| let result = add(2, 3); | ||
| assert!(result == 5); | ||
| } | ||
|
|
||
| #[kani::proof] | ||
| fn check_basic() { | ||
| assert!(1 + 1 == 2); | ||
| } |
3 changes: 3 additions & 0 deletions
3
tests/script-based-pre/workspace_features/workspace_features.expected
This file contains hidden or 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,3 @@ | ||
| Checking harness check_mylib_add... | ||
| VERIFICATION:- SUCCESSFUL | ||
| All workspace feature tests passed | ||
26 changes: 26 additions & 0 deletions
26
tests/script-based-pre/workspace_features/workspace_features.sh
This file contains hidden or 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,26 @@ | ||
| #!/usr/bin/env bash | ||
| # Copyright Kani Contributors | ||
| # SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
|
||
| # Test that cargo kani --workspace --features works correctly when some | ||
| # workspace members don't declare the requested features. | ||
| # This is a regression test for the issue where cargo kani fails with | ||
| # "none of the selected packages contains these features" when using | ||
| # --workspace --features with a workspace containing packages that don't | ||
| # all have the same features. | ||
|
|
||
| set -e | ||
|
|
||
| rm -rf target | ||
|
|
||
| # Test with a feature that only exists in mytests, not in mylib | ||
| cargo kani --workspace --features use_mylib | ||
|
|
||
| # Test with --no-default-features flag | ||
| cargo kani --workspace --no-default-features | ||
|
|
||
| # Test combination of flags | ||
| cargo kani --workspace --no-default-features --features use_mylib | ||
|
|
||
| rm -rf target | ||
| echo "All workspace feature tests passed" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.