-
-
Notifications
You must be signed in to change notification settings - Fork 131
feat: nextest profile inheritance #2786
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
…error handling to inherits setting
…ondensed into a macro)
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2786 +/- ##
==========================================
+ Coverage 80.12% 80.31% +0.19%
==========================================
Files 113 114 +1
Lines 26167 26458 +291
==========================================
+ Hits 20966 21250 +284
- Misses 5201 5208 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…s graph (isolated nodes are treated as SCC)
|
Hi @sunshowers, whenever you are able to, could you take a look at this PR in introducing profile inheritance? The inheritance cycle detection is a little bit verbose due to how isolated nodes without edges are considered as SCCs by I'll also add tests for profile inheritance (testing for cycles, nonexistent profile to inherit from, and whether config fields are appropriately filled in from an inherited profile) later today as well. |
|
Can you just check for any SCCs with 2 or more nodes? That's how I've done this in the past. |
|
Isn't it possible for there to be a self referential SCC if the user sets the inherits to the current profile? |
|
Ah I think we should just reject that case separately, no good reason to even try to model it or support it. |
|
I think I'm having a hard time finding out on how to do this in a neat and efficient manner. Earlier, I wanted to use Instead of doing that, in the current implementation, I'm grabbing all nodes that are not isolated and inserting them into a new graph (which I'm not too sure if the way I'm doing this right now is the neatest way to do this). From reading through the docs in The one thing that comes up to my head is that I could do an earlier check here: // For each custom profile, we add a directed edge from the inherited node
// to the current custom profile node
for (profile_name, profile) in &self.other_profiles {
if let Some(inherit_name) = &profile.inherits
&& let (Some(&from), Some(&to)) =
(profile_map.get(inherit_name), profile_map.get(profile_name))
{
profile_graph.add_edge(from, to, ());
}
}to detect self referential SCCs and append it in a vec of cyclic inherited profile nodes and not insert it into the graph. This way, all non-isolated nodes are guaranteed to be in a chain of 2 or more nodes and I could create a new graph around this. Just so I'm understanding correctly, when you say reject the self referential SCC case separately, do you want it's own error message to be thrown or should it be bundled up with all other detected SCCs? My understanding from zohkcat's PR is that you would find it nice for all SCCs to be printed out. The current implementation here does that through using I also had a couple of questions regarding error handling for
How did you approach checking for SCCs with 2 or more nodes personally? Edit: My apologies if I'm bombarding you with a lot of questions on this! |
|
I think this can be way simpler than what you're imagining. There are 4 properties which need to be verified:
1, 2, and 3 don't need the construction of a graph at all, so check for them at the beginning. Then, construct a reduced graph with each node being a profile and each edge being an inherits relationship not rejected by any of the 1/2/3 checks above. (Include the implicit inherits relationship from each non-default profile to the default profile if Then, the only remaining check is:
These 4 properties together should establish the overall invariant that the inheritance graph is well-formed (acyclic, and nothing points to unknown nodes.) You don't need to remove nodes or anything at any point, just break it up into graph and non-graph checks. To report errors here I'd use an "error collector" or "diagnostic sink" pattern. Pass in a Hope this helps. |
|
I appreciate the advice and I agree with your properties and error handling here (didn't think about the error collector pattern!). I have a couple of follow up questions to ask on this.
Edit: Correction on SCC, I think I got it wrong. It should be {C} instead of {A, B, C} for the first and {C, D, E} instead of {A, B, C, D, E} for the second one, but still curious about how reporting errors for inheritance chain cycles should work. |
|
Can you just report the entire SCC? And definitely prioritize property 2. |
… refactored code (TODO: test cases)
|
@sunshowers, I modified the code to follow the properties we talked about earlier and added a couple of test cases. Let me know if there's anything I should change or if there are any other test cases I should add here! |
This PR implements a way for nextest profiles to inherit from other profiles as mentioned in #387.