From 5ab18cfaa6773629817dfd7ea143b53d88d92d38 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 19 Feb 2017 18:12:48 +0100 Subject: Bypass portageq in test suite for testing on Ubuntu --- bin/porticron | 2 +- test.bats | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/porticron b/bin/porticron index 844f6ce..dba785e 100755 --- a/bin/porticron +++ b/bin/porticron @@ -118,7 +118,7 @@ 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} diff --git a/test.bats b/test.bats index 240dddc..81a0e88 100755 --- a/test.bats +++ b/test.bats @@ -16,6 +16,7 @@ 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} \ bin/porticron \ -- cgit v1.2.3-65-gdbad From 662820fa0c9e5cebf23829bdf16bd15af81908c2 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 19 Feb 2017 18:17:52 +0100 Subject: Test suite: Fix hostname --- bin/porticron | 4 ++-- test.bats | 2 ++ test/data/expected-sendmail-input.txt | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/porticron b/bin/porticron index dba785e..a9d9abd 100755 --- a/bin/porticron +++ b/bin/porticron @@ -114,8 +114,8 @@ 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)} diff --git a/test.bats b/test.bats index 81a0e88..9b5101d 100755 --- a/test.bats +++ b/test.bats @@ -19,6 +19,8 @@ PORTICRON() { 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 -- cgit v1.2.3-65-gdbad From a91a6c5406c55df9c2e396bbdf299731d13c4b30 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Sun, 19 Feb 2017 17:34:59 +0100 Subject: Configure Travis CI --- .travis.sh | 16 ++++++++++++++++ .travis.yml | 2 ++ 2 files changed, 18 insertions(+) create mode 100755 .travis.sh create mode 100644 .travis.yml 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 +# 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 -- cgit v1.2.3-65-gdbad