aboutsummaryrefslogtreecommitdiffstats
path: root/utils.sh
diff options
context:
space:
mode:
author1138-4EB <1138-4EB@users.noreply.github.com>2019-08-16 22:07:46 +0200
committertgingold <tgingold@users.noreply.github.com>2019-08-16 22:07:46 +0200
commitd359d6deb55e5c51707c86263b090fabbc5c41b2 (patch)
treee916cb1f11ec2687bfedbd6ad02f08c3a5b068db /utils.sh
parentc924837dd7f9164aabb37983fb036ee34a9f1e40 (diff)
downloadghdl-yosys-plugin-d359d6deb55e5c51707c86263b090fabbc5c41b2.tar.gz
ghdl-yosys-plugin-d359d6deb55e5c51707c86263b090fabbc5c41b2.tar.bz2
ghdl-yosys-plugin-d359d6deb55e5c51707c86263b090fabbc5c41b2.zip
Run testsuite in Travis CI with docker images (#31)
* makefile: use '--build' shortcut to build ghdl.so * move: rename subdir 'ghdl' to 'src' * travis: add travis config file, build script and utils script * testsuite: do not call ghdl explicitly * readme: update
Diffstat (limited to 'utils.sh')
-rw-r--r--utils.sh72
1 files changed, 72 insertions, 0 deletions
diff --git a/utils.sh b/utils.sh
new file mode 100644
index 0000000..9bbcb47
--- /dev/null
+++ b/utils.sh
@@ -0,0 +1,72 @@
+# Utils for pretty printing logs
+
+enable_color() {
+ ENABLECOLOR='-c '
+ ANSI_RED="\033[31m"
+ ANSI_GREEN="\033[32m"
+ ANSI_YELLOW="\033[33m"
+ ANSI_BLUE="\033[34m"
+ ANSI_MAGENTA="\033[35m"
+ ANSI_CYAN="\033[36;1m"
+ ANSI_DARKCYAN="\033[36m"
+ ANSI_NOCOLOR="\033[0m"
+}
+
+disable_color() { unset ENABLECOLOR ANSI_RED ANSI_GREEN ANSI_YELLOW ANSI_BLUE ANSI_MAGENTA ANSI_CYAN ANSI_DARKCYAN ANSI_NOCOLOR; }
+
+enable_color
+
+#--
+
+print_start() {
+ COL="$ANSI_BLUE"
+ if [ "x$3" != "x" ]; then
+ COL="$3"
+ fi
+ printf "$COL> $2$ANSI_NOCOLOR\n"
+}
+
+travis_start () {
+ print_start "$@"
+}
+travis_finish () {
+ :
+}
+
+[ -n "$TRAVIS" ] && {
+ # This is a trimmed down copy of
+ # https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh
+ travis_time_start() {
+ # `date +%N` returns the date in nanoseconds. It is used as a replacement for $RANDOM, which is only available in bash.
+ travis_timer_id=`date +%N`
+ travis_start_time=$(travis_nanoseconds)
+ echo "travis_time:start:$travis_timer_id"
+ }
+ travis_time_finish() {
+ travis_end_time=$(travis_nanoseconds)
+ local duration=$(($travis_end_time-$travis_start_time))
+ echo "travis_time:end:$travis_timer_id:start=$travis_start_time,finish=$travis_end_time,duration=$duration"
+ }
+
+ if [ "$TRAVIS_OS_NAME" = "osx" ]; then
+ travis_nanoseconds() {
+ date -u '+%s000000000'
+ }
+ else
+ travis_nanoseconds() {
+ date -u '+%s%N'
+ }
+ fi
+
+ travis_start () {
+ echo "travis_fold:start:$1"
+ travis_time_start
+ print_start "$@"
+ }
+
+ travis_finish () {
+ travis_time_finish
+ echo "travis_fold:end:$1"
+ }
+
+} || echo "INFO: not in Travis CI"