Last active
March 23, 2016 06:13
-
-
Save bhargavg/cb0a59fb523302039e43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# _ _ | |
# | |__ | |__ __ _ _ __ __ _ __ ___ ____ _ | |
# | '_ \| '_ \ / _` | '__/ _` |/ _` \ \ / / _` | | |
# | |_) | | | | (_| | | | (_| | (_| |\ V / (_| | | |
# |_.__/|_| |_|\__,_|_| \__, |\__,_| \_/ \__, | | |
# |___/ |___/ | |
# | |
# title : script.sh | |
# description : bash script to automate testing of Swift-PM | |
# author : bhargavg | |
# blog : bhargavg.com | |
# usage : source script.sh && test-spm | |
# notes : This script expects following environmental variables to be set | |
# | |
# HOST_IP | |
# HOST_USERNAME | |
# HOST_SPM_DIRECTORY | |
# VM_SPM_PARENT | |
function test-spm { | |
if [ -z "$HOST_SPM_DIRECTORY" ]; then | |
echo "Please set HOST_SPM_DIRECTORY" | |
echo "" | |
echo "Example:" | |
echo "On Mac, if spm sources are present in /Users/bill/workspaces/spm" | |
echo "set the var as: export HOST_SPM_DIRECTORY=/home/bill/workspaces/spm" | |
return 1 | |
fi | |
if [ -z "$HOST_USERNAME" ]; then | |
echo "Please set HOST_USERNAME variable." | |
echo "Host username can be found by running whoami in OS X terminal" | |
return 1 | |
fi | |
case $(uname) in | |
Linux) | |
if [ -z "$VM_SPM_PARENT" ]; then | |
echo "Please set VM_SPM_PARENT" | |
echo "" | |
echo "Example:" | |
echo "On Ubuntu, if you want to have spm, which is copied from host, in /home/bill/workspaces/spm" | |
echo "set the var as: export VM_SPM_PARENT=/home/bill/workspaces" | |
echo "Note, there is no spm directory at the end of the path" | |
return 1 | |
fi | |
if [ -z "$HOST_IP" ]; then | |
echo "Please set HOST_IP variable using, export HOST_IP=ip.address.of.host" | |
return 1 | |
fi | |
rsync --verbose \ | |
--update \ | |
--archive \ | |
--exclude=".build" \ | |
--exclude=".git" \ | |
$HOST_USERNAME@$HOST_IP:"$HOST_SPM_DIRECTORY" \ | |
"$VM_SPM_PARENT" | |
cd "$VM_SPM_PARENT/$(basename $HOST_SPM_DIRECTORY)" | |
Utilities/bootstrap && \ | |
.build/debug/swift-test | |
;; | |
Darwin) | |
cd "$HOST_SPM_DIRECTORY" | |
Utilities/bootstrap && \ | |
.build/debug/swift-test | |
;; | |
esac | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment