summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2020-02-23 20:56:10 +0000
committerNadrieril2020-03-05 15:58:31 +0000
commite8f3cc176f3cb44132d20540634aef3384238bce (patch)
tree21ba0bf96c5c52b6a5891e374b8d27a99aa786f3
parent121178b6612721dd37a02b3dda501968a06429fc (diff)
Enable script to add new tests
-rwxr-xr-xupdate-tests.sh26
1 files changed, 23 insertions, 3 deletions
diff --git a/update-tests.sh b/update-tests.sh
index 6630b34..eeb79bd 100755
--- a/update-tests.sh
+++ b/update-tests.sh
@@ -75,7 +75,7 @@ function generate_output_file() {
INPUT_FILE="$(${folder}_input_file "$file")"
OUTPUT_FILE="$(${folder}_output_file "$file")"
if [ ! -f "$OUTPUT_FILE" ]; then
- echo "$INPUT_FILE"
+ echo "$OUTPUT_FILE"
${folder}_process "$INPUT_FILE" > "$tmpfile"
if [ $? -eq 0 ]; then
mv "$tmpfile" "$OUTPUT_FILE"
@@ -88,8 +88,6 @@ function generate_output_file() {
if [ "$1" = "missing" ]; then
echo "Generating missing output files..."
- # This is not robust to spaces in filenames, but there should be none in the
- # repo anyways.
for folder in parser binary-decode semantic-hash import type-inference normalization alpha-normalization; do
fd 'A\.dhallb?$' ./dhall-lang/tests/$folder/success ./dhall/tests/$folder/success \
| sed 's/A.dhallb\?$//' \
@@ -97,6 +95,28 @@ if [ "$1" = "missing" ]; then
generate_output_file "$folder" "$file"
done
done
+
+elif [ "$1" = "add" ]; then
+ # Takes in stdin lists of a path and file contents, like:
+ # normalization/unit/TextShowEmpty Text/show ""
+ # This will add a test to the local tests folder for each such line, and generate
+ # the output using the `dhall` command in the PATH.
+ while read file contents; do
+ folder="$(echo "$file" | cut -d/ -f1)"
+ is_success="$(echo "$file" | cut -d/ -f2)"
+ file="./dhall/tests/$file"
+ mkdir -p "$(dirname "$file")"
+
+ if [ "$is_success" = "success" ]; then
+ INPUT_FILE="${file}A.dhall"
+ echo "$contents" > $INPUT_FILE
+ generate_output_file "$folder" "$file"
+ else
+ INPUT_FILE="${file}.dhall"
+ echo "$contents" > $INPUT_FILE
+ fi
+ done
+
else
echo "$usage_text"
fi