fornwall / rust-script

Run Rust files and expressions as scripts without any setup or compilation step.
https://rust-script.org
Apache License 2.0
1.21k stars 41 forks source link

Add `--toolchain-version` argument #21

Closed PatchMixolydic closed 3 years ago

PatchMixolydic commented 3 years ago

This allows the user to specify which toolchain to use to build their script. This allows for the use of nightly features, features only stabilized in beta (without resorting to nightly), and even the use of custom-built toolchains if the need ever arises.

PatchMixolydic commented 3 years ago

I'm a bit concerned about these tests. One works by checking a compiler diagnostic, which may cause it to start failing if the diagnostic is reworded, while the other requires a nightly toolchain to be installed. Is this okay?

fornwall commented 3 years ago

@PatchMixolydic Thanks! It's a nice feature to support, so I think it's worth maintaining the new tests.

fornwall commented 3 years ago

@PatchMixolydic Could you help with a CI build failure?

The CI setup now installs both rust stable (1.47 or 1.51) and nightly toolchains (https://github.com/fornwall/rust-script/blob/master/.github/workflows/ci.yml#L16-L23):

    - name: Setup rust (${{ matrix.rust }})
      uses: hecrj/setup-rust-action@v1
      with:
        rust-version: ${{ matrix.rust }}
    - name: Setup rust (nightly)
      uses: hecrj/setup-rust-action@v1
      with:
        rust-version: nightly

This works on Linux and Mac, but on Windows it fails with (https://github.com/fornwall/rust-script/runs/2436947155#step:5:192):

---- tests::script::test_stable_toolchain stdout ----
rust-script cmd: "target/debug/rust-script" "--toolchain-version" "stable" "tests/data/script-unstable-feature.rs"
rust-script stdout
-----

-----
rust-script stderr:
-----
error: toolchain 'stable-x86_64-pc-windows-msvc' is not installed
error: test failed, to rerun pass '--test integration'

So it seems that +stable doesn't work on Windows here? Earlier the output from the stable installation was 1.47.0-x86_64-pc-windows-msvc installed.

Any ideas? Unfortunately I haven't developed in a Windows environment for a long time.

fornwall commented 3 years ago

Ah, it seems that it might be due to stable being preinstalled on Mac and Linux runners, but not on Windows. Installing stable explicitly fixed the tests on Windows.

fornwall commented 3 years ago

Thanks! This has now been released in version 0.14.0.

PatchMixolydic commented 3 years ago

Sorry about not being around to give you a hand; I was still asleep :sweat_smile: Glad to see it's working fine now!