Merge pull request #37 from Profpatsch/test-executables

Test executables
This commit is contained in:
Profpatsch 2020-11-06 12:09:32 +01:00 committed by GitHub
commit 0315b4c2f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 24 deletions

View File

@ -16,4 +16,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v9
- run: ./test.bash
- run: ./test.sh

View File

@ -21,6 +21,8 @@ pkgs.stdenv.mkDerivation rec {
nativeBuildInputs = [ pkgs.installShellFiles ];
passthru.binNames = binNames;
installPhase = ''
mkdir -p $out/bin

View File

@ -13,5 +13,7 @@ in
dhall-bash-simple
dhall-nix-simple
dhall-yaml-simple
dhall-lsp-simple
dhall-docs-simple
];
}

View File

@ -1,23 +0,0 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash
ERRORS=0;
function test_exe () {
EXE=$1;
LOCATION=$(command -v "$EXE");
if [ -x "$LOCATION" ]; then
echo "found $EXE";
else
echo "didnt find $EXE";
ERRORS=1;
fi
}
test_exe dhall;
test_exe dhall-to-json;
test_exe dhall-to-bash;
test_exe dhall-to-nix;
test_exe dhall-to-yaml-ng;
exit $ERRORS;

39
test.nix Normal file
View File

@ -0,0 +1,39 @@
{ pkgs ? import <nixpkgs> {} }:
let
lib = pkgs.lib;
executables = lib.concatLists
(lib.mapAttrsToList
# every package puts its binNames into passthru
(_: v: map (bin: "${v}/bin/${bin}") v.passthru.binNames)
(import ./default.nix { inherit pkgs; }));
testExeLocation = pkgs.writers.writeDash "test-exe-location" ''
set -e
ERRORS=0;
test_exe () {
EXE=$1;
echo "$EXE --version:"
if $EXE --version; then
return 0
else
echo "$EXE --version failed!"
ERRORS=1
fi
}
for exe in ${lib.escapeShellArgs executables}; do
test_exe "$exe"
done
exit "$ERRORS"
'';
in {
inherit
testExeLocation;
}

4
test.sh Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env sh
set -e
test_script="$(nix-build ./test.nix)"
exec "$test_script"