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 failing test for pre-release and backtracking behavior #3038

Closed
wants to merge 1 commit into from
Closed

Add failing test for pre-release and backtracking behavior #3038

wants to merge 1 commit into from

Conversation

mpizenberg
Copy link

@mpizenberg mpizenberg commented Jun 27, 2021

Hi, I have been spending a lot of time on a Rust port of pubgrub and stumbled upon a tricky case regarding handling of pre-releases and backtracking behavior. In particular, due to the creation of NoVersions incompatibilities potentially preventing the selection of a pre-release version after backtracking.

So I've checked how pub handles this by adding a test and it seems that pub fails to solve dependencies in that situation. Here is the test I've added:

  test('unable to backtrack to pre-release after NoVersions', () async {
    await servePackages((builder) {
      builder.serve('a', '1.1.0', deps: {'b': '^1.0.0'});
      builder.serve('b', '1.0.0', deps: {'c': '^1.0.0'});
      builder.serve('c', '0.9.0');
      builder.serve('b', '1.1.0-alpha');
      builder.serve('a', '1.0.0', deps: {'b': '^1.1.0-alpha'});
    });

    await d.appDir({
      'a': '^1.0.0',
    }).create();
    await expectResolves();
    // fails though I would have expected it to succeed with either
    // a 1.0.0, b 1.1.0-alpha or
    // a 1.1.0, b 1.1.0-alpha
  });

It consists of putting the solver on the wrong track by making it pick a 1.1.0 followed by b 1.0.0 then realizing that there is no compatible c. At that moment, it should backtrack and remember the wrong decision with NoVersions incompatibilities. The issue is that it seems to create knowledge preventing it to pick the b 1.1.0-alpha pre-release while it's a totally valid version after backtracking.

What are your thoughts on this?

@google-cla
Copy link

google-cla bot commented Jun 27, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Jun 27, 2021
@jonasfj jonasfj added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Jun 28, 2021
@sigurdm
Copy link
Contributor

sigurdm commented Aug 24, 2021

I included this test in: #3078

@sigurdm sigurdm closed this Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants