Cagao has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I've got a fair few test scripts covering most of our new code (Test::More and Test::Exception), and would like to get something running in cron with email alerts going upon failure.

I've used Hudson in the past but don't really want anything so hardcore.

What (simple) options do I have?

All I need is the tests to run, and only on failure to email a report of the failures.

Thanks,
Rob

Replies are listed 'Best First'.
Re: automated testing
by JavaFan (Canon) on Oct 29, 2010 at 12:57 UTC
    By default, cron will mail anything that appears on STDOUT or STDERR. So all you need to do is to make sure your program is silent on success.

    Note that the "only email on failure" has a failure mode: if the program doesn't run at all, for whatever reason, you won't notice. It's better to have the program report always - then an absence of a report can be noticed.

      If you want to go this route, just add the "MAILTO" variable to the top of your crontab file or define it in .bash_profile (if that is the shell you are using). I personally use this method. I send the output of the scripts I don't care much about to the bit bucket and all others are emailed to me.
      MAILTO="<your email address>"
      Thanks,
      Dru

      Perl, the Leatherman of Programming languages. - qazwart
      When a program always generates a report (including smooth, uneventful execution) you run the risk of missing errors simply by glossing over the report. I know it's stupid, but it's human. Programs should only report on failure, if it can be at all helped. If you define failure as including the case of not running at all, there needs to be some other mechanism in place for checking whether or not the program ran and generating a notification if not.
        When a program always generates a report (including smooth, uneventful execution) you run the risk of missing errors simply by glossing over the report.
        That's why you put the important fact (pass/fail) in the Subject, or first line of the report.

        Having to gloss over a report to find out whether it's about a failure or a success is wrong.

        Of course, if you get a gazillion reports a day, you can automate that as well: just have an addition program reporting to you which reports were failures, successes or passes. Just make sure *that* report gets send every day.

Re: automated testing
by Anonymous Monk on Oct 29, 2010 at 11:49 UTC
Re: automated testing
by pemungkah (Priest) on Oct 30, 2010 at 00:53 UTC
    I recommend sticking with Hudson anyway only because I'm sinfully lazy and Hudson takes care of 90% of what I want. :)