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

rustup_mode: add toolchain install --allow-downgrade option #2126

Merged
merged 1 commit into from
Nov 29, 2019

Conversation

payload
Copy link
Contributor

@payload payload commented Nov 12, 2019

In case you have an already installed nightly toolchain
and you want to install a nightly toolchain with a component
which is not available in the installed toolchain,
rustup is searching for the most recent nightly supporting
all requested components and which is not older than the currently
installed nightly.

With this option set it will also search for toolchains older
than the currently installed one.

  • add a test for downgrading

Should fix #2067

@kinnison kinnison changed the title fix #2067 rustup_mode: add toolchain install --allow-downgrade option WIP: rustup_mode: add toolchain install --allow-downgrade option Nov 12, 2019
Copy link
Contributor

@kinnison kinnison left a comment

Choose a reason for hiding this comment

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

Some initial feedback.

src/dist/dist.rs Outdated Show resolved Hide resolved
src/dist/dist.rs Outdated Show resolved Hide resolved
@kinnison kinnison added this to the 1.21.0 milestone Nov 12, 2019
@payload payload changed the title WIP: rustup_mode: add toolchain install --allow-downgrade option rustup_mode: add toolchain install --allow-downgrade option Nov 12, 2019
src/dist/dist.rs Outdated Show resolved Hide resolved
@payload
Copy link
Contributor Author

payload commented Nov 14, 2019

The failed CI run ended with the message:


Copying from /checkout/target/x86_64-unknown-linux-gnu/release/rustup-init to /checkout/target/x86_64-unknown-linux-gnu/tests/running-test-ryUcXF/rustup-exeTGkmi4/rustup

running "/checkout/target/x86_64-unknown-linux-gnu/tests/running-test-ryUcXF/rustup-exeTGkmi4/rustup" "set" "default-host" "x86_64-unknown-linux-gnu"

thread 'env_override_beats_file_override' panicked at 'failed to run test command: Os { code: 26, kind: Other, message: "Text file busy" }', src/libcore/result.rs:1165:5

I consider this flakyness of the underlying system, probably some filesystem hickup. I don't know if it is probably related to code in rustup set default-host which could be more robust against yet uncertain filesystem races.

@kinnison what do you think of it?

@kinnison
Copy link
Contributor

@payload Yes that's a transient issue I only ever tend to see on Travis. As such I've not managed to track it down to where it actually happens to add a retry in for that case.

Copy link
Contributor

@kinnison kinnison left a comment

Choose a reason for hiding this comment

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

For the test, I'd be tempted to add the --allow-downgrade variant to the end of the longer test, so that the scenario plays out in full as:

  1. Install
    2 Check for rls -- should not be present
  2. Attempt to add rls -- this should fail
  3. Attempt to add rls with downgrate permitted -- this should succeed
  4. Check for rls -- should be present
  5. Check hash for rustc -- should have downgraded

@kinnison kinnison self-assigned this Nov 23, 2019
Copy link
Contributor

@kinnison kinnison left a comment

Choose a reason for hiding this comment

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

Pretty close to mergeable -- some more test ideas. Nice job 👍

src/cli/rustup_mode.rs Outdated Show resolved Hide resolved
"component 'rls' for target '{}' is unavailable for download for channel nightly",
trip,
),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps here add a check that the rls component is not installed You can do that with:

expect_component_not_executable(config, "rls");

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although I added it I would rather see that in a different testcase which checks if toolchain install does not change anything without allow-downgrade. When I look at the subcommand toolchain install I see 7 arguments and would expect at least as many as 7 tests at the level of cli-v2.rs, but there are not. Or else I don't know yet about all the test levels. Well that's obvious :)

"nightly",
"--no-self-update",
],
);
Copy link
Contributor

Choose a reason for hiding this comment

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

After this, I'd add an expect to check the rustc version is the version we expect (i.e. one without rls)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I add that. It is though like a sanity check to find out if our test setup is based on the right assumptions.

"--allow-downgrade",
],
);
expect_stdout_ok(config, &["rustc", "--version"], "hash-nightly-2");
Copy link
Contributor

Choose a reason for hiding this comment

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

While this is useful to check that it did downgrade, that'd be clearer if you'd done the equivalent above as commented. Also you could usefully assert that the rls component is now available via expect_component_executable()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like the expect_component_executable check much more than the version check. Thx

Copy link
Contributor

@kinnison kinnison left a comment

Choose a reason for hiding this comment

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

This looks pretty good now. Could you please rebase to clean up the commits? I'd like to see a commit for the code and a commit for the tests at minimum. Once that's done, I'll give it a final once-over but I think this very close to mergeable

In case you have an already installed nightly toolchain
and you want to install a nightly toolchain with a component
which is not available in the installed toolchain,
rustup is searching for the most recent nightly supporting
all requested components and which is not older than the currently
installed nightly.

With this option set it will also search for toolchains older
than the currently installed one.
@payload
Copy link
Contributor Author

payload commented Nov 26, 2019

@kinnison squashed it together. I have put the code change and its test together. When you split the test from the implementation it is less clear what belongs together. One reason to split test from implementation is of course to put the test before the implementation so you see the test failing first. Do you mean to put a separate test commit before the implementation commit?

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.

[Feature Request] Downgrading nightly toolchains
2 participants