From 663626f06d79aa4d3d3b17e0391897c852658a28 Mon Sep 17 00:00:00 2001 From: Christopher Peplin Date: Sat, 20 Sep 2014 16:26:08 -0400 Subject: Move scripts inside tests directory. Fixed https://github.com/sudar/Arduino-Makefile/issues/260 --- .travis.yml | 4 +- README.md | 9 +- examples/TestSuiteCommon.mk | 2 +- script/bootstrap.sh | 9 -- script/bootstrap/arduino.sh | 44 ------- script/bootstrap/chipkit.sh | 61 --------- script/bootstrap/common.sh | 191 ---------------------------- script/bootstrap/pip-requirements.txt | 1 - script/runtests.sh | 48 ------- tests/script/bootstrap.sh | 9 ++ tests/script/bootstrap/arduino.sh | 44 +++++++ tests/script/bootstrap/chipkit.sh | 61 +++++++++ tests/script/bootstrap/common.sh | 191 ++++++++++++++++++++++++++++ tests/script/bootstrap/pip-requirements.txt | 1 + tests/script/runtests.sh | 48 +++++++ 15 files changed, 363 insertions(+), 360 deletions(-) delete mode 100755 script/bootstrap.sh delete mode 100644 script/bootstrap/arduino.sh delete mode 100644 script/bootstrap/chipkit.sh delete mode 100644 script/bootstrap/common.sh delete mode 100644 script/bootstrap/pip-requirements.txt delete mode 100755 script/runtests.sh create mode 100755 tests/script/bootstrap.sh create mode 100644 tests/script/bootstrap/arduino.sh create mode 100644 tests/script/bootstrap/chipkit.sh create mode 100644 tests/script/bootstrap/common.sh create mode 100644 tests/script/bootstrap/pip-requirements.txt create mode 100755 tests/script/runtests.sh diff --git a/.travis.yml b/.travis.yml index 68efeb5..f97a4ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: c compiler: - gcc -script: script/runtests.sh -before_install: script/bootstrap.sh +script: tests/script/runtests.sh +before_install: tests/script/bootstrap.sh diff --git a/README.md b/README.md index b929f6c..a5f1cff 100644 --- a/README.md +++ b/README.md @@ -215,9 +215,12 @@ Then, the following line must be added to the project Makefile : ## Test Suite This project includes a suite of example Makefiles and small Arduino and chipKIT -programs to assist the developers. Run `script/bootstrap.sh` to attempt to -automatically install the dependencies (Arduino IDE, MPIDE, etc.). Run -`script/runtests.sh` to attempt to compile all of the examples. +programs to assist the maintainers of the Makefile. Run +`tests/script/bootstrap.sh` to attempt to automatically install the dependencies +(Arduino IDE, MPIDE, etc.). Run `tests/script/runtests.sh` to attempt to compile +all of the examples. The bootstrap script is primarily intended for use by a +continuous integration server, specifically Travis CI. It is not intended for +normal users. ### Bare-Arduino–Project diff --git a/examples/TestSuiteCommon.mk b/examples/TestSuiteCommon.mk index 5fa4f50..a66a007 100644 --- a/examples/TestSuiteCommon.mk +++ b/examples/TestSuiteCommon.mk @@ -1,5 +1,5 @@ ARDMK_DIR=../../ -DEPENDENCIES_FOLDER = ../../dependencies +DEPENDENCIES_FOLDER = /var/tmp/Arduino-Makefile-testing-dependencies DEPENDENCIES_MPIDE_DIR = $(DEPENDENCIES_FOLDER)/mpide-0023-linux64-20130817-test ifeq ($(MPIDE_DIR),) diff --git a/script/bootstrap.sh b/script/bootstrap.sh deleted file mode 100755 index 083bf5d..0000000 --- a/script/bootstrap.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -set -e - -SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -pushd $SCRIPTS_DIR/.. - -source $SCRIPTS_DIR/bootstrap/chipkit.sh -source $SCRIPTS_DIR/bootstrap/arduino.sh diff --git a/script/bootstrap/arduino.sh b/script/bootstrap/arduino.sh deleted file mode 100644 index 3c7e9d7..0000000 --- a/script/bootstrap/arduino.sh +++ /dev/null @@ -1,44 +0,0 @@ -set -e -BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $BOOTSTRAP_DIR/common.sh - -echo "Installing dependencies for building for the Arduino" - -if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then - - echo "Installing Arduino..." - - ARDUINO_BASENAME="arduino-1.0.5" - if [ $OS == "cygwin" ]; then - ARDUINO_FILE="$ARDUINO_BASENAME-r2-windows".zip - EXTRACT_COMMAND="unzip -q" - elif [ $OS == "mac" ]; then - ARDUINO_FILE="$ARDUINO_BASENAME-macosx".zip - EXTRACT_COMMAND="unzip -q" - else - ARDUINO_FILE="$ARDUINO_BASENAME-linux64".tgz - EXTRACT_COMMAND="tar -xzf" - fi - - ARDUINO_URL=http://arduino.googlecode.com/files/$ARDUINO_FILE - - _pushd $DEPENDENCIES_FOLDER - if ! test -e $ARDUINO_FILE - then - echo "Downloading Arduino IDE..." - download $ARDUINO_URL $ARDUINO_FILE - fi - - if ! test -d $ARDUINO_BASENAME - then - echo "Installing Arduino to local folder..." - $EXTRACT_COMMAND $ARDUINO_FILE - echo "Arduino installed" - fi - - _popd - -fi - -echo -echo "${bldgreen}Arduino dependencies installed.$txtrst" diff --git a/script/bootstrap/chipkit.sh b/script/bootstrap/chipkit.sh deleted file mode 100644 index efe9615..0000000 --- a/script/bootstrap/chipkit.sh +++ /dev/null @@ -1,61 +0,0 @@ -set -e -BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $BOOTSTRAP_DIR/common.sh - -echo "Installing dependencies for building for the chipKIT" - - -if [ -z "$MPIDE_DIR" ] || ! test -e $MPIDE_DIR || [ $OS == "cygwin" ]; then - - echo "Installing MPIDE..." - - if [ $OS == "cygwin" ]; then - MPIDE_BASENAME="mpide-0023-windows-20130715" - MPIDE_FILE="$MPIDE_BASENAME".zip - EXTRACT_COMMAND="unzip -q" - if ! command -v unzip >/dev/null 2>&1; then - _cygwin_error "unzip" - fi - elif [ $OS == "mac" ]; then - MPIDE_BASENAME=mpide-0023-macosx-20130715 - MPIDE_FILE="$MPIDE_BASENAME".dmg - else - MPIDE_BASENAME=mpide-0023-linux64-20130817-test - MPIDE_FILE="$MPIDE_BASENAME".tgz - EXTRACT_COMMAND="tar -xzf" - fi - - MPIDE_URL=http://chipkit.s3.amazonaws.com/builds/$MPIDE_FILE - - _pushd $DEPENDENCIES_FOLDER - if ! test -e $MPIDE_FILE - then - echo "Downloading MPIDE..." - download $MPIDE_URL $MPIDE_FILE - fi - - if ! test -d $MPIDE_BASENAME - then - echo "Installing MPIDE to local folder..." - if [ $OS == "mac" ]; then - hdiutil attach $MPIDE_FILE - cp -R /Volumes/Mpide/Mpide.app/Contents/Resources/Java $MPIDE_BASENAME - hdiutil detach /Volumes/Mpide - else - $EXTRACT_COMMAND $MPIDE_FILE - fi - echo "MPIDE installed" - fi - - if [ $OS == "cygwin" ]; then - chmod a+x mpide/hardware/pic32/compiler/pic32-tools/bin/* - chmod a+x -R mpide/hardware/pic32/compiler/pic32-tools/pic32mx/ - chmod a+x mpide/*.dll - chmod a+x mpide/hardware/tools/avr/bin/* - fi - _popd - -fi - -echo -echo "${bldgreen}chipKIT dependencies installed.$txtrst" diff --git a/script/bootstrap/common.sh b/script/bootstrap/common.sh deleted file mode 100644 index 695d6b7..0000000 --- a/script/bootstrap/common.sh +++ /dev/null @@ -1,191 +0,0 @@ -#!/usr/bin/env bash - -set -e -BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -if [ -z $COMMON_SOURCED ]; then - - # TODO this is kind of a hacky way of determining if root is required - - # ideally we wouuld set up a little virtualenv in the dependencies folder - SUDO_CMD= - if command -v sudo >/dev/null 2>&1; then - SUDO_CMD="sudo -E" - - if [ -z $CI ] && [ -z $VAGRANT ]; then - echo "The bootstrap script needs to install a few packages to your system as an admin, and we will use the 'sudo' command - enter your password to continue" - $SUDO_CMD ls > /dev/null - fi - fi - - KERNEL=`uname` - ARCH=`uname -m` - if [ ${KERNEL:0:7} == "MINGW32" ]; then - OS="windows" - elif [ ${KERNEL:0:6} == "CYGWIN" ]; then - OS="cygwin" - elif [ $KERNEL == "Darwin" ]; then - OS="mac" - else - OS="linux" - if ! command -v lsb_release >/dev/null 2>&1; then - # Arch Linux - if command -v pacman>/dev/null 2>&1; then - $SUDO_CMD pacman -S lsb-release - fi - fi - - DISTRO=`lsb_release -si` - fi - - - die() { - echo >&2 "${bldred}$@${txtrst}" - exit 1 - } - - _cygwin_error() { - echo - echo "${bldred}Missing \"$1\"${txtrst} - run the Cygwin installer again and select the base package set:" - echo " $CYGWIN_PACKAGES" - echo "After installing the packages, re-run this bootstrap script." - die - } - - if ! command -v tput >/dev/null 2>&1; then - if [ $OS == "cygwin" ]; then - echo "OPTIONAL: Install the \"ncurses\" package in Cygwin to get colored shell output" - fi - else - set +e - # These exit with 1 when provisioning in a Vagrant box...? - txtrst=$(tput sgr0) # reset - bldred=${txtbld}$(tput setaf 1) - bldgreen=${txtbld}$(tput setaf 2) - set -e - fi - - - _pushd() { - pushd $1 > /dev/null - } - - _popd() { - popd > /dev/null - } - - _wait() { - if [ -z $CI ] && [ -z $VAGRANT ]; then - echo "Press Enter when done" - read - fi - } - - _install() { - if [ $OS == "cygwin" ]; then - _cygwin_error $1 - elif [ $OS == "mac" ]; then - # brew exists with 1 if it's already installed - set +e - brew install $1 - set -e - else - if [ -z $DISTRO ]; then - echo - echo "Missing $1 - install it using your distro's package manager or build from source" - _wait - else - if [ $DISTRO == "arch" ]; then - $SUDO_CMD pacman -S $1 - elif [ $DISTRO == "Ubuntu" ]; then - $SUDO_CMD apt-get update -qq - $SUDO_CMD apt-get install $1 -y - else - echo - echo "Missing $1 - install it using your distro's package manager or build from source" - _wait - fi - fi - fi - } - - download() { - url=$1 - filename=$2 - curl $url -L -o $filename - } - - if [ `id -u` == 0 ]; then - die "Error: running as root - don't use 'sudo' with this script" - fi - - if ! command -v unzip >/dev/null 2>&1; then - _install "unzip" - fi - - if ! command -v curl >/dev/null 2>&1; then - if [ $OS == "cygwin" ]; then - _cygwin_error "curl" - else - _install curl - fi - fi - - echo "Storing all downloaded dependencies in the \"dependencies\" folder" - - DEPENDENCIES_FOLDER="dependencies" - mkdir -p $DEPENDENCIES_FOLDER - - if ! command -v make >/dev/null 2>&1; then - if [ $OS == "cygwin" ]; then - _cygwin_error "make" - elif [ $OS == "mac" ]; then - die "Missing 'make' - install the Xcode CLI tools" - else - if [ $DISTRO == "arch" ]; then - _install "base-devel" - elif [ $DISTRO == "Ubuntu" ]; then - _install "build-essential" - fi - fi - fi - - if [ $DISTRO == "Ubuntu" ] && [ $ARCH == "x86_64" ]; then - _install "libc6-i386" - _install "lib32gcc1" - fi - - if ! command -v g++ >/dev/null 2>&1; then - if [ $DISTRO == "Ubuntu" ]; then - _install "g++" - fi - fi - - if ! command -v python >/dev/null 2>&1; then - echo "Installing Python..." - _install "python" - fi - - if ! command -v pip >/dev/null 2>&1; then - echo "Installing Pip..." - if ! command -v easy_install >/dev/null 2>&1; then - _install "python-setuptools" - fi - - if ! command -v easy_install >/dev/null 2>&1; then - die "easy_install not available, can't install pip" - fi - - $SUDO_CMD easy_install pip - fi - - PIP_SUDO_CMD= - if [ -z $VIRTUAL_ENV ]; then - # Only use sudo if the user doesn't have an active virtualenv - PIP_SUDO_CMD=$SUDO_CMD - fi - - $PIP_SUDO_CMD pip install --upgrade setuptools - $PIP_SUDO_CMD pip install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt - - COMMON_SOURCED=1 -fi diff --git a/script/bootstrap/pip-requirements.txt b/script/bootstrap/pip-requirements.txt deleted file mode 100644 index 8313187..0000000 --- a/script/bootstrap/pip-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pyserial==2.7 diff --git a/script/runtests.sh b/script/runtests.sh deleted file mode 100755 index 5f513da..0000000 --- a/script/runtests.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash - -TESTS_DIR=examples - -failures=() - -# These examples cannot be tested easily at the moment as they require -# alternate cores. The MakefileExample doesn't actually contain any source code -# to compile. -NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial) - -for dir in $TESTS_DIR/*/ -do - dir=${dir%*/} - example=${dir##*/} - example_is_testable=true - for non_testable_example in "${NON_TESTABLE_EXAMPLES[@]}"; do - if [[ $example == $non_testable_example ]]; then - example_is_testable=false - break - fi - done - - if ! $example_is_testable; then - echo "Skipping non-testable example $example..." - continue - fi - - pushd $dir - echo "Compiling $example..." - make_output=`make clean` - make_output=`make` - if [[ $? -ne 0 ]]; then - failures+=("$example") - echo "Example $example failed" - fi - popd -done - -for failure in "${failures[@]}"; do - echo "Example $failure failed" -done - -if [[ ${#failures[@]} -eq 0 ]]; then - echo "All tests passed." -else - exit 1 -fi diff --git a/tests/script/bootstrap.sh b/tests/script/bootstrap.sh new file mode 100755 index 0000000..083bf5d --- /dev/null +++ b/tests/script/bootstrap.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +pushd $SCRIPTS_DIR/.. + +source $SCRIPTS_DIR/bootstrap/chipkit.sh +source $SCRIPTS_DIR/bootstrap/arduino.sh diff --git a/tests/script/bootstrap/arduino.sh b/tests/script/bootstrap/arduino.sh new file mode 100644 index 0000000..3c7e9d7 --- /dev/null +++ b/tests/script/bootstrap/arduino.sh @@ -0,0 +1,44 @@ +set -e +BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $BOOTSTRAP_DIR/common.sh + +echo "Installing dependencies for building for the Arduino" + +if [ -z "$ARDUINO_DIR" ] || ! test -e $ARDUINO_DIR || [ $OS == "cygwin" ]; then + + echo "Installing Arduino..." + + ARDUINO_BASENAME="arduino-1.0.5" + if [ $OS == "cygwin" ]; then + ARDUINO_FILE="$ARDUINO_BASENAME-r2-windows".zip + EXTRACT_COMMAND="unzip -q" + elif [ $OS == "mac" ]; then + ARDUINO_FILE="$ARDUINO_BASENAME-macosx".zip + EXTRACT_COMMAND="unzip -q" + else + ARDUINO_FILE="$ARDUINO_BASENAME-linux64".tgz + EXTRACT_COMMAND="tar -xzf" + fi + + ARDUINO_URL=http://arduino.googlecode.com/files/$ARDUINO_FILE + + _pushd $DEPENDENCIES_FOLDER + if ! test -e $ARDUINO_FILE + then + echo "Downloading Arduino IDE..." + download $ARDUINO_URL $ARDUINO_FILE + fi + + if ! test -d $ARDUINO_BASENAME + then + echo "Installing Arduino to local folder..." + $EXTRACT_COMMAND $ARDUINO_FILE + echo "Arduino installed" + fi + + _popd + +fi + +echo +echo "${bldgreen}Arduino dependencies installed.$txtrst" diff --git a/tests/script/bootstrap/chipkit.sh b/tests/script/bootstrap/chipkit.sh new file mode 100644 index 0000000..efe9615 --- /dev/null +++ b/tests/script/bootstrap/chipkit.sh @@ -0,0 +1,61 @@ +set -e +BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $BOOTSTRAP_DIR/common.sh + +echo "Installing dependencies for building for the chipKIT" + + +if [ -z "$MPIDE_DIR" ] || ! test -e $MPIDE_DIR || [ $OS == "cygwin" ]; then + + echo "Installing MPIDE..." + + if [ $OS == "cygwin" ]; then + MPIDE_BASENAME="mpide-0023-windows-20130715" + MPIDE_FILE="$MPIDE_BASENAME".zip + EXTRACT_COMMAND="unzip -q" + if ! command -v unzip >/dev/null 2>&1; then + _cygwin_error "unzip" + fi + elif [ $OS == "mac" ]; then + MPIDE_BASENAME=mpide-0023-macosx-20130715 + MPIDE_FILE="$MPIDE_BASENAME".dmg + else + MPIDE_BASENAME=mpide-0023-linux64-20130817-test + MPIDE_FILE="$MPIDE_BASENAME".tgz + EXTRACT_COMMAND="tar -xzf" + fi + + MPIDE_URL=http://chipkit.s3.amazonaws.com/builds/$MPIDE_FILE + + _pushd $DEPENDENCIES_FOLDER + if ! test -e $MPIDE_FILE + then + echo "Downloading MPIDE..." + download $MPIDE_URL $MPIDE_FILE + fi + + if ! test -d $MPIDE_BASENAME + then + echo "Installing MPIDE to local folder..." + if [ $OS == "mac" ]; then + hdiutil attach $MPIDE_FILE + cp -R /Volumes/Mpide/Mpide.app/Contents/Resources/Java $MPIDE_BASENAME + hdiutil detach /Volumes/Mpide + else + $EXTRACT_COMMAND $MPIDE_FILE + fi + echo "MPIDE installed" + fi + + if [ $OS == "cygwin" ]; then + chmod a+x mpide/hardware/pic32/compiler/pic32-tools/bin/* + chmod a+x -R mpide/hardware/pic32/compiler/pic32-tools/pic32mx/ + chmod a+x mpide/*.dll + chmod a+x mpide/hardware/tools/avr/bin/* + fi + _popd + +fi + +echo +echo "${bldgreen}chipKIT dependencies installed.$txtrst" diff --git a/tests/script/bootstrap/common.sh b/tests/script/bootstrap/common.sh new file mode 100644 index 0000000..a6b6415 --- /dev/null +++ b/tests/script/bootstrap/common.sh @@ -0,0 +1,191 @@ +#!/usr/bin/env bash + +set -e +BOOTSTRAP_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +if [ -z $COMMON_SOURCED ]; then + + # TODO this is kind of a hacky way of determining if root is required - + # ideally we wouuld set up a little virtualenv in the dependencies folder + SUDO_CMD= + if command -v sudo >/dev/null 2>&1; then + SUDO_CMD="sudo -E" + + if [ -z $CI ] && [ -z $VAGRANT ]; then + echo "The bootstrap script needs to install a few packages to your system as an admin, and we will use the 'sudo' command - enter your password to continue" + $SUDO_CMD ls > /dev/null + fi + fi + + KERNEL=`uname` + ARCH=`uname -m` + if [ ${KERNEL:0:7} == "MINGW32" ]; then + OS="windows" + elif [ ${KERNEL:0:6} == "CYGWIN" ]; then + OS="cygwin" + elif [ $KERNEL == "Darwin" ]; then + OS="mac" + else + OS="linux" + if ! command -v lsb_release >/dev/null 2>&1; then + # Arch Linux + if command -v pacman>/dev/null 2>&1; then + $SUDO_CMD pacman -S lsb-release + fi + fi + + DISTRO=`lsb_release -si` + fi + + + die() { + echo >&2 "${bldred}$@${txtrst}" + exit 1 + } + + _cygwin_error() { + echo + echo "${bldred}Missing \"$1\"${txtrst} - run the Cygwin installer again and select the base package set:" + echo " $CYGWIN_PACKAGES" + echo "After installing the packages, re-run this bootstrap script." + die + } + + if ! command -v tput >/dev/null 2>&1; then + if [ $OS == "cygwin" ]; then + echo "OPTIONAL: Install the \"ncurses\" package in Cygwin to get colored shell output" + fi + else + set +e + # These exit with 1 when provisioning in a Vagrant box...? + txtrst=$(tput sgr0) # reset + bldred=${txtbld}$(tput setaf 1) + bldgreen=${txtbld}$(tput setaf 2) + set -e + fi + + + _pushd() { + pushd $1 > /dev/null + } + + _popd() { + popd > /dev/null + } + + _wait() { + if [ -z $CI ] && [ -z $VAGRANT ]; then + echo "Press Enter when done" + read + fi + } + + _install() { + if [ $OS == "cygwin" ]; then + _cygwin_error $1 + elif [ $OS == "mac" ]; then + # brew exists with 1 if it's already installed + set +e + brew install $1 + set -e + else + if [ -z $DISTRO ]; then + echo + echo "Missing $1 - install it using your distro's package manager or build from source" + _wait + else + if [ $DISTRO == "arch" ]; then + $SUDO_CMD pacman -S $1 + elif [ $DISTRO == "Ubuntu" ]; then + $SUDO_CMD apt-get update -qq + $SUDO_CMD apt-get install $1 -y + else + echo + echo "Missing $1 - install it using your distro's package manager or build from source" + _wait + fi + fi + fi + } + + download() { + url=$1 + filename=$2 + curl $url -L -o $filename + } + + if [ `id -u` == 0 ]; then + die "Error: running as root - don't use 'sudo' with this script" + fi + + if ! command -v unzip >/dev/null 2>&1; then + _install "unzip" + fi + + if ! command -v curl >/dev/null 2>&1; then + if [ $OS == "cygwin" ]; then + _cygwin_error "curl" + else + _install curl + fi + fi + + echo "Storing all downloaded dependencies in the \"dependencies\" folder" + + DEPENDENCIES_FOLDER="/var/tmp/Arduino-Makefile-testing-dependencies" + mkdir -p $DEPENDENCIES_FOLDER + + if ! command -v make >/dev/null 2>&1; then + if [ $OS == "cygwin" ]; then + _cygwin_error "make" + elif [ $OS == "mac" ]; then + die "Missing 'make' - install the Xcode CLI tools" + else + if [ $DISTRO == "arch" ]; then + _install "base-devel" + elif [ $DISTRO == "Ubuntu" ]; then + _install "build-essential" + fi + fi + fi + + if [ $DISTRO == "Ubuntu" ] && [ $ARCH == "x86_64" ]; then + _install "libc6-i386" + _install "lib32gcc1" + fi + + if ! command -v g++ >/dev/null 2>&1; then + if [ $DISTRO == "Ubuntu" ]; then + _install "g++" + fi + fi + + if ! command -v python >/dev/null 2>&1; then + echo "Installing Python..." + _install "python" + fi + + if ! command -v pip >/dev/null 2>&1; then + echo "Installing Pip..." + if ! command -v easy_install >/dev/null 2>&1; then + _install "python-setuptools" + fi + + if ! command -v easy_install >/dev/null 2>&1; then + die "easy_install not available, can't install pip" + fi + + $SUDO_CMD easy_install pip + fi + + PIP_SUDO_CMD= + if [ -z $VIRTUAL_ENV ]; then + # Only use sudo if the user doesn't have an active virtualenv + PIP_SUDO_CMD=$SUDO_CMD + fi + + $PIP_SUDO_CMD pip install --upgrade setuptools + $PIP_SUDO_CMD pip install --src dependencies --pre -Ur $BOOTSTRAP_DIR/pip-requirements.txt + + COMMON_SOURCED=1 +fi diff --git a/tests/script/bootstrap/pip-requirements.txt b/tests/script/bootstrap/pip-requirements.txt new file mode 100644 index 0000000..8313187 --- /dev/null +++ b/tests/script/bootstrap/pip-requirements.txt @@ -0,0 +1 @@ +pyserial==2.7 diff --git a/tests/script/runtests.sh b/tests/script/runtests.sh new file mode 100755 index 0000000..5f513da --- /dev/null +++ b/tests/script/runtests.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +TESTS_DIR=examples + +failures=() + +# These examples cannot be tested easily at the moment as they require +# alternate cores. The MakefileExample doesn't actually contain any source code +# to compile. +NON_TESTABLE_EXAMPLES=(ATtinyBlink MakefileExample TinySoftWareSerial) + +for dir in $TESTS_DIR/*/ +do + dir=${dir%*/} + example=${dir##*/} + example_is_testable=true + for non_testable_example in "${NON_TESTABLE_EXAMPLES[@]}"; do + if [[ $example == $non_testable_example ]]; then + example_is_testable=false + break + fi + done + + if ! $example_is_testable; then + echo "Skipping non-testable example $example..." + continue + fi + + pushd $dir + echo "Compiling $example..." + make_output=`make clean` + make_output=`make` + if [[ $? -ne 0 ]]; then + failures+=("$example") + echo "Example $example failed" + fi + popd +done + +for failure in "${failures[@]}"; do + echo "Example $failure failed" +done + +if [[ ${#failures[@]} -eq 0 ]]; then + echo "All tests passed." +else + exit 1 +fi -- cgit v1.2.3