#! /bin/sh

set -e
set -u


t=$1

cat $t

set -x

mkdir "$t-c2go"

if ! c2go transpile -o "$t-c2go/main.go" "$t"
then
    exit 1
fi

if ! (cd "$t-c2go" && go build -o "$t.bin")
then
    exit 1
fi

if ! "$t.bin" > "$t.output" 2>&1
then
    exit 1
fi

if ! diff -u "$t.expected" "$t.output"
then
    exit 1
fi
