2022-03-27 18:11:32 +03:00
|
|
|
{
|
|
|
|
self,
|
|
|
|
lib,
|
2022-04-23 16:09:55 +03:00
|
|
|
async,
|
|
|
|
bash,
|
2022-03-27 18:11:32 +03:00
|
|
|
coreutils,
|
2022-03-28 19:41:33 +03:00
|
|
|
git,
|
2022-08-31 12:51:32 +03:00
|
|
|
gnugrep,
|
|
|
|
jq,
|
2022-05-17 14:56:08 +03:00
|
|
|
parallel,
|
2022-03-27 18:11:32 +03:00
|
|
|
nix,
|
2022-08-31 12:51:32 +03:00
|
|
|
pkgs,
|
2022-11-16 03:53:40 +03:00
|
|
|
framework,
|
2022-03-27 18:11:32 +03:00
|
|
|
...
|
|
|
|
}: let
|
|
|
|
l = lib // builtins;
|
|
|
|
examples = ../../examples;
|
2022-05-17 14:56:08 +03:00
|
|
|
testScript =
|
2022-11-16 03:53:40 +03:00
|
|
|
framework.utils.writePureShellScript
|
2022-05-17 14:56:08 +03:00
|
|
|
[
|
|
|
|
async
|
|
|
|
bash
|
|
|
|
coreutils
|
|
|
|
git
|
2022-08-31 12:51:32 +03:00
|
|
|
gnugrep
|
|
|
|
jq
|
2022-05-17 14:56:08 +03:00
|
|
|
nix
|
|
|
|
]
|
|
|
|
''
|
2022-08-20 19:32:48 +03:00
|
|
|
cd $TMPDIR
|
2022-05-17 14:56:08 +03:00
|
|
|
dir=$1
|
2022-05-18 21:42:05 +03:00
|
|
|
shift
|
2022-05-18 21:45:26 +03:00
|
|
|
echo -e "\ntesting example for $dir"
|
2022-08-20 19:32:48 +03:00
|
|
|
start_time=$(date +%s)
|
2022-05-17 14:56:08 +03:00
|
|
|
cp -r ${examples}/$dir/* .
|
|
|
|
chmod -R +w .
|
2022-12-28 10:27:06 +03:00
|
|
|
if [ -n "''${NIX:-}" ]; then
|
2022-12-28 09:19:57 +03:00
|
|
|
PATH="$(dirname $NIX):$PATH"
|
|
|
|
fi
|
2022-05-17 14:56:08 +03:00
|
|
|
nix flake lock --override-input dream2nix ${../../.}
|
2022-08-31 12:51:32 +03:00
|
|
|
if nix flake show | grep -q resolveImpure; then
|
|
|
|
nix run .#resolveImpure --show-trace
|
|
|
|
fi
|
2022-07-24 19:53:38 +03:00
|
|
|
# disable --read-only check for these because they do IFD so they will
|
|
|
|
# write to store at eval time
|
|
|
|
evalBlockList=("haskell_cabal-plan" "haskell_stack-lock")
|
2022-08-31 12:51:32 +03:00
|
|
|
if [[ ! ((''${evalBlockList[*]} =~ "$dir")) ]] \
|
|
|
|
&& [ "$(nix flake show --json | jq 'select(.packages."x86_64-linux".default.name)')" != "" ]; then
|
2022-07-24 19:53:38 +03:00
|
|
|
nix eval --read-only --no-allow-import-from-derivation .#default.name
|
|
|
|
fi
|
2022-05-18 21:42:05 +03:00
|
|
|
nix flake check "$@"
|
2022-08-20 19:32:48 +03:00
|
|
|
end_time=$(date +%s)
|
|
|
|
elapsed=$(( end_time - start_time ))
|
|
|
|
echo -e "testing example for $dir took $elapsed seconds"
|
|
|
|
echo "$elapsed sec: $dir" >> $STATS_FILE
|
2022-05-17 14:56:08 +03:00
|
|
|
'';
|
2022-03-27 18:11:32 +03:00
|
|
|
in
|
2022-11-16 03:53:40 +03:00
|
|
|
framework.utils.writePureShellScript
|
2022-03-27 18:11:32 +03:00
|
|
|
[
|
|
|
|
coreutils
|
2022-05-17 14:56:08 +03:00
|
|
|
parallel
|
2022-03-27 18:11:32 +03:00
|
|
|
]
|
|
|
|
''
|
2022-08-20 19:32:48 +03:00
|
|
|
export STATS_FILE=$(mktemp)
|
2022-04-17 15:42:48 +03:00
|
|
|
if [ -z ''${1+x} ]; then
|
2022-08-24 14:14:07 +03:00
|
|
|
JOBS=''${JOBS:-$(nproc)}
|
|
|
|
parallel --halt now,fail=1 -j$JOBS -a <(ls ${examples}) ${testScript}
|
2022-04-17 15:42:48 +03:00
|
|
|
else
|
2022-05-18 21:42:05 +03:00
|
|
|
arg1=$1
|
|
|
|
shift
|
|
|
|
${testScript} $arg1 "$@"
|
2022-04-15 02:15:37 +03:00
|
|
|
fi
|
2022-08-20 19:32:48 +03:00
|
|
|
echo -e "\nExecution times:"
|
|
|
|
cat $STATS_FILE | sort --numeric-sort
|
|
|
|
rm $STATS_FILE
|
2022-03-27 18:11:32 +03:00
|
|
|
''
|