commit: 27122b247cd14a8503fc5a4c126342cdbb973a97 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> AuthorDate: Thu Dec 17 03:26:01 2015 +0000 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> CommitDate: Thu Dec 17 03:26:01 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=27122b24
enable travis build support Rework some of the tests too to work under Ubuntu. .travis.yml | 20 ++++++++++++++++++++ tests/atom_compare/Makefile | 23 +++++++++++++++++------ tests/atom_compare/atom-compare.py | 8 +++++++- tests/init.sh | 2 +- tests/qfile/dotest | 10 ++++++++-- tests/qmerge/dotest | 6 ++++++ travis/install-iniparser.sh | 18 ++++++++++++++++++ travis/lib.sh | 38 ++++++++++++++++++++++++++++++++++++++ travis/main.sh | 18 ++++++++++++++++++ 9 files changed, 133 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..015172e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +# Travis build integration. +# https://docs.travis-ci.com/ + +language: c +compiler: + - clang + - gcc + +sudo: false + +os: + - linux + +addons: + apt: + packages: + +before_install: + - ./travis/install-iniparser.sh +script: ./travis/main.sh diff --git a/tests/atom_compare/Makefile b/tests/atom_compare/Makefile index 8151922..71a980f 100644 --- a/tests/atom_compare/Makefile +++ b/tests/atom_compare/Makefile @@ -4,15 +4,26 @@ include ../subdir.mk all: test test check: static static.q portage - diff -u $(s)/static.good $(b)/static - diff -u $(s)/static.q.good $(b)/static.q - diff -u $(s)/static.good $(b)/portage t = \ - set -f && \ + @set -f && \ $(call mkdir,$(b)) && \ - $(realpath $(lastword $^)) $(1) `sed 's:\#.*::' $<` \ - > $(@:.tests=) + good=`echo $< | sed 's:.tests:.good:'`; \ + out=$(@:.tests=); \ + ret=0; \ + $(realpath $(lastword $^)) $(1) `sed 's:\#.*::' $<` > $$out || ret=$$?; \ + case $$ret in \ + 0) \ + if diff -u $$good $$out; then \ + echo "PASS atom_compare $$out"; \ + else \ + echo "FAIL atom_compare $$out"; \ + fi;; \ + 77) echo "SKIP atom_compare $$out"; ret=0;; \ + *) echo "FAIL atom_compare $$out";; \ + esac; \ + [ $$ret -eq 0 ] && rm -f $$out; \ + exit $$ret static: $(s)/static.tests $(atb)/q $(call t,atom -c) diff --git a/tests/atom_compare/atom-compare.py b/tests/atom_compare/atom-compare.py index 7a9ce89..ab5ed6d 100755 --- a/tests/atom_compare/atom-compare.py +++ b/tests/atom_compare/atom-compare.py @@ -1,6 +1,12 @@ #!/usr/bin/python -import sys,portage +from __future__ import print_function + +import sys +try: + import portage +except ImportError: + sys.exit(77) i = 1 while i < len(sys.argv): diff --git a/tests/init.sh b/tests/init.sh index a17821d..03d728a 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -24,7 +24,7 @@ setup_env() { : ${as:=${ats}/tests/${a}} if [[ -z ${GOOD} ]] && [[ -d ${ats}/.git ]] ; then - eval $(eval_ecolors) 2>/dev/null + eval $(eval_ecolors 2>/dev/null) fi } setup_env diff --git a/tests/qfile/dotest b/tests/qfile/dotest index 32ca841..889aa95 100755 --- a/tests/qfile/dotest +++ b/tests/qfile/dotest @@ -1,5 +1,11 @@ #!/bin/bash +# TODO: Make these work with local vdb instead of requiring /. +if [[ -n ${TRAVIS_OS_NAME} ]] ; then + echo "TODO: Make it work on non-Gentoo system" + exit 0 +fi + . ../init.sh || exit 1 tests=( @@ -9,10 +15,10 @@ tests=( "q file -Co /bin/bash /bin/XXXXX" "/bin/XXXXX" - "echo -e \"/bin/bash\n/bin/XXXXX\" | q file -Cq -f -" + "printf \"/bin/bash\n/bin/XXXXX\" | q file -Cq -f -" "app-shells/bash" - "echo -e \"/bin/bash\n/bin/XXXXX\" | q file -Co -f -" + "printf \"/bin/bash\n/bin/XXXXX\" | q file -Co -f -" "/bin/XXXXX" "q file -Co -x bash /bin/bash" diff --git a/tests/qmerge/dotest b/tests/qmerge/dotest index 3fc01f2..224f3b9 100755 --- a/tests/qmerge/dotest +++ b/tests/qmerge/dotest @@ -1,5 +1,11 @@ #!/bin/bash +# TODO: Make these work with local vdb instead of requiring /. +if [[ -n ${TRAVIS_OS_NAME} ]] ; then + echo "TODO: Make it work on non-Gentoo system" + exit 0 +fi + . ../init.sh || exit 1 set -e diff --git a/travis/install-iniparser.sh b/travis/install-iniparser.sh new file mode 100755 index 0000000..c0edd83 --- /dev/null +++ b/travis/install-iniparser.sh @@ -0,0 +1,18 @@ +#!/bin/bash -e + +. "${0%/*}"/lib.sh + +main() { + local pv="3.1" + local S="iniparser" + travis_fold start dep-iniparser + rm -rf iniparser* + v mkdir -p ../sysroot + v wget http://distfiles.gentoo.org/distfiles/iniparser-${pv}.tar.gz + v tar xf iniparser-${pv}.tar.gz + m -C ${S} + v cp ${S}/libiniparser.a ${S}/src/{dictionary,iniparser}.h ../sysroot/ + v rm -rf iniparser* + travis_fold end dep-iniparser +} +main "$@" diff --git a/travis/lib.sh b/travis/lib.sh new file mode 100644 index 0000000..687ed41 --- /dev/null +++ b/travis/lib.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Common funcs for working w/Travis. + +travis_fold() { + if [[ -n ${TRAVIS_OS_NAME} ]] ; then + printf 'travis_fold:%s:%s\r\n' "$@" | sed 's: :_:g' + fi +} + +if [[ -n ${TRAVIS_OS_NAME} ]] ; then + whitebg=$(tput setab 7) + blackfg=$(tput setaf 0) + normal=$(tput sgr0) +else + whitebg= + blackbg= + normal= +fi +v() { + local fold="" + case $1 in + --fold=*) fold=${1:7}; shift;; + esac + if [[ -n ${fold} ]] ; then + travis_fold start "${fold}" + echo "\$ $*" + "$@" + travis_fold end "${fold}" + else + echo "${whitebg}${blackfg}\$ $*${normal}" + "$@" + fi +} + +ncpus=$(getconf _NPROCESSORS_ONLN) +m() { + v make -j${ncpus} "$@" +} diff --git a/travis/main.sh b/travis/main.sh new file mode 100755 index 0000000..e333685 --- /dev/null +++ b/travis/main.sh @@ -0,0 +1,18 @@ +#!/bin/bash -e + +. "${0%/*}"/lib.sh + +main() { + # For local deps like iniparser. + export CPPFLAGS="-I${PWD}/../sysroot" + export LDFLAGS="-L${PWD}/../sysroot" + + # Standard optimized build. + m + m check + + # Debug build w/ASAN and such enabled. + m debug + m check +} +main "$@"