Commit 73c318b0 authored by Marie Ramlow's avatar Marie Ramlow
Browse files

gauge: add plugin loading tests

Adds tests to every plugin which makes sure installation works.
Also adds another test to gauge itself to make sure all plugins load
correctly when installed simultaneously.
parent c30eb0c5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ lib.makeScope pkgs.newScope (final: let
  inherit (final) callPackage;
in {
  makeGaugePlugin = callPackage ./make-gauge-plugin.nix { };
  testGaugePlugins = callPackage ./test-gauge-plugins.nix { };
  dotnet = callPackage ./dotnet { };
  html-report = callPackage ./html-report { };
  java = callPackage ./java { };
+41 −37
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
, lib
, writeScript
, autoPatchelfHook
, testGaugePlugins
}:

{ pname
@@ -41,7 +42,9 @@ stdenvNoCC.mkDerivation (finalAttrs: (lib.recursiveUpdate {
    cp -r . "$out/share/gauge-plugins/${pname}/${finalAttrs.version}"
  '';

  passthru.updateScript = writeScript "update-${finalAttrs.pname}" ''
  passthru = {
    tests.loadPlugin = testGaugePlugins { plugins = [ finalAttrs.finalPackage ]; };
    updateScript = writeScript "update-${finalAttrs.pname}" ''
      #!/usr/bin/env nix-shell
      #!nix-shell -i bash -p curl nix-prefetch yq-go

@@ -94,4 +97,5 @@ stdenvNoCC.mkDerivation (finalAttrs: (lib.recursiveUpdate {

      mv "$tempfile" "$dirname/data.json"
    '';
  };
} otherArgs))
+35 −0
Original line number Diff line number Diff line
{
  runCommand,
  gauge,
  lib,
}:

/**
  Creates a gauge install with all given plugins and makes sure every plugin is loaded.
*/
{ plugins }:

let
  gaugeWithPlugins = gauge.withPlugins (_: plugins);
in

runCommand "gauge-test" { nativeBuildInputs = [ gaugeWithPlugins ]; } ''
  mkdir $out
  echo $(gauge install || true) > $out/output.txt

  function checkPlugin() {
    plugin="$1"
    version="$2"

    echo Checking for plugin $plugin version $version
    if ! grep "$plugin ($version)" $out/output.txt
    then
      echo "Couldn't find plugin $plugin version $version"
      exit 1
    fi
  }

  ${lib.concatMapStringsSep "\n" (
    p: "checkPlugin '${lib.removePrefix "gauge-plugin-" p.pname}' '${p.version}'"
  ) plugins}
''
+3 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
, xorg
, gaugePlugins
, plugins ? []
, runCommand
}:

stdenvNoCC.mkDerivation {
@@ -53,6 +54,8 @@ stdenvNoCC.mkDerivation {
        requiredPlugins = with manifest; [ Language ] ++ Plugins;
        manifestPlugins = plugins: map (name: plugins.${name} or (throw "Gauge plugin ${name} is not available!")) requiredPlugins;
      in gauge.withPlugins manifestPlugins;
    # Builds gauge with all plugins and checks for successful installation
    tests.allPlugins = gaugePlugins.testGaugePlugins { plugins = lib.filter lib.isDerivation (lib.attrValues gaugePlugins); };
  };

  inherit (gauge-unwrapped) meta;