nix: add withTmpDir to checked-shell-script
This commit is contained in:
committed by
Wolfgang Walther
parent
579a626de2
commit
fc791a6320
+2
-4
@@ -105,17 +105,16 @@ let
|
|||||||
name = "postgrest-dump-minimal-imports";
|
name = "postgrest-dump-minimal-imports";
|
||||||
docs = "Dump minimal imports into given directory.";
|
docs = "Dump minimal imports into given directory.";
|
||||||
inRootDir = true;
|
inRootDir = true;
|
||||||
|
withTmpDir = true;
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
dumpdir="''${1:?dumpdir not set}"
|
dumpdir="''${1:?dumpdir not set}"
|
||||||
tmpdir="$(mktemp -d)"
|
|
||||||
mkdir -p "$dumpdir"
|
mkdir -p "$dumpdir"
|
||||||
${cabal-install}/bin/cabal v2-build ${devCabalOptions} \
|
${cabal-install}/bin/cabal v2-build ${devCabalOptions} \
|
||||||
--builddir="$tmpdir" \
|
--builddir="$tmpdir" \
|
||||||
--ghc-option=-ddump-minimal-imports \
|
--ghc-option=-ddump-minimal-imports \
|
||||||
--ghc-option=-dumpdir="$dumpdir" \
|
--ghc-option=-dumpdir="$dumpdir" \
|
||||||
1>&2
|
1>&2
|
||||||
rm -rf "$tmpdir"
|
|
||||||
|
|
||||||
# Fix OverloadedRecordFields imports
|
# Fix OverloadedRecordFields imports
|
||||||
# shellcheck disable=SC2016
|
# shellcheck disable=SC2016
|
||||||
@@ -127,12 +126,11 @@ let
|
|||||||
{
|
{
|
||||||
name = "postgrest-hsie-minimal-imports";
|
name = "postgrest-hsie-minimal-imports";
|
||||||
docs = "Run hsie with a provided dump of minimal imports.";
|
docs = "Run hsie with a provided dump of minimal imports.";
|
||||||
|
withTmpDir = true;
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
tmpdir="$(mktemp -d)"
|
|
||||||
${dumpMinimalImports} "$tmpdir"
|
${dumpMinimalImports} "$tmpdir"
|
||||||
${hsie} "$tmpdir" "$@"
|
${hsie} "$tmpdir" "$@"
|
||||||
rm -rf "$tmpdir"
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
hsieGraphModules =
|
hsieGraphModules =
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
, stdenv
|
, stdenv
|
||||||
, writeTextFile
|
, writeTextFile
|
||||||
}:
|
}:
|
||||||
{ name, docs, inRootDir ? false }: text:
|
{ name, docs, inRootDir ? false, withTmpDir ? false }: text:
|
||||||
# TODO: do something sensible with docs, e.g. provide automated --help
|
# TODO: do something sensible with docs, e.g. provide automated --help
|
||||||
let
|
let
|
||||||
bin =
|
bin =
|
||||||
@@ -40,7 +40,19 @@ let
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
''
|
''
|
||||||
+ "(${text})";
|
+ lib.optionalString withTmpDir ''
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
|
||||||
|
# we keep the tmpdir when an error occurs for debugging
|
||||||
|
trap 'echo Temporary directory kept at: $tmpdir' ERR
|
||||||
|
# remove the tmpdir when cancelled (postgrest-watch)
|
||||||
|
trap 'rm -rf "$tmpdir"' SIGINT SIGTERM
|
||||||
|
''
|
||||||
|
+ "(${text})"
|
||||||
|
+ lib.optionalString withTmpDir ''
|
||||||
|
|
||||||
|
rm -rf "$tmpdir"
|
||||||
|
'';
|
||||||
|
|
||||||
checkPhase =
|
checkPhase =
|
||||||
''
|
''
|
||||||
|
|||||||
+1
-10
@@ -174,6 +174,7 @@ let
|
|||||||
inherit name;
|
inherit name;
|
||||||
docs = "Run spec and io tests while collecting hpc coverage data.";
|
docs = "Run spec and io tests while collecting hpc coverage data.";
|
||||||
inRootDir = true;
|
inRootDir = true;
|
||||||
|
withTmpDir = true;
|
||||||
}
|
}
|
||||||
''
|
''
|
||||||
env="$(cat ${postgrest.env})"
|
env="$(cat ${postgrest.env})"
|
||||||
@@ -184,14 +185,6 @@ let
|
|||||||
mkdir -p coverage
|
mkdir -p coverage
|
||||||
rm -rf coverage/*
|
rm -rf coverage/*
|
||||||
|
|
||||||
# temporary directory to collect data in
|
|
||||||
tmpdir="$(mktemp -d)"
|
|
||||||
|
|
||||||
# we keep the tmpdir when an error occurs for debugging
|
|
||||||
trap 'echo Temporary directory kept at: $tmpdir' ERR
|
|
||||||
# remove the tmpdir when cancelled (postgrest-watch)
|
|
||||||
trap 'rm -rf "$tmpdir"' SIGINT SIGTERM
|
|
||||||
|
|
||||||
# build once before running all the tests
|
# build once before running all the tests
|
||||||
${cabal-install}/bin/cabal v2-build ${devCabalOptions} --enable-tests all
|
${cabal-install}/bin/cabal v2-build ${devCabalOptions} --enable-tests all
|
||||||
|
|
||||||
@@ -234,8 +227,6 @@ let
|
|||||||
echo "file://$(pwd)/coverage/hpc_index.html"
|
echo "file://$(pwd)/coverage/hpc_index.html"
|
||||||
${ghc}/bin/hpc report coverage/postgrest.tix "$@"
|
${ghc}/bin/hpc report coverage/postgrest.tix "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf "$tmpdir"
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
coverageDraftOverlay =
|
coverageDraftOverlay =
|
||||||
|
|||||||
Reference in New Issue
Block a user