From 80c2d8385556ef3f82858f9d8e5050a175cec0ad Mon Sep 17 00:00:00 2001 From: Anish Athalye Date: Sat, 16 Jan 2016 16:43:58 -0500 Subject: Move Travis CI test script --- .travis.yml | 2 +- .travis/run_tests | 75 ------------------------------------------------------- test/test_travis | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 76 deletions(-) delete mode 100755 .travis/run_tests create mode 100755 test/test_travis diff --git a/.travis.yml b/.travis.yml index f80bc62..8c2d54c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,4 +7,4 @@ python: - "3.5" script: - - ./.travis/run_tests + - ./test/test_travis diff --git a/.travis/run_tests b/.travis/run_tests deleted file mode 100755 index 8117ec9..0000000 --- a/.travis/run_tests +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env bash -set -e - -# For debug only: -# export DEBUG=true -# set -x -# set -v - -BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" - -# Travis runs do not rely on Vagrant -export USE_VAGRANT=false -export DOTBOT_EXEC="${BASEDIR}/bin/dotbot" - -cd "${BASEDIR}" -. "test/driver-lib.bash" - -travis_initialize() { - echo "initializing." - tests_run=0 - tests_passed=0 - tests_failed=0 - tests_total="${1}" - local plural="" && [ "${tests_total}" -gt 1 ] && plural="s" - printf -- "running %d test%s...\n\n" "${tests_total}" "${plural}" -} - -travis_cleanup() { - # Remove all dotfiles installed since the start, ignoring the main - # dotfiles directory, and the dotbot source directory - find ~ -mindepth 1 -readable -newermt "${date_stamp}" \ - -not \( -path ~ -o -path "${BASEDIR}/*" \ - -o -path ~/dotfiles \) \ - -exec rm -rf {} + -} - -travis_run_test() { - tests_run=$((tests_run + 1)) - printf '[%d/%d] (%s)\n' "${tests_run}" "${tests_total}" "${1}" - cd ${BASEDIR}/test/tests - if bash ${1} ; then - pass - else - fail - fi - travis_cleanup || die "unable to clean up system." -} - -date_stamp="$(date --rfc-3339=ns)" -start="$(date +%s)" - -declare -a tests=() - -if [ $# -eq 0 ]; then - while read file; do - tests+=("${file}") - done < <(find ${BASEDIR}/test/tests -type f -name '*.bash') -else - tests=("$@") -fi - -travis_initialize "${#tests[@]}" - -for file in "${tests[@]}"; do - travis_run_test "$(basename "${file}")" -done - -if report; then - ret=0 -else - ret=1 -fi - -echo "(tests run in $(($(date +%s) - start)) seconds)" -exit ${ret} diff --git a/test/test_travis b/test/test_travis new file mode 100755 index 0000000..8117ec9 --- /dev/null +++ b/test/test_travis @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +set -e + +# For debug only: +# export DEBUG=true +# set -x +# set -v + +BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +# Travis runs do not rely on Vagrant +export USE_VAGRANT=false +export DOTBOT_EXEC="${BASEDIR}/bin/dotbot" + +cd "${BASEDIR}" +. "test/driver-lib.bash" + +travis_initialize() { + echo "initializing." + tests_run=0 + tests_passed=0 + tests_failed=0 + tests_total="${1}" + local plural="" && [ "${tests_total}" -gt 1 ] && plural="s" + printf -- "running %d test%s...\n\n" "${tests_total}" "${plural}" +} + +travis_cleanup() { + # Remove all dotfiles installed since the start, ignoring the main + # dotfiles directory, and the dotbot source directory + find ~ -mindepth 1 -readable -newermt "${date_stamp}" \ + -not \( -path ~ -o -path "${BASEDIR}/*" \ + -o -path ~/dotfiles \) \ + -exec rm -rf {} + +} + +travis_run_test() { + tests_run=$((tests_run + 1)) + printf '[%d/%d] (%s)\n' "${tests_run}" "${tests_total}" "${1}" + cd ${BASEDIR}/test/tests + if bash ${1} ; then + pass + else + fail + fi + travis_cleanup || die "unable to clean up system." +} + +date_stamp="$(date --rfc-3339=ns)" +start="$(date +%s)" + +declare -a tests=() + +if [ $# -eq 0 ]; then + while read file; do + tests+=("${file}") + done < <(find ${BASEDIR}/test/tests -type f -name '*.bash') +else + tests=("$@") +fi + +travis_initialize "${#tests[@]}" + +for file in "${tests[@]}"; do + travis_run_test "$(basename "${file}")" +done + +if report; then + ret=0 +else + ret=1 +fi + +echo "(tests run in $(($(date +%s) - start)) seconds)" +exit ${ret} -- cgit v1.2.3