From 1621c1109bab17cc2d29f948b25989cd97a56618 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Sat, 28 Mar 2020 07:25:43 +0100 Subject: Implement test action --- lib/actions/test.bash | 76 +++++++++++++++++++++++++++++++++++++++++++++++++-- lib/util.bash | 1 + 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/lib/actions/test.bash b/lib/actions/test.bash index 68c6d60..482666d 100644 --- a/lib/actions/test.bash +++ b/lib/actions/test.bash @@ -1,6 +1,78 @@ #!/usr/bin/env bash action() { - # TODO: Implement test - die "Not yet implemented" + local OPTIND + local raku + + while getopts ":p:" opt + do + case "$opt" in + p) RSTAR_PREFIX=$OPTARG ;; + *) emerg "Invalid option specified: $opt" ;; + esac + done + + shift $(( OPTIND - 1 )) + + raku="$RSTAR_PREFIX/bin/raku" + + # Ensure raku is available + if [[ ! -f $raku ]] + then + emerg "No Raku executable available at $raku." + emerg "Make sure you ran the install command." + emerg "Also, if you installed with -p, you must specify it for test as well" + fi + + # If no specific targets are specified, set all targets + if (( $# < 1 )) + then + set -- spectest modules + fi + + # Run each test target + for target in "$@" + do + if [[ $(type -t "action_test_$target") != "function" ]] + then + crit "Test target '$target' is invalid" + continue + fi + + "action_test_$target" + done +} + +action_test_modules() { + local modules + local prove + + modules="$(tmpfile)" + prove="$RSTAR_PREFIX/share/perl6/vendor/bin/prove6" + + awk '/^[^#]/ {print $1}' "$BASEDIR/etc/modules.txt" > "$modules" + + while read -r module + do + chgdir "$BASEDIR/src/rakudo-star-modules/$module" + "$prove" -v . + done < "$modules" +} + +action_test_spectest() { + local destination + local source + + destination="$(tmpdir)" + source="$BASEDIR/src/rakudo-$(config_etc_kv "dist_rakudo.txt" "version")" + + notice "Using $destination as working directory" + + # Grab the source files + cp -R -- "$source/." "$destination" + chgdir "$destination" + + # Run the spectest + perl Configure.pl --prefix="$RSTAR_PREFIX" + make spectest } diff --git a/lib/util.bash b/lib/util.bash index 92ff1bc..97131c3 100644 --- a/lib/util.bash +++ b/lib/util.bash @@ -3,6 +3,7 @@ # Change the working directory. In usage, this is the same as using cd, # however, it will make additional checks to ensure everything is going fine. chgdir() { + debug "Changing workdir to $1" cd -- "$1" || die "Failed to change directory to $1" } -- cgit v1.1