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

Use "true" for force_update in relevant install_from_dist calls in config.rs #2074

Merged

Conversation

BeniCheni
Copy link
Contributor

... there're three sites which call install_from_dist() in the config.rs::Cfg code, and the one in update_all_channels() should be left alone. As such there are two sites to amend a boolean ...

The difficulty will be in devising a nice set of tests to verify that this works ...

This PR resolves #2068 by updating the force_update param from false to true in relevant install_from_dist() calls in config.rs, and provides two tests to mimic the users cases where these install_from_dist calls would occur. (Could update the tests better under review guidance. Thanks in advance.)

@BeniCheni BeniCheni force-pushed the install-from-dist-w-force-update-from-cfg branch 3 times, most recently from af62fcd to 6d26dfa Compare October 19, 2019 02:21
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.

The implementation is good; but are you certain that the tests fail if you don't have the src/config.rs change?

@BeniCheni
Copy link
Contributor Author

BeniCheni commented Oct 19, 2019

@kinnison, I've done some local testing using latest master without src/config.rs change, and then using the current branch with the change.

Below seems to validate that rustup run --install nightly-2019-07-12 cargo -V would fail in master, and would install the missing toolchain correctly in the PR branch.

Please let me know if there are other ways you'd like me to test to validate more. Thanks.

`master` version failed the download
# ~/github/rustup.rs on git:master
→ rustup -V                                       
rustup 1.20.2+20 (6dbf494bb 2019-10-19)

# ~/github/rustup.rs on git:master
→ rustup toolchain uninstall nightly-2019-07-12                    
info: no toolchain installed for 'nightly-2019-07-12-x86_64-apple-darwin'

# ~/github/rustup.rs on git:master
→ rustup run --install nightly-2019-07-12 cargo -V                           
info: syncing channel updates for 'nightly-2019-07-12-x86_64-apple-darwin'
info: latest update on 2019-07-12, rust version 1.38.0-nightly (4bb6b4a5e 2019-07-11)
error: component 'clippy' for target 'x86_64-apple-darwin' is unavailable for download for channel nightly-2019-07-12
PR version installed
  • "warning: Force-skipping unavailable component 'clippy-x86_64-apple-darwin'" message seems to confirm the force flag being truthy to help the install
# ~/github/rustup.rs on git:install-from-dist-w-force-update-from-cfg
→ rustup -V                        
rustup 1.20.2+21 (50206cf6b 2019-10-19)

# ~/github/rustup.rs on git:install-from-dist-w-force-update-from-cfg
→ rustup toolchain remove nightly-2019-07-12 
info: no toolchain installed for 'nightly-2019-07-12-x86_64-apple-darwin'

# ~/github/rustup.rs on git:install-from-dist-w-force-update-from-cfg
→ rustup run --install nightly-2019-07-12 cargo -V
info: syncing channel updates for 'nightly-2019-07-12-x86_64-apple-darwin'
info: latest update on 2019-07-12, rust version 1.38.0-nightly (4bb6b4a5e 2019-07-11)
warning: Force-skipping unavailable component 'clippy-x86_64-apple-darwin'
info: downloading component 'cargo'
info: downloading component 'rust-docs'
 11.7 MiB /  11.7 MiB (100 %)   7.8 MiB/s in  1s ETA:  0s
info: downloading component 'rust-std'
168.8 MiB / 168.8 MiB (100 %)   7.3 MiB/s in 21s ETA:  0s
info: downloading component 'rustc'
 58.8 MiB /  58.8 MiB (100 %)   8.0 MiB/s in  7s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'rust-docs'
 11.7 MiB /  11.7 MiB (100 %)   2.2 MiB/s in  4s ETA:  0s
info: installing component 'rust-std'
168.8 MiB / 168.8 MiB (100 %)  14.2 MiB/s in 10s ETA:  0s
info: installing component 'rustc'
 58.8 MiB /  58.8 MiB (100 %)   7.6 MiB/s in  7s ETA:  0s
info: installing component 'rustfmt'
cargo 1.38.0-nightly (677a180f4 2019-07-08)

@kinnison
Copy link
Contributor

Right, but do your test cases behave this way -- an easy way to check that is to simply temporarily change the trues back to falses and run those new tests -- if they fail with false but pass with true then that's good enough :D

@BeniCheni BeniCheni force-pushed the install-from-dist-w-force-update-from-cfg branch from 6d26dfa to 71d1e72 Compare October 20, 2019 05:35
@BeniCheni
Copy link
Contributor Author

an easy way to check that is to simply temporarily change the trues back to falses and run those new tests

@kinnison, you were right about that the previous tests were inefficient that there was no difference when reverting the booleans.

So I rewrote the test w. make_component_unavailable in test code to mimic an unavailable component of nightly, and then rustup run --install nightly rustc --version to confirm the force install.

I also confirmed that test would fail before the boolean change, and then with the boolean change the test passed as expected. PTAL?

Test failed before the boolean change in config.rs
→ cargo test run_with_install_flag_against_unavailable_component
   Compiling rustup v1.20.2 (/Users/bchen/github/rustup.rs)
    Finished dev [unoptimized + debuginfo] target(s) in 23.97s
     Running target/debug/deps/rustup-b6ab2206befdfe0d
...
running 1 test
test run_with_install_flag_against_unavailable_component ... FAILED

failures:

---- run_with_install_flag_against_unavailable_component stdout ----
Copying from /Users/bchen/github/rustup.rs/target/debug/rustup-init to /Users/bchen/github/rustup.rs/target/tests/running-test-9U9ht7/rustup-exeScqntI/rustup
running "/Users/bchen/github/rustup.rs/target/tests/running-test-9U9ht7/rustup-exeScqntI/rustup" "set" "default-host" "x86_64-apple-darwin"
status: exit code: 0
----- stdout

