Skip to content

Commit 5b8c64f

Browse files
committed
xunit-viewer: Add basic tests
1 parent 23ab0c4 commit 5b8c64f

3 files changed

Lines changed: 34 additions & 0 deletions

File tree

pkgs/by-name/xu/xunit-viewer/package.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
buildNpmPackage,
44
fetchFromGitHub,
55
nix-update-script,
6+
callPackage,
7+
testers, xunit-viewer,
68
}:
79
let
810
version = "10.6.1";
@@ -22,6 +24,14 @@ buildNpmPackage {
2224

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

27+
passthru.tests = {
28+
version = testers.testVersion {
29+
package = xunit-viewer;
30+
version = "unknown"; # broken, but at least it runs
31+
};
32+
example = callPackage ./test/example.nix { };
33+
};
34+
2535
meta = {
2636
description = "View your xunit results using JavaScript";
2737
homepage = "https://lukejpreston.github.io/xunit-viewer";
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- taken from the nix test suite and then stripped down -->
3+
<testsuites tests="280" failures="0" disabled="2" errors="0" time="0.2" timestamp="2024-06-16T13:50:02.511" name="AllTests">
4+
<testsuite name="parseShebangContent" tests="14" failures="0" disabled="0" skipped="0" errors="0" time="0.001" timestamp="2024-06-16T13:50:02.511">
5+
<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" />
6+
<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" />
7+
</testsuite>
8+
</testsuites>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{ xunit-viewer, runCommand, ... }:
2+
3+
runCommand "test-xunit-viewer" {
4+
nativeBuildInputs = [ xunit-viewer ];
5+
} ''
6+
mkdir $out
7+
xunit-viewer -r ${./example.junit.xml} -o $out/index.html
8+
( set -x
9+
grep '<body' $out/index.html
10+
# Can't easily grep for parts of the original data, because it ends up
11+
# embedded as base64 encoded data (and slightly modified?).
12+
# We'd have to really dissect it or render it with a browser.
13+
# Fortunately, we've already caught the most severe packaging problems
14+
# with just this.
15+
)
16+
''

0 commit comments

Comments
 (0)