Development/RegressionTests

The basics

So you've been asked to submit a regression test. Here's how to get started.

darcs get http://darcs.net
cp tests/EXAMPLE.sh tests/failing-issueXXXX_your-test.sh
# edit away
darcs record
darcs send

Regression tests are just shell scripts that fail on the first command that returns with a non-zero exit status.

See tests/EXAMPLE.sh to get a template for writing these tests. Note also the tests/lib for things you should be able to invoke from your test or tests/toolbox.sh for little tricks you can copy and paste.

NB. If you're not actually expecting your test to fail, then remove 'failing-' from the name.

Tips

  • Name your patch Accept issueNNNN: (short description)
  • Just let darcs send do the thinking (no arguments or flags needed). The darcs repository will automatically specify what email address to send the patch to (one which will cause a patch tracker ticket to be created for your patch).
  • See the Patches checklist

Things to avoid

  1. cp -a (BSD)
  2. sed -r (BSD)
  3. sed -i (BSD)
  4. yes | (doesn't terminate on OpenBSD when SIGPIPE is ignored by the shell, could be fixed by trap - PIPE in the script)
  5. find ... -exec ... {} + (Not supported on OpenBSD)
  6. grep -F (use fgrep instead)

If in doubt, look it up at http://www.opengroup.org/bookstore/catalog/c082.htm, but be aware that not all systems are conforming to the latest SUS.