Skip to content

Commit

Permalink
stderr status checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kspalaiologos committed Jan 5, 2021
1 parent 56e1088 commit 00e24ca
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,22 @@ _fail() {
exit 1
}

_if_error() {
[[ $(wc -c < "$1.err") -ne 0 ]] && _fail $(cat "$1.err")
rm -f "$1.err"
}

_interpreter() {
_log "$1" "$3"

if [[ -f "$1.in" ]]; then
./wsi $2 "$1" < "$1.in" > "$1.aout"
./wsi $2 "$1" < "$1.in" > "$1.aout" 2> "$1.err"
else
./wsi $2 "$1" > "$1.aout"
./wsi $2 "$1" > "$1.aout" 2> "$1.err"
fi

_if_error "$1"

delta=$(diff "$1.aout" "$1.out")
status=$?

Expand All @@ -46,21 +53,25 @@ _interpreter() {
_build() {
_log "$1" "[ASM]"

./wsi -m "$1" > "$1.ws"
./wsi -m "$1" > "$1.ws" 2> "$1.err"
status=$?

[[ $status -eq 1 ]] && _fail ""
[[ $status -eq 1 ]] && _fail $(cat $1.err)

rm -f "$1.err"

_ok
}

_disasm() {
_log "$1" "[D/C]"

./wsi -d "$1" > "$1.asm"
./wsi -d "$1" > "$1.asm" 2> "$1.err"
status=$?

[[ $status -eq 1 ]] && _fail ""
[[ $status -eq 1 ]] && _fail $(cat $1.err)

rm -f "$1.err"

_ok
}
Expand Down

0 comments on commit 00e24ca

Please sign in to comment.