Skip to content

Commit

Permalink
Explicitly manage the version of Nightly Rust in tests
Browse files Browse the repository at this point in the history
Some of our tests use nightly Rust to help test for specific
things. The version of Rust used was simply piggybacking on the
version of nightly Rust we use for `rustfmt`, rather than being
specifically managed.

Previously, this wasn't an issue, but with the latest nightly Rust
that works for `rustfmt`, we apparently have a bug around cargo
dealing with crates that have symlinks in them (possibly related to
rust-lang/cargo#5664).

This commit introduces a `RUST_NIGHTLY_VERSION` file to explicitly
manage which version we're using in tests. For now, it also pins back
to the last known good nightly version for testing purposes.

Signed-off-by: Christopher Maier <[email protected]>
  • Loading branch information
christophermaier committed Aug 6, 2019
1 parent d0dc9ca commit 1d7af0b
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions RUST_NIGHTLY_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly-2019-06-06
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (!$Toolchain) {
}

if($Command -eq "Fmt") {
$toolchain = "$(Get-Content $PSScriptRoot/RUSTFMT_VERSION)"
$toolchain = Get-RustfmtToolchain
Write-Host "Forcing the use of $toolchain toolchain for rustfmt"
}

Expand Down
2 changes: 1 addition & 1 deletion support/ci/install-nightly-rustfmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ set -euo pipefail
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
# shellcheck disable=SC1090
source "$dir/shared.sh"
toolchain=$(get_nightly_toolchain)
toolchain=$(get_rustfmt_toolchain)

install_rustfmt "$toolchain"
2 changes: 1 addition & 1 deletion support/ci/rustfmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
# shellcheck disable=SC1090
source "$dir/shared.sh"
toolchain=$(get_nightly_toolchain)
toolchain=$(get_rustfmt_toolchain)

install_rustup
install_rustfmt "$toolchain"
Expand Down
6 changes: 5 additions & 1 deletion support/ci/shared.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Get-NightlyToolchain {
function Get-RustfmtToolchain {
# It turns out that every nightly version of rustfmt has slight tweaks from the previous version.
# This means that if we're always using the latest version, then we're going to have enormous
# churn. Even PRs that don't touch rust code will likely fail CI, since master will have been
Expand All @@ -12,6 +12,10 @@ function Get-NightlyToolchain {
Get-Content "$PSScriptRoot\..\..\RUSTFMT_VERSION"
}

function Get-NightlyToolchain {
Get-Content "$PSScriptRoot\..\..\RUST_NIGHTLY_VERSION"
}

function Install-Rustup($Toolchain) {
if(Test-Path $env:USERPROFILE\.cargo\bin) {
$env:path = New-PathString -StartingPath $env:path -Path "$env:USERPROFILE\.cargo\bin"
Expand Down
8 changes: 7 additions & 1 deletion support/ci/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"

sudo hab license accept

get_nightly_toolchain() {
get_rustfmt_toolchain() {
# It turns out that every nightly version of rustfmt has slight tweaks from the previous version.
# This means that if we're always using the latest version, then we're going to have enormous
# churn. Even PRs that don't touch rust code will likely fail CI, since master will have been
Expand All @@ -20,6 +20,12 @@ get_nightly_toolchain() {
cat "$dir/../../RUSTFMT_VERSION"
}

# Get the version of the nightly toolchain we use for compiling,
# running, tests, etc.
get_nightly_toolchain() {
cat "$dir/../../RUST_NIGHTLY_VERSION"
}

get_toolchain() {
cat "$dir/../../rust-toolchain"
}
Expand Down
2 changes: 1 addition & 1 deletion test/run_cargo_test.ps1
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $ErrorActionPreference="stop"
. $PSScriptRoot\..\support\ci\shared.ps1

$toolchain = Get-Toolchain
if($Nightly) { $toolchain = (gc $PSScriptRoot\..\RUSTFMT_VERSION | out-string).Trim() }
if($Nightly) { $toolchain = Get-NightlyToolchain }

Setup-Environment

Expand Down

0 comments on commit 1d7af0b

Please sign in to comment.