-
Notifications
You must be signed in to change notification settings - Fork 2
Feat/152 typesafe test infrastructure #208
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
base: main
Are you sure you want to change the base?
Conversation
aa4ab32 to
ceb6699
Compare
|
@tschmidtb51 We added another crate representing the parsed schema. Could you add this |
What is the reasoning behind this? While I am not a complete expert on the rust ecosystem, my feeling is that splitting functionality up between crates without good reasoning is not preferred. Each crate needs its own publishing task (which could theoretically fail) and its own publishing config on crates.io. This can create a mess if one of them fails. It is also harder for the user since they need to maintain versions on two crates, albeit this can be done with automatic tools. But you have to keep in mind that Rust will not "harmonize" dependency versions, i.e., if you use I would propose simply switching the paths from |
|
I think it is ok to split libraries. There are tools like I'm just not sure I understand the split and responsibility of each crate. I think it makes sense to have one crate which focuses on validation. That maybe a lot of code, that only certain users might want to use. Compared to the actual types, which will be used by more people. Splitting up the loader from the types (which is what seems to be case with this PR) doesn't seem like a reasonable idea. I'd rather see the "test" stuff go into a dedicated module or crate. And maybe enable it through a feature flag. To remove it from the "normal" code. So you could have:
I also noted that there are files which are claimed to be generated by An alternative could be to manually generate this and commit the code. Performing the generation step during CI and failing the CI if there is a difference. |
|
Thank you for your feedback.
It doesn't need its own publishing task, only the crate configuration in crates.io. You can see this already in the current build workflow, where there is only one call to
No they don't, or rather only if consumers use explicit versions with
The main reason behind this extraction was to make the code more maintainable and not blow up the build file, and additionally to have the benefit of having the types as a separate package which others can use.
I don't think
I see your point here. What exactly do you mean by loader? The current proposal would exactly do that, split the types into csaf-schema and leave the all the validation in the current crate. I guess we could also move the csaf trait into the schema crate, which would then represent the concrete types for the individual versions and the trait for the abstraction. Here we could opt into the specific functionality for validation via a feature.
As there is no standard in rust to refer to, we can agree to disagree :) I see the point in having generated files in the target folder, but I loose a bit of control over what is there. With committed files a clearly see what changed right away and not only with some errors in other parts of the code. But I like the approach of not doing this in the |
|
I'll pulled out the test infrastructure to a separate PR #221 . This is then only for eventually pulling out the schema generation etc. I'll refactor into a local tool to generate the files/ |
335d9cd to
f440734
Compare
f440734 to
e32ba35
Compare
| Ok(()) | ||
| }, | ||
| (Ok(()), Err(_)) => Err(format!( | ||
| "Test {} case {}: Expected failure but validation passed", |
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.
I think it would be helpful to print the expected errors here.
e32ba35 to
c4342b2
Compare
resolves #152
resolves #174