#!/usr/bin/env bash # # Sanity checks for the shell. # # Usage: # ./smoke.sh set -o nounset set -o pipefail set -o errexit source test/common.sh proc ast { bin/osh -n -c 'echo hi' bin/osh -n --ast-format text -c 'echo hi' bin/osh -n --ast-format abbrev-html -c 'echo hi' bin/osh -n --ast-format html -c 'echo hi' # Not dumping to terminal if bin/osh -n --ast-format oheap -c 'echo hi' { die "Should have failed" } local ast_bin=_tmp/smoke-ast.bin bin/osh -n --ast-format oheap -c 'echo hi' > $ast_bin ls -l $ast_bin hexdump -C $ast_bin } # Read from a file. proc osh-file { echo ===== Hello cat >_tmp/hi.sh <_tmp/no-newline.sh $OSH _tmp/no-newline.sh } # Read from stdin. proc osh-stdin { $OSH < _tmp/hi.sh echo ===== EMPTY $OSH < _tmp/empty.sh echo ===== NO TRAILING NEWLINE $OSH < _tmp/no-newline.sh # Line continuation tests $OSH < >> )' #_error-case 'echo ${' } proc exit-builtin-interactive { set +o errexit echo 'echo one; exit 42; echo two' | bin/osh -i assert $Status -eq 42 } readonly -a PASSING=( ast osh-file osh-stdin osh-interactive exit-builtin-interactive help ) proc all-passing { run-all $(PASSING[@]) } @ARGV