mirror of
https://github.com/justinwoo/easy-dhall-nix.git
synced 2024-11-22 19:19:42 +01:00
test(*): automatically check all binaries, based on binNames
The test list would go out-of-date when new packages were added. This does the same check as before, but uses the binaries we already specify on the nix level (via a passthru). The next step is to try to run the binaries (e.g. with --version), which will give us a better test of whether they are actually executable.
This commit is contained in:
parent
3eec0cfb18
commit
e555e2201c
5 changed files with 46 additions and 26 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -16,4 +16,4 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: cachix/install-nix-action@v9
|
||||
- run: ./test.bash
|
||||
- run: ./test.sh
|
||||
|
|
|
@ -21,6 +21,8 @@ pkgs.stdenv.mkDerivation rec {
|
|||
|
||||
nativeBuildInputs = [ pkgs.installShellFiles ];
|
||||
|
||||
passthru.binNames = binNames;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
|
||||
|
|
25
test.bash
25
test.bash
|
@ -1,25 +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;
|
||||
test_exe dhall-docs;
|
||||
test_exe dhall-lsp-server;
|
||||
|
||||
exit $ERRORS;
|
39
test.nix
Normal file
39
test.nix
Normal 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;
|
||||
LOCATION=$(command -v "$EXE");
|
||||
if [ -x "$LOCATION" ]; then
|
||||
echo "found $EXE";
|
||||
else
|
||||
echo "didnt find $EXE";
|
||||
ERRORS=1;
|
||||
fi
|
||||
}
|
||||
|
||||
for exe in ${lib.escapeShellArgs executables}; do
|
||||
test_exe "$exe"
|
||||
done
|
||||
|
||||
exit "$ERRORS"
|
||||
|
||||
'';
|
||||
|
||||
in {
|
||||
inherit
|
||||
testExeLocation;
|
||||
}
|
4
test.sh
Executable file
4
test.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env sh
|
||||
set -e
|
||||
test_script="$(nix-build ./test.nix)"
|
||||
exec "$test_script"
|
Loading…
Reference in a new issue