Skip to content
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

Add test for embedded requirements #748

Merged
merged 3 commits into from
Jun 22, 2023
Merged

Add test for embedded requirements #748

merged 3 commits into from
Jun 22, 2023

Conversation

jrray
Copy link
Collaborator

@jrray jrray commented Jun 10, 2023

Checking solver behavior before the changes in #744. I happened on this while trying to improve the test code coverage of the validators.

@rydrman this test should be passing, yes? I've double and triple checked that the mypkg definition is a valid spec.

@jrray
Copy link
Collaborator Author

jrray commented Jun 10, 2023

Ugh okay I think I see the problem, after lifting this out of the other branch there won't be a request for dep-e1:comp1 or dep-e1:comp2 here. Let me update it.

@jrray jrray force-pushed the embedded-requirements-test branch from 65998fd to 62b097f Compare June 10, 2023 01:22
@jrray
Copy link
Collaborator Author

jrray commented Jun 10, 2023

Okay, now it should be in a state where the test should pass, but it still fails.

@jrray jrray force-pushed the embedded-requirements-test branch from 62b097f to b59cdf5 Compare June 10, 2023 01:29
Add test to exercise this behavior.

Signed-off-by: J Robert Ray <[email protected]>
@jrray jrray force-pushed the embedded-requirements-test branch from b59cdf5 to f00ebb1 Compare June 10, 2023 01:42
]
];

changes.extend(self.components_to_changes(embedded.components(), embedded.ident()));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this one addition will make the tests pass. I cribbed this from what resolve_package does, and now I wonder if it would be more correct to do all the things that resolve_package does here too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure it would be more correct, so I went ahead and implemented that.

@jrray jrray requested a review from rydrman June 10, 2023 02:00
@codecov
Copy link

codecov bot commented Jun 10, 2023

Codecov Report

Merging #748 (4f6ebcb) into main (0943b48) will increase coverage by 0.10%.
The diff coverage is 95.00%.

@@            Coverage Diff             @@
##             main     #748      +/-   ##
==========================================
+ Coverage   53.68%   53.78%   +0.10%     
==========================================
  Files         237      237              
  Lines       19101    19102       +1     
==========================================
+ Hits        10254    10274      +20     
+ Misses       8847     8828      -19     
Impacted Files Coverage Δ
crates/spk-solve/src/macros.rs 100.00% <ø> (ø)
crates/spk-solve/crates/graph/src/graph.rs 85.30% <95.00%> (-0.16%) ⬇️

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

The logic for using `Change::SetPackage` correctly needs to also be used
when adding an embedded package to the solution.

Signed-off-by: J Robert Ray <[email protected]>
@jrray jrray self-assigned this Jun 10, 2023
@rydrman
Copy link
Collaborator

rydrman commented Jun 10, 2023

I'm not actually sure that requirements on embedded packages was allowed in the past - which might explain why this was not passing... but I'd have to go back and check. Originally, the fields that were allowed for embedded packages was quite limited, but it may have changed over time I don't really remember.

Regardless, this change seems appropriate if we want to allow this - though it might be worth thinking about whether it should be allowed if we haven't technically supported it in the past.

This probably shouldn't be allowed, but it currently works.

Signed-off-by: J Robert Ray <[email protected]>
@jrray
Copy link
Collaborator Author

jrray commented Jun 10, 2023

An embedded package needs to be able to masquerade as a real package, so it should have all the capabilities of a real package. Where it gets iffy for me is allowing an embedded package to embed packages.

@jrray
Copy link
Collaborator Author

jrray commented Jun 10, 2023

which might explain why this was not passing...

Oh, the test was failing because it wasn't adding the requirement. Not because the spec parser was rejecting an illegal construct, like how it will reject an embedded package specifying build options.

@jrray
Copy link
Collaborator Author

jrray commented Jun 10, 2023

This came up because I was trying to create a test that would hit

https://github.com/imageworks/spk/blob/fe4dbf24ca0059e788255edbab31500e93d1e2e7/crates/spk-solve/crates/validation/src/validation.rs#L679-L685

but so far I haven't be able to come up with a test that reaches this code. None of the current tests hit this.

@jrray
Copy link
Collaborator Author

jrray commented Jun 10, 2023

#744 effectively disables nested embedded packages because it closes the loophole of being allowed to define them inside an embedded package via install.components[].embedded.

Copy link
Collaborator

@rydrman rydrman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC this is the test that gets deleted in a later branch as per your comment

@jrray
Copy link
Collaborator Author

jrray commented Jun 21, 2023

IIRC this is the test that gets deleted in a later branch as per your comment

One of them is.

@jrray jrray merged commit db01f88 into main Jun 22, 2023
@jrray jrray deleted the embedded-requirements-test branch June 22, 2023 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants