From 63f5ca5c0b6dd9b18f8c1647c1da464dd4b3ac28 Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Mon, 3 Jun 2024 14:14:28 +0200 Subject: [PATCH] No need to force the rustc tests to match the rustc version we're using This adds too much update complexity for little benefit: rust is quite stable, most tests stay the same from one version to the next. --- flake.nix | 7 +++++-- nix/rustc-tests.nix | 41 +++++++++++++++++------------------------ 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/flake.nix b/flake.nix index 66d75f6c8..e9e274305 100644 --- a/flake.nix +++ b/flake.nix @@ -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 { @@ -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 diff --git a/nix/rustc-tests.nix b/nix/rustc-tests.nix index b5ff7e9b7..dd5d33be9 100644 --- a/nix/rustc-tests.nix +++ b/nix/rustc-tests.nix @@ -12,7 +12,19 @@ }: 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 \ @@ -20,27 +32,6 @@ let | 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 @@ -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 @@ -112,4 +103,6 @@ let ''; in -rustc-tests +{ + inherit toolchain_commit rustc-test-suite rustc-tests; +}