diff options
author | Florian Klink <flokli@flokli.de> | 2023-05-22T13·46+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-05-24T09·17+0000 |
commit | 1fb500823733c7d0fefad6c15b54d2e91f6f95fb (patch) | |
tree | 28becaa99f2874f59108e2f5cbfeb39e9fe27f58 | |
parent | 7bd9df01335832705f3ac6d8790e579ecef33d55 (diff) |
feat(tvix/cli): introduce mkNixpkgsEvalCheck, add outPath check r/6189
This introduces a function that can be instantiated with an attribute path to instantiate, as well as the expected path (normally interpolated with the nix evaluator). Check both pkgs.stdenv.drvPath and pkgs.stdenv.outPath to match. Change-Id: Id667ed35fa159ff83fedb3017ef8d3271aa42695 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8606 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
-rw-r--r-- | tvix/cli/default.nix | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/tvix/cli/default.nix b/tvix/cli/default.nix index 96a1b736686b..03c01ddc7783 100644 --- a/tvix/cli/default.nix +++ b/tvix/cli/default.nix @@ -1,25 +1,32 @@ { depot, pkgs, lib, ... }: +let + mkNixpkgsEvalCheck = attrset: expectedPath: { + label = ":nix: evaluate nixpkgs.${attrset} in tvix"; + needsOutput = true; + + command = pkgs.writeShellScript "tvix-eval-${builtins.replaceStrings [".drv"] ["-drv"] attrset}" '' + TVIX_OUTPUT=$(result/bin/tvix -E '(import ${pkgs.path} {}).${attrset}') + EXPECTED='${/* the verbatim expected Tvix output: */ "=> \"${expectedPath}\" :: string"}' + + echo "Tvix output: ''${TVIX_OUTPUT}" + if [ "$TVIX_OUTPUT" != "$EXPECTED" ]; then + echo "Correct would have been ''${EXPECTED}" + exit 1 + fi + + echo "Output was correct." + ''; + }; +in + (depot.tvix.crates.workspaceMembers.tvix-cli.build.override { runTests = true; }).overrideAttrs (_: { meta = { - ci.extraSteps.eval-nixpkgs-stdenv = { - label = ":nix: evaluate nixpkgs.stdenv in tvix"; - needsOutput = true; - - command = pkgs.writeShellScript "tvix-eval-stdenv" '' - TVIX_OUTPUT=$(result/bin/tvix -E '(import ${pkgs.path} {}).stdenv.drvPath') - EXPECTED='${/* the verbatim expected Tvix output: */ "=> \"${pkgs.stdenv.drvPath}\" :: string"}' - - echo "Tvix output: ''${TVIX_OUTPUT}" - if [ "$TVIX_OUTPUT" != "$EXPECTED" ]; then - echo "Correct would have been ''${EXPECTED}" - exit 1 - fi - - echo "Output was correct." - ''; + ci.extraSteps = { + eval-nixpkgs-stdenv-drvpath = (mkNixpkgsEvalCheck "stdenv.drvPath" pkgs.stdenv.drvPath); + eval-nixpkgs-stdenv-outpath = (mkNixpkgsEvalCheck "stdenv.outPath" pkgs.stdenv.outPath); }; }; }) |