Skip to content

Commit

Permalink
sh-compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
kspalaiologos committed Jan 5, 2021
1 parent 00e24ca commit c10831f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash
#!/bin/sh

TEST_JIT=0

# TODO: Capture stderr in wsi invocations.

if [[ $# -ne 0 ]]; then
if [ $# -ne 0 ]; then
# one argument => test the JIT too.
TEST_JIT=1
fi

_log() {
echo -n "$(tput setaf 6)$2 $(tput setaf 5)$1$(tput sgr0) $(printf '.%.0s' {1..60})" | head -c 60
echo -n "$(tput setaf 6)$2 $(tput setaf 5)$1$(tput sgr0) $(printf '.%.0s' $(seq 1 70))" | head -c 70
echo -n
}

Expand All @@ -25,14 +25,14 @@ _fail() {
}

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

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

if [[ -f "$1.in" ]]; then
if [ -f "$1.in" ]; then
./wsi $2 "$1" < "$1.in" > "$1.aout" 2> "$1.err"
else
./wsi $2 "$1" > "$1.aout" 2> "$1.err"
Expand All @@ -43,7 +43,7 @@ _interpreter() {
delta=$(diff "$1.aout" "$1.out")
status=$?

[[ $status -eq 1 ]] && _fail "$delta"
[ $status -eq 1 ] && _fail "$delta"

_ok

Expand All @@ -56,7 +56,7 @@ _build() {
./wsi -m "$1" > "$1.ws" 2> "$1.err"
status=$?

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

rm -f "$1.err"

Expand All @@ -69,15 +69,15 @@ _disasm() {
./wsi -d "$1" > "$1.asm" 2> "$1.err"
status=$?

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

rm -f "$1.err"

_ok
}

_run_jit() {
[[ $TEST_JIT -eq 1 ]] && _interpreter "$1" "-j" "[JIT]"
[ $TEST_JIT -eq 1 ] && _interpreter "$1" "-j" "[JIT]"
_interpreter "$1" "" "[RUN]"
}

Expand Down

0 comments on commit c10831f

Please sign in to comment.