From 492e2557e18ab0610b7e145a04b4d54a10f07332 Mon Sep 17 00:00:00 2001 From: Lieven Hollevoet Date: Tue, 12 Jul 2016 08:27:42 +0200 Subject: [PATCH 1/2] Add Travis CI regression test support This pull request adds the required files to run a basic regression test on the MisterHouse code using Travis. All control is in the `.travis.yml` file in the root of the repository. Every time somebody commits code, a new build is triggered on Travis. The test code that is executed is: ``` mh -code_dir code/test ``` With the current code that is present in that folder, MisterHouse is started, runs for one minute and then exits. Results are here: https://travis-ci.org/hollie/misterhouse/builds Rationale: * to offer a framework that allows automatic code verification for new pull requests * to speed up acceptance of new pull requests that pass the tests Note: * I had to change the exit code of MisterHouse to '0' for an intended exit (so that the test can stop at a certain point in time). That exit code used to be 1, and I changed both the exit code and the loop code that checks the exit code. We need to check if there are other uses of the exit code '1' that could be broken by this change * More test code needs to be added to the `code/test/` folder. E.g. performing a basic check if the web interface is up, adding specific test code for modules, ... So: this is a start, I hope we can expand it to cover larger parts of the MisterHouse code. --- .travis.yml | 3 +++ README.md | 2 ++ bin/mh | 4 ++-- bin/mhl | 2 +- code/test/test_mh.pl | 15 +++++++++++++++ 5 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 .travis.yml create mode 100644 code/test/test_mh.pl diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..d0fdc25bc --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: perl +install: true +script: cd bin ; ./mh -tk 0 -code_dir ../code/test diff --git a/README.md b/README.md index 76359864d..ab4698402 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ MisterHouse =========== +[![Build Status](https://travis-ci.org/hollie/misterhouse.svg?branch=master)](https://travis-ci.org/hollie/misterhouse) + Perl open source home automation program. It's fun, it's free, and it's entirely geeky. * [Quickstart Guide](https://github.com/hollie/misterhouse/wiki/Getting-started) diff --git a/bin/mh b/bin/mh index a1315e43d..48e9de26d 100755 --- a/bin/mh +++ b/bin/mh @@ -3705,7 +3705,7 @@ sub exit_pgm { $sock->close() if $sock; } - # Use exit code 1 to mean we exited on purpose ... anything else + # Use exit code 0 to mean we exited on purpose ... anything else # we can use in mh_loop to mean accidental exit, 'better restart' if ($restart) { &print_log("Restarting mh"); @@ -3717,7 +3717,7 @@ sub exit_pgm { print "Bye Bye\n"; # exit 1; - POSIX::_exit(1); # MUCH faster ... but no DESTROY or END called. + POSIX::_exit(0); # MUCH faster ... but no DESTROY or END called. } } diff --git a/bin/mhl b/bin/mhl index a0cef728b..f7b0ec022 100755 --- a/bin/mhl +++ b/bin/mhl @@ -23,7 +23,7 @@ while [ 1 = 1 ]; do rc=$? echo mh rc=$rc - if [ $rc = 1 ]; then + if [ $rc = 0 ]; then echo mh exited normally exit fi diff --git a/code/test/test_mh.pl b/code/test/test_mh.pl new file mode 100644 index 000000000..ee2686467 --- /dev/null +++ b/code/test/test_mh.pl @@ -0,0 +1,15 @@ +# Category=Test + +# At startup program a time to stop the test after one minute +my $shutdown_timer = new Timer; #noloop +$shutdown_timer->set(60, \&shutdown); #noloop + +if ($Startup) { + $shutdown_timer->start(); + print_log "Shutdown timer set"; +} + +sub shutdown { + print_log "Stopping self-test, exit..."; + run_voice_cmd("Exit Mister House"); +} From af11f8ff694cd9f725f87696902003a57872e4c4 Mon Sep 17 00:00:00 2001 From: Lieven Hollevoet Date: Mon, 25 Jul 2016 18:06:32 +0200 Subject: [PATCH 2/2] Update the perl version for the CI tests on Travis Added all stable releases and 5.08 on request of Howard. --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index d0fdc25bc..d6402e1fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,11 @@ language: perl +perl: + - "5.24" + - "5.22" + - "5.20" + - "5.18" + - "5.16" + - "5.14" + - "5.08" install: true script: cd bin ; ./mh -tk 0 -code_dir ../code/test