-
Notifications
You must be signed in to change notification settings - Fork 244
Add test function
#3915
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
franciszekjob
wants to merge
10
commits into
master
Choose a base branch
from
3901-add-test-function
base: master
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.
+63
−44
Open
Add test function
#3915
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b2639c4
Add `test` function
franciszekjob 640293f
Merge branch 'master' of https://github.com/foundry-rs/starknet-found…
franciszekjob 22ac37f
Merge branch 'master' of https://github.com/foundry-rs/starknet-found…
franciszekjob bd51ff3
Fixes
franciszekjob bf72b84
Revert "Fixes"
franciszekjob 8954f15
Fixes
franciszekjob 3f3cb4d
Formatting
franciszekjob 0fa273b
Fix linting
franciszekjob 6ca8fc0
Fix linting
franciszekjob 9fe90b3
Merge branch 'master' into 3901-add-test-function
franciszekjob 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
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,52 @@ | ||
| use crate::profile_validation::check_profile_compatibility; | ||
| use crate::run_tests::workspace::run_for_workspace; | ||
| use crate::warn::warn_if_snforge_std_does_not_match_package_version; | ||
| use crate::warn::{ | ||
| error_if_snforge_std_deprecated_missing, error_if_snforge_std_deprecated_not_compatible, | ||
| error_if_snforge_std_not_compatible, warn_if_backtrace_without_panic_hint, | ||
| warn_if_snforge_std_deprecated_does_not_match_package_version, | ||
| }; | ||
| use crate::{ColorOption, ExitStatus, MINIMAL_SCARB_VERSION_FOR_V2_MACROS_REQUIREMENT, TestArgs}; | ||
| use anyhow::Result; | ||
| use foundry_ui::UI; | ||
| use scarb_api::metadata::MetadataOpts; | ||
| use scarb_api::metadata::metadata_with_opts; | ||
| use scarb_api::version::scarb_version; | ||
| use std::{env, sync::Arc}; | ||
|
|
||
| #[tracing::instrument(skip_all, level = "debug")] | ||
| pub async fn test(args: TestArgs, ui: Arc<UI>) -> Result<ExitStatus> { | ||
| set_color_envs(&args.color); | ||
|
|
||
| let scarb_metadata = metadata_with_opts(MetadataOpts { | ||
| profile: args.scarb_args.profile.specified(), | ||
| ..MetadataOpts::default() | ||
| })?; | ||
|
|
||
| check_profile_compatibility(&args, &scarb_metadata)?; | ||
|
|
||
| let scarb_version = scarb_version()?.scarb; | ||
|
|
||
| if scarb_version >= MINIMAL_SCARB_VERSION_FOR_V2_MACROS_REQUIREMENT { | ||
| error_if_snforge_std_not_compatible(&scarb_metadata)?; | ||
| warn_if_snforge_std_does_not_match_package_version(&scarb_metadata, &ui)?; | ||
| } else { | ||
| error_if_snforge_std_deprecated_missing(&scarb_metadata)?; | ||
| error_if_snforge_std_deprecated_not_compatible(&scarb_metadata)?; | ||
| warn_if_snforge_std_deprecated_does_not_match_package_version(&scarb_metadata, &ui)?; | ||
| } | ||
|
|
||
| warn_if_backtrace_without_panic_hint(&scarb_metadata, &ui); | ||
|
|
||
| run_for_workspace(&scarb_metadata, args, ui).await | ||
| } | ||
|
|
||
| fn set_color_envs(color: &ColorOption) { | ||
| match color { | ||
| // SAFETY: This runs in a single-threaded environment. | ||
| ColorOption::Always => unsafe { env::set_var("CLICOLOR_FORCE", "1") }, | ||
| // SAFETY: This runs in a single-threaded environment. | ||
| ColorOption::Never => unsafe { env::set_var("CLICOLOR", "0") }, | ||
| ColorOption::Auto => (), | ||
| } | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably should be attached on
UI