1#!/usr/bin/env bash 2# 3# Copyright (C) 2017 Joseph Benden <joe@benden.us> 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 18 19 20# Params to script are: 21# 1st = Short name 22# 2nd = Long name 23# 3rd+ = Code/Script under test 24 25set -euf 26 27SHORTNAME="$1"; shift 28LONGNAME="$1"; shift 29 30# 31# Begin our fold 32# 33echo -e 'travis_fold:start:'"${SHORTNAME}"'\n\e[0K\e[33;1m'"${LONGNAME}"'\e[0m' 34 35# 36# Begin a timed block 37# 38if [ "$TRAVIS_OS_NAME" == "osx" ]; then 39 SHA256SUM="shasum -a 256" 40else 41 SHA256SUM="sha256sum" 42fi 43START=$(python -c 'import time; print "%.9f" % time.time()' | tr -d '.') 44TOKEN=$(echo "${START}" | $SHA256SUM | cut -c1-7) 45echo -e "travis_time:start:${TOKEN}" 46 47 48# 49# Code under test is here! 50# 51set +e 52"$@" 53rc=$? 54set -e 55 56# 57# End a timed block 58# 59END=$(python -c 'import time; print "%.9f" % time.time()' | tr -d '.') 60ELAPSED=$(echo "$END - $START" | bc) 61echo -e "travis_time:end:${TOKEN}:start=${START},finish=${END},duration=${ELAPSED}" 62 63# 64# End our fold 65# 66echo -e "travis_fold:end:${SHORTNAME}" 67 68exit $rc 69