Skip to content

Instantly share code, notes, and snippets.

@niflostancu
Created November 19, 2012 11:14

Revisions

  1. niflostancu revised this gist Nov 19, 2012. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions eval_bonus.sh
    Original file line number Diff line number Diff line change
    @@ -24,19 +24,21 @@ function test_correct {

    STDERR=$(cat __stderr)

    DIFF_CMD="diff -w -u <(grep -vE '^\s*(#[0-9]+|$)' __stdout) <(grep -vE '^\s*(#[0-9]+|$)' $2) "

    if [ -n "$STDERR" ]; then
    fail "compilation errors"
    echo "-- First lines of stderr below --"
    cat __stderr | head -n 3
    echo "-----"
    echo
    else
    if [ -z "$(diff -w -u <(grep -vE '^\s*(#[0-9]+|$)' __stdout) <(grep -vE '^\s*(#[0-9]+|$)' $2) )" ]; then
    if [ -z "$( eval $DIFF_CMD )" ]; then
    pass
    else
    fail "differences found"
    echo "-- First lines of the diff below --"
    diff -w -u <(grep -vE '^\s*(#[0-9]+|$)' __stdout) <(grep -vE '^\s*(#[0-9]+|$)' $2) | head -n 20
    eval $DIFF_CMD | head -n 20
    echo "-----"
    echo
    fi
  2. niflostancu created this gist Nov 19, 2012.
    59 changes: 59 additions & 0 deletions eval_bonus.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    #!/bin/bash

    TESTS_DIR="_tests"

    export CLASSPATH="$CLASSPATH:./bin:antlr-3.4.jar:java-cup-11a-runtime.jar"

    PARSER="java Semant"

    function fail {
    printf "FAIL (%s)\n" "$1"
    }

    function pass {
    printf "PASS\n"
    }


    function test_correct {
    printf "%-50s" "Testing file $1... "
    rm -f __stdout
    rm -f __stderr

    $PARSER -tail_recursive < $1 1>__stdout 2>__stderr

    STDERR=$(cat __stderr)

    if [ -n "$STDERR" ]; then
    fail "compilation errors"
    echo "-- First lines of stderr below --"
    cat __stderr | head -n 3
    echo "-----"
    echo
    else
    if [ -z "$(diff -w -u <(grep -vE '^\s*(#[0-9]+|$)' __stdout) <(grep -vE '^\s*(#[0-9]+|$)' $2) )" ]; then
    pass
    else
    fail "differences found"
    echo "-- First lines of the diff below --"
    diff -w -u <(grep -vE '^\s*(#[0-9]+|$)' __stdout) <(grep -vE '^\s*(#[0-9]+|$)' $2) | head -n 20
    echo "-----"
    echo
    fi
    fi
    }

    echo "******************************"
    echo "**** Running bonus tests ****"
    echo "******************************"
    echo

    for CL_SRC in $TESTS_DIR/bonus/*.in.ast; do
    test_correct $CL_SRC ${CL_SRC/%in.ast/ast}
    done

    echo
    echo

    rm -f __stdout
    rm -f __stderr