#!/bin/sh
# Run unit tests in a VM, and land change only if they pass.

current_branch=$(git symbolic-ref --short -q HEAD)
if [ "master" != "$current_branch" ]; then
    # Can only run this if not on master
    arc land --hold
fi

vagrant up
if vagrant ssh -c 'cd /vagrant; ./runtests'; then
    echo 'Unit test passed; landing change'
    arc amend && git push
else
    echo 'Unit test failures; aborting'
fi

Add script to run tests before landing changes.
Add script to run tests before landing changes.

Summary:
tools/test_and_submit.sh will merge your changes into master, run the test
suite on the resultant working copy, and push only if the tests pass.
Consider using it instead of `arc land` to submit changes.

Test Plan:
Checked that script aborts if the tests fail; successfully
used it to submit an accepted commit. The script probably won't handle every
weird Git edge-case though.

Reviewers: spang

Reviewed By: spang

CC: kav-ya, mg

Differential Revision: https://review.inboxapp.com/D46
