#!/bin/bash # # Usage: # ./regtest.sh set -o nounset set -o pipefail set -o errexit const THIS_DIR = $[cd $[dirname $0] && pwd] source $THIS_DIR/common.sh const REPO_ROOT = $[cd $THIS_DIR/.. && pwd] # Everything we care about compiling: proc _all-py-files { var fmt = $1 # Python files (including build scripts and unit tests, which aren't in the # binary). oil-python-sources $REPO_ROOT $fmt # - stdlib deps of bin.oil and bin.opy_ # NOTE: These end with .pyc cat \ $REPO_ROOT/_build/py-to-compile.txt \ $REPO_ROOT/_build/{oil,opy}/py-to-compile.txt } # Only compile unique proc all-py-files { _all-py-files @Argv | sort | uniq } proc _copy { var dest_dir = $1 var src_path = $2 var dest_rel_path = $3 var dest = "$dest_dir/$dest_rel_path" set dest = $(dest%c) # .pyc -> py mkdir -p $[dirname $dest] cp -v --no-target-directory $src_path $dest } proc import { var dest = '_regtest/src' mkdir -p $dest all-py-files '%p %P\n' | xargs -n 2 -- $0 _copy $dest } # # Now compiled the files imported # proc manifest { # add .pyc at the end find _regtest/src -type f -a -printf '%p %Pc\n' } # 19 seconds on lisa. This should be a benchmark. # TODO: Parallelize with xargs. compile-manifest in build.sh is serial. Just # needs a mkdir. proc compile { var pat = $(1:-) var dest = '_tmp/regtest' mkdir -p $dest time manifest | egrep $pat | ./build.sh compile-manifest $dest } proc checksum { find _tmp/regtest -type f | xargs $THIS_DIR/../bin/opyc dis-md5 | sort -n } proc verify-golden { if checksum | diff -u _regtest/dis-md5.golden.txt - { echo OK } else { return 1 } } proc lines { find _regtest/src -type f | xargs wc -l | sort -n } proc compare-one { var rel_path = ''opy/compiler2/transformer.pyc'' ls -l _tmp/regtest/$rel_path # TODO: Copy zip from flanders? unzip -p $rel_path _tmp/flanders/bytecode-opy.zip | od -c } proc smoke-three-modes { compile oil $THIS_DIR/../bin/opyc eval '1+2*3' echo '4+5*6' | $THIS_DIR/../bin/opyc repl } @Argv