Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions scripts/conformance/rspec/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#
# Env:
# RBGO path to rbgo binary (default: built from ./cmd/rbgo EVERY run)
# PARSESWEEP path to parsesweep (default: built EVERY run, beside rbgo)
# RUBY path to MRI ruby (default: first `ruby` on PATH)
# CLONES dir holding rspec-* repos (default: /tmp/rspec-clones)
set -u
Expand All @@ -21,19 +22,27 @@ REPO_ROOT="$(cd "$HERE/../../.." && pwd)"
RBGO="${RBGO:-}"
RUBY="${RUBY:-$(command -v ruby || true)}"
CLONES="${CLONES:-/tmp/rspec-clones}"
PARSESWEEP="${PARSESWEEP:-/tmp/parsesweep}"
PARSESWEEP="${PARSESWEEP:-}"

echo "== build rbgo =="
# #964: built EVERY run, into a directory this run owns and deletes. The old
# default reused any /tmp/rbgo already there, built by whichever checkout ran
# first; scripts/oracle.sh and apps/run.sh then picked that same file up.
# #964, #974: every binary this run builds goes into ONE directory it owns and
# deletes. The old defaults were /tmp/rbgo and /tmp/parsesweep, shared by every
# checkout on the machine, so a sweep could run another checkout's helper. A
# failed mktemp stops the run: an empty directory name would put the binaries
# at /rbgo. INT and TERM exit through the EXIT trap, so an interrupted run
# cleans up too.
BUILD_DIR="$(mktemp -d)" || { echo "mktemp -d failed" >&2; exit 1; }
trap 'rm -rf "$BUILD_DIR"' EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
if [ -z "$RBGO" ]; then
RBGO_DIR="$(mktemp -d)"
trap 'rm -rf "$RBGO_DIR"' EXIT
RBGO="$RBGO_DIR/rbgo"
RBGO="$BUILD_DIR/rbgo"
(cd "$REPO_ROOT" && GOWORK=off go build -o "$RBGO" ./cmd/rbgo) || exit 1
fi
(cd "$REPO_ROOT" && GOWORK=off go build -o "$PARSESWEEP" ./scripts/conformance/rspec/parsesweep) || exit 1
if [ -z "$PARSESWEEP" ]; then
PARSESWEEP="$BUILD_DIR/parsesweep"
(cd "$REPO_ROOT" && GOWORK=off go build -o "$PARSESWEEP" ./scripts/conformance/rspec/parsesweep) || exit 1
fi
echo "rbgo: $RBGO"
go version -m "$RBGO" | grep -E 'vcs\.(revision|modified)' ||
echo " (no vcs stamp in $RBGO: built outside a git tree, or with -buildvcs=false)"
Expand Down
6 changes: 5 additions & 1 deletion scripts/conformance/rubyspec/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ echo "== build rbgo =="
# line either way. The build cache makes a rebuild cheap; a stale binary
# makes a whole sweep measure the wrong code.
if [ -z "$RBGO" ]; then
RBGO_DIR="$(mktemp -d)"
# #974: no `set -e` here, so a failed mktemp must stop the run itself, or
# RBGO would become /rbgo.
RBGO_DIR="$(mktemp -d)" || { echo "mktemp -d failed" >&2; exit 1; }
trap 'rm -rf "$RBGO_DIR"' EXIT # widened below once RESULTS exists
trap 'exit 130' INT
trap 'exit 143' TERM
RBGO="$RBGO_DIR/rbgo"
(cd "$REPO_ROOT" && GOWORK=off CGO_ENABLED=0 go build -o "$RBGO" ./cmd/rbgo) || exit 1
fi
Expand Down
26 changes: 20 additions & 6 deletions scripts/oracle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,34 @@ MRI=${MRI:-ruby}
JRUBY=${JRUBY:-jruby}
TRUFFLE=${TRUFFLE:-truffleruby}

usage() {
echo "usage: $0 (-e '<ruby>' | -b <corpus-file> | <program.rb>)" >&2
exit 2
}

# The arguments are checked before anything is built (#974): a usage error
# answers at once instead of after a compile.
case "${1:-}" in
'') usage ;;
-e | -b | --batch) [ $# -ge 2 ] || usage ;;
esac

# #964: built EVERY run, into a directory this run owns and deletes. It used
# to prefer any /tmp/rbgo already present — another checkout's interpreter.
# #974: /bin/sh may be dash, which runs no EXIT trap on a signal, so INT and
# TERM exit explicitly and the EXIT trap still removes the directory.
if [ -z "$RBGO" ]; then
RBGO_DIR=$(mktemp -d)
RBGO_DIR=$(mktemp -d) || {
echo "mktemp -d failed" >&2
exit 1
}
trap 'rm -rf "$RBGO_DIR"' EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
RBGO="$RBGO_DIR/rbgo"
(cd "$here" && GOWORK=off go build -o "$RBGO" ./cmd/rbgo) || exit 1
fi

usage() {
echo "usage: $0 (-e '<ruby>' | -b <corpus-file> | <program.rb>)" >&2
exit 2
}

# run executes a reference binary, or notes that it is absent (so a missing
# reference is skipped, not counted as a divergence).
run() { # binary, args...
Expand Down
Loading