Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions test/bench/nushell_preparation_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require_relative "test_helper"

class NushellPreparationTest < Minitest::Test
def test_installs_the_exact_toolchain_of_each_source_revision
%w[1.97.1 1.98.1].each do |version|
output, status, config, calls = prepare(version)

assert status.success?, output
assert_equal({ "version" => version, "profile" => "minimal" }, config.dig("tools", "rust"))
assert_equal "0.17.0", config.dig("tools", "sccache")
assert_equal ["trust #{version}", "install #{version}"], calls
end
kase = Bench::Catalog.new(Bench::ROOT).find_case("cargo/nushell")
refute kase.env({}).key?("RUSTUP_TOOLCHAIN")
end

def test_rejects_floating_toolchains_before_installation
%w[stable nightly 1.98].each do |version|
output, status, config, calls = prepare(version)

refute status.success?
assert_includes output, "requires one exact Rust version"
refute config.fetch("tools").key?("rust")
assert_empty calls
end
end

private
def prepare(version)
Dir.mktmpdir("nushell-rust") do |dir|
FileUtils.mkdir_p([File.join(dir, "upstream"), File.join(dir, "bin")])
FileUtils.cp(File.join(Bench::ROOT, "tools/cargo/nushell/mise.toml"), dir)
source = TomlRB.dump("toolchain" => { "channel" => version })
toolchain = File.join(dir, "upstream/rust-toolchain.toml")
File.write(toolchain, source)
calls = File.join(dir, "calls")
mise = File.join(dir, "bin/mise")
File.write(mise, <<~SH)
#!/usr/bin/env bash
version=$(ruby -rtoml-rb -e 'puts TomlRB.load_file("mise.toml").dig("tools", "rust", "version")')
echo "$1 $version" >> "$CALLS"
SH
File.chmod(0o755, mise)
kase = Bench::Catalog.new(Bench::ROOT).find_case("cargo/nushell")
output, status = Open3.capture2e(
{ "PATH" => "#{dir}/bin:#{File.dirname(RbConfig.ruby)}:#{ENV.fetch("PATH")}", "CALLS" => calls, "BENCH_ROOT" => Bench::ROOT },
"bash", "-e", "-c", kase.prepare.first, chdir: dir
)
assert_equal source, File.read(toolchain)
[output, status, TomlRB.load_file(File.join(dir, "mise.toml")), File.exist?(calls) ? File.readlines(calls, chomp: true) : []]
end
end
end
6 changes: 4 additions & 2 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ job into a parallel lint job. Rolling builds visit every commit.
Fresh builds use that starting source for both cold and warm phases.

Every lane runs the root job's Cargo build, tests and doctests, with its `ci`
profile and `.cargo/ci.toml`. Source files are unchanged. Rust is 1.97.1 and
sccache is 0.17.0. Incremental compilation is off in all lanes so sccache can
profile and `.cargo/ci.toml`. Source files are unchanged. Setup installs the exact
Rust version pinned by each source commit's `rust-toolchain.toml`; floating
channels fail preparation. All lanes use that version and sccache 0.17.0.
Incremental compilation is off in all lanes so sccache can
cache compiler outputs. After the tests, every lane copies `nu` out of
`target` and removes the workspace's test executables, binaries, examples and
their debug files from `target/ci`. Libraries and dependency outputs stay, so
Expand Down
3 changes: 1 addition & 2 deletions tools/cargo/nushell/case.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ rolling_series = 4
directory = "upstream"
script = ["bash", "../overlay/ci.sh"]
prepare = [
"mise trust && mise install",
"ruby \"$BENCH_ROOT/tools/cargo/nushell/prepare.rb\" && mise trust && mise install",
"cd upstream && rustup show active-toolchain && cargo metadata --no-deps --format-version 1 > /dev/null",
]
check = "bash overlay/check.sh"

[env]
CARGO_TERM_COLOR = "always"
CARGO_INCREMENTAL = "0"
RUSTUP_TOOLCHAIN = "1.97.1"
NU_LOG_LEVEL = "DEBUG"
NU_TEST_SKIP_DEPS_BUILD = "true"
NUSHELL_CARGO_PROFILE = "ci"
Expand Down
1 change: 0 additions & 1 deletion tools/cargo/nushell/mise.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[tools]
rust = { version = "1.97.1", profile = "minimal" }
sccache = "0.17.0"
8 changes: 8 additions & 0 deletions tools/cargo/nushell/prepare.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require "toml-rb"

version = TomlRB.load_file("upstream/rust-toolchain.toml").fetch("toolchain").fetch("channel")
abort "nushell requires one exact Rust version in rust-toolchain.toml" unless version.match?(/\A\d+\.\d+\.\d+\z/)

config = TomlRB.load_file("mise.toml")
config.fetch("tools")["rust"] = { "version" => version, "profile" => "minimal" }
File.write("mise.toml", TomlRB.dump(config))
Loading