From 027083be7dea33aa215d116eab04bfc1164128c5 Mon Sep 17 00:00:00 2001 From: DavHau Date: Sat, 20 Aug 2022 18:32:48 +0200 Subject: [PATCH] chore: print execution times for integration tests --- tests/examples/default.nix | 10 ++++++++++ tests/integration/default.nix | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/tests/examples/default.nix b/tests/examples/default.nix index b7eac6f8..cd031e88 100644 --- a/tests/examples/default.nix +++ b/tests/examples/default.nix @@ -23,9 +23,11 @@ nix ] '' + cd $TMPDIR dir=$1 shift echo -e "\ntesting example for $dir" + start_time=$(date +%s) cp -r ${examples}/$dir/* . chmod -R +w . nix flake lock --override-input dream2nix ${../../.} @@ -37,6 +39,10 @@ nix eval --read-only --no-allow-import-from-derivation .#default.name fi 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 utils.writePureShellScript @@ -45,6 +51,7 @@ in parallel ] '' + export STATS_FILE=$(mktemp) if [ -z ''${1+x} ]; then parallel --halt now,fail=1 -j$(nproc) -a <(ls ${examples}) ${testScript} else @@ -52,4 +59,7 @@ in shift ${testScript} $arg1 "$@" fi + echo -e "\nExecution times:" + cat $STATS_FILE | sort --numeric-sort + rm $STATS_FILE '' diff --git a/tests/integration/default.nix b/tests/integration/default.nix index 4c058c85..413fca6e 100644 --- a/tests/integration/default.nix +++ b/tests/integration/default.nix @@ -23,15 +23,21 @@ nix ] '' + cd $TMPDIR dir=$1 shift echo -e "\nrunning test $dir" + start_time=$(date +%s) cp -r ${tests}/$dir/* . chmod -R +w . nix flake lock --override-input dream2nix ${../../.} nix run .#resolveImpure || echo "no resolveImpure probably?" nix build 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 utils.writePureShellScript @@ -40,6 +46,7 @@ in parallel ] '' + export STATS_FILE=$(mktemp) if [ -z ''${1+x} ]; then parallel --halt now,fail=1 -j$(nproc) -a <(ls ${tests}) ${testScript} else @@ -48,4 +55,7 @@ in ${testScript} $arg1 "$@" fi echo "done running integration tests" + echo -e "\nExecution times:" + cat $STATS_FILE | sort --numeric-sort + rm $STATS_FILE ''