diff options
author | Patrick Spek <p.spek@tyil.nl> | 2020-03-28 07:25:43 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2020-03-28 07:25:43 +0100 |
commit | 1621c1109bab17cc2d29f948b25989cd97a56618 (patch) | |
tree | c9a106df1ea8170bd88469a3b7d3b135f154d3ac /lib/actions/test.bash | |
parent | 060e616a6e77eb32b37aae24b629970f8efcbac0 (diff) |
Implement test action
Diffstat (limited to 'lib/actions/test.bash')
-rw-r--r-- | lib/actions/test.bash | 76 |
1 files changed, 74 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 } |