diff options
-rwxr-xr-x | .travis.sh | 16 | ||||
-rw-r--r-- | .travis.yml | 2 | ||||
-rwxr-xr-x | bin/porticron | 6 | ||||
-rwxr-xr-x | test.bats | 3 | ||||
-rw-r--r-- | test/data/expected-sendmail-input.txt | 6 |
5 files changed, 27 insertions, 6 deletions
diff --git a/.travis.sh b/.travis.sh new file mode 100755 index 0000000..382290f --- /dev/null +++ b/.travis.sh @@ -0,0 +1,16 @@ +#! /bin/bash +# Copyright (C) 2017 Sebastian Pipping <sebastian@pipping.org> +# Licensed under the 3-Clause BSD license +set -e + +PS4='# ' +set -x + + +# Install BATS that the test suite relies on +git clone --depth 1 https://github.com/sstephenson/bats.git +( cd bats && sudo ./install.sh /usr/local ) + + +# Run test suite +./test.bats diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5980c4e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,2 @@ +language: bash +script: ./.travis.sh diff --git a/bin/porticron b/bin/porticron index 844f6ce..a9d9abd 100755 --- a/bin/porticron +++ b/bin/porticron @@ -114,11 +114,11 @@ fi # detect some common variables SCRIPT_NAME=$(basename $0) -FQDN=$(hostname --fqdn) -HOST=$(hostname -s) +: ${FQDN:=$(hostname --fqdn)} +: ${HOST:=$(hostname -s)} IP=$(dig +short ${FQDN} | tr '\n' ' ') : ${DATE:=$(date -R)} -PORTDIR=$(portageq get_repo_path $(portageq envvar EROOT) gentoo) +: ${PORTDIR:=$(portageq get_repo_path $(portageq envvar EROOT) gentoo)} # defaults, second half : ${RCPT:=root} @@ -16,8 +16,11 @@ teardown() { _clear_state ; } PORTICRON() { DATE="$(cat test/data/date-r-output.txt)" \ EMERGE=test/mocks/emerge \ + PORTDIR=/usr/portage \ GLSA_CHECK=/bin/true \ SENDMAIL=${SENDMAIL:-/bin/true} \ + HOST=testbox \ + FQDN=testbox.example.org \ bin/porticron \ -c /dev/null \ "$@" diff --git a/test/data/expected-sendmail-input.txt b/test/data/expected-sendmail-input.txt index 0fac911..1bed225 100644 --- a/test/data/expected-sendmail-input.txt +++ b/test/data/expected-sendmail-input.txt @@ -1,6 +1,6 @@ To: root -From: root@sevendust -Subject: Gentoo package updates on sevendust [ ] +From: root@testbox.example.org +Subject: Gentoo package updates on testbox.example.org [ ] Date: Sun, 19 Feb 2017 16:50:56 +0100 porticron report [Sun, 19 Feb 2017 16:50:56 +0100] @@ -28,7 +28,7 @@ You can perform the upgrade by issuing the command: emerge --deep --update world -as root on sevendust +as root on testbox.example.org It is recommended that you pretend the upgrade first to confirm that the actions that would be taken are reasonable. The upgrade may be |