#!/bin/bash # # Usage: # ./oilc.sh set -o nounset set -o pipefail set -o errexit source test/common.sh # TODO: We need a common test framework for command-line syntax of bin/*. The # spec tests are doing that now with $SH. # osh2oil should be oilc translate. # Compare osh code on stdin (fd 0) and expected oil code on fd 3. assert-deps() { bin/oilc deps | diff -u /dev/fd/3 - || fail } usage() { set +o errexit # missing required subcommand bin/oilc test $? -eq 2 || fail bin/oilc invalid test $? -eq 2 || fail # Syntax error echo '<' | bin/oilc deps test $? -eq 2 || fail # File not found bin/oilc deps nonexistent.txt test $? -eq 2 || fail return # Doesn't work yet echo -- bin/oilc --help test $? -eq 0 || fail set -o errexit } deps() { bin/oilc deps $0 test $? -eq 0 || fail # Have to go inside a condition assert-deps <