chore: print execution times for integration tests

This commit is contained in:
DavHau 2022-08-20 18:32:48 +02:00
parent 479dc304b5
commit 027083be7d
2 changed files with 20 additions and 0 deletions

View File

@ -23,9 +23,11 @@
nix nix
] ]
'' ''
cd $TMPDIR
dir=$1 dir=$1
shift shift
echo -e "\ntesting example for $dir" echo -e "\ntesting example for $dir"
start_time=$(date +%s)
cp -r ${examples}/$dir/* . cp -r ${examples}/$dir/* .
chmod -R +w . chmod -R +w .
nix flake lock --override-input dream2nix ${../../.} nix flake lock --override-input dream2nix ${../../.}
@ -37,6 +39,10 @@
nix eval --read-only --no-allow-import-from-derivation .#default.name nix eval --read-only --no-allow-import-from-derivation .#default.name
fi fi
nix flake check "$@" nix flake check "$@"
end_time=$(date +%s)
elapsed=$(( end_time - start_time ))
echo -e "testing example for $dir took $elapsed seconds"
echo "$elapsed sec: $dir" >> $STATS_FILE
''; '';
in in
utils.writePureShellScript utils.writePureShellScript
@ -45,6 +51,7 @@ in
parallel parallel
] ]
'' ''
export STATS_FILE=$(mktemp)
if [ -z ''${1+x} ]; then if [ -z ''${1+x} ]; then
parallel --halt now,fail=1 -j$(nproc) -a <(ls ${examples}) ${testScript} parallel --halt now,fail=1 -j$(nproc) -a <(ls ${examples}) ${testScript}
else else
@ -52,4 +59,7 @@ in
shift shift
${testScript} $arg1 "$@" ${testScript} $arg1 "$@"
fi fi
echo -e "\nExecution times:"
cat $STATS_FILE | sort --numeric-sort
rm $STATS_FILE
'' ''

View File

@ -23,15 +23,21 @@
nix nix
] ]
'' ''
cd $TMPDIR
dir=$1 dir=$1
shift shift
echo -e "\nrunning test $dir" echo -e "\nrunning test $dir"
start_time=$(date +%s)
cp -r ${tests}/$dir/* . cp -r ${tests}/$dir/* .
chmod -R +w . chmod -R +w .
nix flake lock --override-input dream2nix ${../../.} nix flake lock --override-input dream2nix ${../../.}
nix run .#resolveImpure || echo "no resolveImpure probably?" nix run .#resolveImpure || echo "no resolveImpure probably?"
nix build nix build
nix flake check nix flake check
end_time=$(date +%s)
elapsed=$(( end_time - start_time ))
echo -e "testing example for $dir took $elapsed seconds"
echo "$elapsed sec: $dir" >> $STATS_FILE
''; '';
in in
utils.writePureShellScript utils.writePureShellScript
@ -40,6 +46,7 @@ in
parallel parallel
] ]
'' ''
export STATS_FILE=$(mktemp)
if [ -z ''${1+x} ]; then if [ -z ''${1+x} ]; then
parallel --halt now,fail=1 -j$(nproc) -a <(ls ${tests}) ${testScript} parallel --halt now,fail=1 -j$(nproc) -a <(ls ${tests}) ${testScript}
else else
@ -48,4 +55,7 @@ in
${testScript} $arg1 "$@" ${testScript} $arg1 "$@"
fi fi
echo "done running integration tests" echo "done running integration tests"
echo -e "\nExecution times:"
cat $STATS_FILE | sort --numeric-sort
rm $STATS_FILE
'' ''