Unverified Commit 3862695e authored by Doron Behar's avatar Doron Behar Committed by GitHub
Browse files

buildOctavePackage: add passthru tests (#411718)

parents 41609fd3 a25d57dc
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
  stdenv,
  config,
  octave,
  callPackage,
  texinfo,
  computeRequiredOctavePackages,
  writeRequiredOctavePackagesHook,
@@ -64,13 +65,6 @@ let
    writeRequiredOctavePackagesHook
  ] ++ nativeBuildInputs;

  passthru' = {
    updateScript = [
      ../../../../maintainers/scripts/update-octave-packages
      (builtins.unsafeGetAttrPos "pname" octave.pkgs.${attrs.pname}).file
    ];
  } // passthru;

  # This step is required because when
  # a = { test = [ "a" "b" ]; }; b = { test = [ "c" "d" ]; };
  # (a // b).test = [ "c" "d" ];
@@ -81,9 +75,9 @@ let
    "nativeBuildInputs"
    "passthru"
  ];

in
stdenv.mkDerivation (
  finalAttrs:
  {
    packageName = "${fullLibName}";
    # The name of the octave package ends up being
@@ -136,7 +130,22 @@ stdenv.mkDerivation (
    # together with Octave.
    dontInstall = true;

    passthru = passthru';
    passthru =
      {
        updateScript = [
          ../../../../maintainers/scripts/update-octave-packages
          (builtins.unsafeGetAttrPos "pname" octave.pkgs.${attrs.pname}).file
        ];
      }
      // passthru
      // {
        tests = {
          testOctaveBuildEnv = (octave.withPackages (os: [ finalAttrs.finalPackage ])).overrideAttrs (old: {
            name = "${finalAttrs.name}-pkg-install";
          });
          testOctavePkgTests = callPackage ./run-pkg-test.nix { } finalAttrs.finalPackage;
        } // passthru.tests or { };
      };

    inherit meta;
  }
+25 −0
Original line number Diff line number Diff line
{
  octave,
  runCommand,
}:
package:

runCommand "${package.name}-pkg-test"
  {
    nativeBuildInputs = [
      (octave.withPackages (os: [ package ]))
    ];
  }
  ''
    { octave-cli --eval 'pkg test ${package.pname}' || touch FAILED_ERRCODE; } \
      |& tee >( grep --quiet '^Failure Summary:$' && touch FAILED_OUTPUT || : ; cat >/dev/null )
    if [[ -f FAILED_ERRCODE ]]; then
      echo >&2 "octave-cli returned with non-zero exit code."
      false
    elif [[ -f FAILED_OUTPUT ]]; then
      echo >&2 "Test failures detected in output."
      false
    else
      touch $out
    fi
  ''