Commit 5b8c64f1 authored by Robert Hensing's avatar Robert Hensing
Browse files

xunit-viewer: Add basic tests

parent 23ab0c4b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@
  buildNpmPackage,
  fetchFromGitHub,
  nix-update-script,
  callPackage,
  testers, xunit-viewer,
}:
let
  version = "10.6.1";
@@ -22,6 +24,14 @@ buildNpmPackage {

  passthru.updateScript = nix-update-script { };

  passthru.tests = {
    version = testers.testVersion {
      package = xunit-viewer;
      version = "unknown"; # broken, but at least it runs
    };
    example = callPackage ./test/example.nix { };
  };

  meta = {
    description = "View your xunit results using JavaScript";
    homepage = "https://lukejpreston.github.io/xunit-viewer";
+8 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<!-- taken from the nix test suite and then stripped down -->
<testsuites tests="280" failures="0" disabled="2" errors="0" time="0.2" timestamp="2024-06-16T13:50:02.511" name="AllTests">
  <testsuite name="parseShebangContent" tests="14" failures="0" disabled="0" skipped="0" errors="0" time="0.001" timestamp="2024-06-16T13:50:02.511">
    <testcase name="basic" file="tests/unit/libutil/args.cc" line="10" status="run" result="completed" time="0." timestamp="2024-06-16T13:50:02.511" classname="parseShebangContent" />
    <testcase name="empty" file="tests/unit/libutil/args.cc" line="18" status="run" result="completed" time="0." timestamp="2024-06-16T13:50:02.511" classname="parseShebangContent" />
  </testsuite>
</testsuites>
+16 −0
Original line number Diff line number Diff line
{ xunit-viewer, runCommand, ... }:

runCommand "test-xunit-viewer" {
  nativeBuildInputs = [ xunit-viewer ];
} ''
  mkdir $out
  xunit-viewer -r ${./example.junit.xml} -o $out/index.html
  ( set -x
    grep '<body' $out/index.html
    # Can't easily grep for parts of the original data, because it ends up
    # embedded as base64 encoded data (and slightly modified?).
    # We'd have to really dissect it or render it with a browser.
    # Fortunately, we've already caught the most severe packaging problems
    # with just this.
  )
''