Skip to content

Commit

Permalink
No need to force the rustc tests to match the rustc version we're using
Browse files Browse the repository at this point in the history
This adds too much update complexity for little benefit: rust is quite
stable, most tests stay the same from one version to the next.
  • Loading branch information
Nadrieril committed Jun 4, 2024
1 parent 5344374 commit 4f31ced
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
7 changes: 5 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
in
{
packages = {
inherit charon charon-ml rustc-tests rustToolchain;
inherit charon charon-ml rustToolchain;
inherit (rustc-tests) toolchain_commit rustc-tests;
default = charon;
};
devShells.default = pkgs.mkShell {
Expand All @@ -144,7 +145,9 @@
self.packages.${system}.charon-ml
];
};
checks = { inherit charon-ml-tests charon-check-fmt charon-ml-check-fmt; };
checks = {
inherit charon-ml-tests charon-check-fmt charon-ml-check-fmt;
};

# Export this function so that users of charon can use it in nix. This
# fits in none of the standard flake output categories hace why it is
Expand Down
41 changes: 17 additions & 24 deletions nix/rustc-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,26 @@
}:

let
# The commit that corresponds to our nightly pin.
# The rustc commit we use to get the tests. We should update it every now and
# then to match the version of rustc we're using.
tests_commit = "65ea825f4021eaf77f1b25139969712d65b435a4";
tests_hash = "sha256-0dsWuGcWjQpj/N4iG6clCzM8kjrDjE+dQfyL3iuBGiY=";

rustc-test-suite = fetchFromGitHub {
owner = "rust-lang";
repo = "rust";
rev = tests_commit;
sha256 = tests_hash;
};

# The commit that corresponds to our nightly pin, for when we want to update the pinned commit.
toolchain_commit = runCommand "get-rustc-commit" { } ''
# This is sad but I don't know a better way.
cat ${rustToolchain}/share/doc/rust/html/version_info.html \
| grep 'github.com' \
| sed 's#.*"https://github.com/rust-lang/rust/commit/\([^"]*\)".*#\1#' \
> $out
'';
# The rustc commit we use to get the tests. This should stay equal to `toolchain_commit`.
tests_commit = "65ea825f4021eaf77f1b25139969712d65b435a4";
rustc_tests = runCommand "rustc-tests"
{
src = fetchFromGitHub {
owner = "rust-lang";
repo = "rust";
rev = tests_commit;
sha256 = "sha256-0dsWuGcWjQpj/N4iG6clCzM8kjrDjE+dQfyL3iuBGiY=";
};
} ''
# Check we're using the correct commit for tests.
TOOLCHAIN_COMMIT="$(cat ${toolchain_commit})"
TESTS_COMMIT="${tests_commit}"
if [ "$TOOLCHAIN_COMMIT" != "$TESTS_COMMIT" ]; then
echo "Error: the commit used for tests is incorrect" 1>&2
echo 'Please set `tests_commit = "'"$TOOLCHAIN_COMMIT"'";` in nix/rustc-tests.nix' 1>&2
exit 1
fi
ln -s $src $out
'';

analyze_test_file = writeScript "charon-analyze-test-file" ''
#!${bash}/bin/bash
Expand Down Expand Up @@ -101,7 +92,7 @@ let
# for each file we processed.
rustc-tests = runCommand "charon-rustc-tests"
{
src = rustc_tests;
src = rustc-test-suite;
buildInputs = [ rustToolchain ];
} ''
mkdir $out
Expand All @@ -112,4 +103,6 @@ let
'';

in
rustc-tests
{
inherit toolchain_commit rustc-test-suite rustc-tests;
}

0 comments on commit 4f31ced

Please sign in to comment.