----- stderr

/Users/bchen/github/rustup.rs/target/tests/running-test-9U9ht7/rustup-distr3PtDU/dist/channel-rust-nightly.toml.sha256
running "/Users/bchen/github/rustup.rs/target/tests/running-test-9U9ht7/rustup-exeScqntI/rustup" "run" "--install" "nightly" "rustc" "--version"
status: exit code: 1
----- stdout

----- stderr
info: syncing channel updates for 'nightly-x86_64-apple-darwin'
info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2)
info: skipping nightly which is missing installed component 'rust-std'
info: syncing channel updates for 'nightly-2015-01-01-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-2014-12-31-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-2014-12-30-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-2014-12-29-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-2014-12-28-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-2014-12-27-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-2014-12-26-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-2014-12-25-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-2014-12-24-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-2014-12-23-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-2014-12-22-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-2014-12-21-x86_64-apple-darwin'
info: syncing channel updates for 'nightly-2014-12-20-x86_64-apple-darwin'
error: component 'rust-std' for target 'x86_64-apple-darwin' is unavailable for download for channel nightly


> rustup run --install nightly rustc --version
out.ok: false
out.stdout (0 lines):
    
out.stderr (17 lines):
    info: syncing channel updates for 'nightly-x86_64-apple-darwin'
    info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2)
    info: skipping nightly which is missing installed component 'rust-std'
    info: syncing channel updates for 'nightly-2015-01-01-x86_64-apple-darwin'
    info: syncing channel updates for 'nightly-2014-12-31-x86_64-apple-darwin'
    info: syncing channel updates for 'nightly-2014-12-30-x86_64-apple-darwin'
    info: syncing channel updates for 'nightly-2014-12-29-x86_64-apple-darwin'
    info: syncing channel updates for 'nightly-2014-12-28-x86_64-apple-darwin'
    info: syncing channel updates for 'nightly-2014-12-27-x86_64-apple-darwin'
    info: syncing channel updates for 'nightly-2014-12-26-x86_64-apple-darwin'
    info: syncing channel updates for 'nightly-2014-12-25-x86_64-apple-darwin'
    info: syncing channel updates for 'nightly-2014-12-24-x86_64-apple-darwin'
    info: syncing channel updates for 'nightly-2014-12-23-x86_64-apple-darwin'
    info: syncing channel updates for 'nightly-2014-12-22-x86_64-apple-darwin'
    info: syncing channel updates for 'nightly-2014-12-21-x86_64-apple-darwin'
    info: syncing channel updates for 'nightly-2014-12-20-x86_64-apple-darwin'
    error: component 'rust-std' for target 'x86_64-apple-darwin' is unavailable for download for channel nightly
    
expected.ok: true
expected.stdout (1 lines):
    1.3.0 (hash-nightly-2)
    
expected.stderr (9 lines):
    info: syncing channel updates for 'nightly-x86_64-apple-darwin'
    info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2)
    warning: Force-skipping unavailable component 'rust-std-x86_64-apple-darwin'
    info: downloading component 'cargo'
    info: downloading component 'rust-docs'
    info: downloading component 'rustc'
    info: installing component 'cargo'
    info: installing component 'rust-docs'
    info: installing component 'rustc'
    
[tests/mock/clitools.rs:257] out.stdout == stdout = false
[tests/mock/clitools.rs:258] out.stderr == stderr = false
thread 'run_with_install_flag_against_unavailable_component' panicked at 'explicit panic', tests/mock/clitools.rs:259:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.


failures:
    run_with_install_flag_against_unavailable_component

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 67 filtered out

error: test failed, to rerun pass '--test cli-v2'
Test passed after the boolean change in config.rs
→ cargo test run_with_install_flag_against_unavailable_component
   Compiling rustup v1.20.2 (/Users/bchen/github/rustup.rs)
    Finished dev [unoptimized + debuginfo] target(s) in 18.51s
     Running target/debug/deps/rustup-b6ab2206befdfe0d
...
running 1 test
test run_with_install_flag_against_unavailable_component ... ok

@BeniCheni BeniCheni force-pushed the install-from-dist-w-force-update-from-cfg branch from 71d1e72 to f11e7f1 Compare October 20, 2019 06:00
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.

If you can fix the test case, I think this looks good. Nice job.

tests/cli-v2.rs Outdated Show resolved Hide resolved
@kinnison
Copy link
Contributor

Since I had some time, I made the change for you and pushed a commit. if you're okay with it, and it passes tests, then please fold it into your commit appropriately and then we'll be good to merge.

@BeniCheni BeniCheni force-pushed the install-from-dist-w-force-update-from-cfg branch from 09a24c5 to 0800f41 Compare October 20, 2019 13:20
@BeniCheni
Copy link
Contributor Author

... if you're okay with it, and it passes tests, then please fold it into your commit appropriately and then we'll be good to merge.

@kinnison, ah my bad. Didn't use wildcard w. nightly-{0} in one of the expected message line, as your push fixed it up. 🙏 I've passed all the tests locally and folded into a single commit in last push. PTAL?

P.S.: Thanks for your comment that led to the learning about make_component_unavailable fn in test code interesting and helpful, in case a future PR would need to write tests w. unavailable components.

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.

LGTM

@kinnison kinnison merged commit d427b76 into rust-lang:master Oct 20, 2019
@BeniCheni BeniCheni deleted the install-from-dist-w-force-update-from-cfg branch October 20, 2019 14:59
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.

builds fail due to missing components on non tier 1 platforms using the default profile
2 participants