summary refs log tree commit diff
path: root/pkgs/build-support/release/gcov-report.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2014-03-03 13:39:30 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2014-03-03 13:57:08 +0100
commit497997cc388ce791ca0b4dc55f46ab515e8fb5d9 (patch)
tree867053bb31858180d2b439d1c63c610c58be54ee /pkgs/build-support/release/gcov-report.nix
parentad7c518e45221533e2094acb20fea6ade477da75 (diff)
downloadnixpkgs-497997cc388ce791ca0b4dc55f46ab515e8fb5d9.tar
nixpkgs-497997cc388ce791ca0b4dc55f46ab515e8fb5d9.tar.gz
nixpkgs-497997cc388ce791ca0b4dc55f46ab515e8fb5d9.tar.bz2
nixpkgs-497997cc388ce791ca0b4dc55f46ab515e8fb5d9.tar.lz
nixpkgs-497997cc388ce791ca0b4dc55f46ab515e8fb5d9.tar.xz
nixpkgs-497997cc388ce791ca0b4dc55f46ab515e8fb5d9.tar.zst
nixpkgs-497997cc388ce791ca0b4dc55f46ab515e8fb5d9.zip
Move generation of coverage reports from nixos/lib/testing to releaseTools
Also, turn some stdenv adapters into setup hooks.
Diffstat (limited to 'pkgs/build-support/release/gcov-report.nix')
-rw-r--r--pkgs/build-support/release/gcov-report.nix49
1 files changed, 49 insertions, 0 deletions
diff --git a/pkgs/build-support/release/gcov-report.nix b/pkgs/build-support/release/gcov-report.nix
new file mode 100644
index 00000000000..8ce5c0488a7
--- /dev/null
+++ b/pkgs/build-support/release/gcov-report.nix
@@ -0,0 +1,49 @@
+{ runCommand, lcov, rsync, coverageRuns, lcovFilter ? [ "/nix/store/*" ], baseDirHack ? false }:
+
+runCommand "coverage"
+  { buildInputs = [ lcov rsync ];
+    inherit lcovFilter baseDirHack;
+  }
+  ''
+    mkdir -p $TMPDIR/gcov $out/nix-support $out/coverage
+    info=$out/coverage/full.info
+
+    for p in ${toString coverageRuns}; do
+        if [ -f $p/nix-support/hydra-build-products ]; then
+            cat $p/nix-support/hydra-build-products >> $out/nix-support/hydra-build-products
+        fi
+
+        [ ! -e $p/nix-support/failed ] || touch $out/nix-support/failed
+
+        opts=
+        for d in $p/coverage-data/*; do
+            for i in $(cd $d/nix/store && ls); do
+                if ! [ -e /nix/store/$i/.build ]; then continue; fi
+                if [ -e $TMPDIR/gcov/nix/store/$i ]; then continue; fi
+                echo "copying $i..."
+                rsync -a /nix/store/$i/.build/* $TMPDIR/gcov/
+                if [ -n "$baseDirHack" ]; then
+                    opts="-b $TMPDIR/gcov/$(cd /nix/store/$i/.build && ls)"
+                fi
+            done
+
+            for i in $(cd $d/nix/store && ls); do
+                rsync -a $d/nix/store/$i/.build/* $TMPDIR/gcov/ --include '*/' --include '*.gcda' --exclude '*'
+            done
+        done
+
+        chmod -R u+w $TMPDIR/gcov
+
+        echo "producing info..."
+        geninfo --ignore-errors source,gcov $TMPDIR/gcov --output-file $TMPDIR/app.info $opts
+        cat $TMPDIR/app.info >> $info
+    done
+
+    echo "making report..."
+    set -o noglob
+    lcov --remove $info ''$lcovFilter > $info.tmp
+    set +o noglob
+    mv $info.tmp $info
+    genhtml --show-details $info -o $out/coverage
+    echo "report coverage $out/coverage" >> $out/nix-support/hydra-build-products
+  ''