-
Notifications
You must be signed in to change notification settings - Fork 240
Add tests precollection logic #3922
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
8
commits into
3901-move-free-functions
Choose a base branch
from
3901-tests-precollection
base: 3901-move-free-functions
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.
+106
−9
Open
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
cb03120
Add logic for tests precollection
franciszekjob 5dd210c
Fix linting
franciszekjob c34c522
Fix linting
franciszekjob 9eb7b17
Remove `casm_program` field from `TestTarget`
franciszekjob 56e3f8b
Revert "Remove `casm_program` field from `TestTarget`"
franciszekjob a8af7e6
Simply collection
franciszekjob 3572157
Parralelize `collect_packages_with_tests`
franciszekjob 7999674
Merge branch '3901-move-free-functions' into 3901-tests-precollection
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,18 +128,20 @@ impl TestDetails { | |
| } | ||
| } | ||
|
|
||
| // TODO: Remove in next PRs | ||
| #[derive(Debug, Clone)] | ||
| pub struct TestTarget<C> { | ||
| pub struct TestTargetDeprecated<C> { | ||
| pub tests_location: TestTargetLocation, | ||
| pub sierra_program: ProgramArtifact, | ||
| pub sierra_program_path: Arc<Utf8PathBuf>, | ||
| pub casm_program: Arc<RawCasmProgram>, | ||
| pub test_cases: Vec<TestCase<C>>, | ||
| } | ||
|
|
||
| impl TestTarget<TestCaseWithConfig> { | ||
| // TODO: Remove in next PRs | ||
| impl TestTargetDeprecated<TestCaseWithConfig> { | ||
| #[tracing::instrument(skip_all, level = "debug")] | ||
| pub fn from_raw( | ||
| pub fn from_raw_deprecated( | ||
| test_target_raw: TestTargetRaw, | ||
| tracked_resource: &ForgeTrackedResource, | ||
| ) -> Result<TestTargetWithConfig> { | ||
|
|
@@ -200,7 +202,7 @@ impl TestTarget<TestCaseWithConfig> { | |
| test_cases, | ||
| sierra_program: test_target_raw.sierra_program, | ||
| sierra_program_path: test_target_raw.sierra_program_path.into(), | ||
| casm_program, | ||
| casm_program: casm_program, | ||
| }) | ||
| } | ||
| } | ||
|
|
@@ -211,3 +213,72 @@ pub struct TestCase<C> { | |
| pub name: String, | ||
| pub config: C, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone)] | ||
| pub struct TestTarget<T> { | ||
| pub tests_location: TestTargetLocation, | ||
| pub sierra_program: ProgramArtifact, | ||
| pub sierra_program_path: Arc<Utf8PathBuf>, | ||
| pub casm_program: Option<Arc<RawCasmProgram>>, | ||
| pub test_cases: Vec<T>, | ||
| } | ||
|
|
||
| impl TestTarget<TestCandidate> { | ||
| #[tracing::instrument(skip_all, level = "debug")] | ||
| pub fn from_raw(test_target_raw: TestTargetRaw) -> Result<TestTarget<TestCandidate>> { | ||
| macro_rules! by_id { | ||
| ($field:ident) => {{ | ||
| let temp: HashMap<_, _> = test_target_raw | ||
| .sierra_program | ||
| .program | ||
| .$field | ||
| .iter() | ||
| .map(|f| (f.id.id, f)) | ||
| .collect(); | ||
|
|
||
| temp | ||
| }}; | ||
| } | ||
| let funcs = by_id!(funcs); | ||
| let type_declarations = by_id!(type_declarations); | ||
|
|
||
| let sierra_program_registry = | ||
| ProgramRegistry::<CoreType, CoreLibfunc>::new(&test_target_raw.sierra_program.program)?; | ||
| let type_size_map = get_type_size_map( | ||
| &test_target_raw.sierra_program.program, | ||
| &sierra_program_registry, | ||
| ) | ||
| .ok_or_else(|| anyhow!("can not get type size map"))?; | ||
|
|
||
| let default_executables = vec![]; | ||
| let debug_info = test_target_raw.sierra_program.debug_info.clone(); | ||
| let executables = debug_info | ||
| .as_ref() | ||
| .and_then(|info| info.executables.get("snforge_internal_test_executable")) | ||
| .unwrap_or(&default_executables); | ||
|
|
||
| let test_cases = executables | ||
| .par_iter() | ||
| .map(|case| { | ||
| let func = funcs[&case.id]; | ||
| let name = case.debug_name.clone().unwrap().into(); | ||
| let test_details = TestDetails::build(func, &type_declarations, &type_size_map); | ||
|
|
||
| Ok(TestCandidate { name, test_details }) | ||
| }) | ||
| .collect::<Result<_>>()?; | ||
|
|
||
| Ok(TestTarget { | ||
| tests_location: test_target_raw.tests_location, | ||
| test_cases, | ||
| sierra_program: test_target_raw.sierra_program, | ||
| sierra_program_path: test_target_raw.sierra_program_path.into(), | ||
| casm_program: None, | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| pub struct TestCandidate { | ||
| pub name: String, | ||
| pub test_details: TestDetails, | ||
| } | ||
|
Comment on lines
+281
to
+284
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: We can easily add |
||
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
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
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.
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.
note: It's the same as
from_raw_deprecatedbut: