Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I've recently seen a lot of references to test driven development on the Monastery, and it sounds like a great idea. So I keep wondering whether I can use it. The problem is that as a sysadmin, almost all the code I write is essentially glorfied shell scripts. How can testing be incorporated into code that doesn't really compute values, but instead does something?

For instance, I've got a script that moves users' mailboxes into their home directories (where quota is more strictly monitored) if they get too large. I've got another that kills processes left by users that are no longer logged in (where "logged in" involves checking whether the user has any of various shells still running) and deletes any temporary files they left behind.

The details aren't that important, but what matters is that instead of being a collection of small subroutines that compute values (and can therefore be tested with all sorts of inputs to confirm that they produce the correct output), what I deal with are just big (but usually no more than a screenful or so of text) scripts that interact with the real world. I haven't come up with any automated testing proceedures, but putting one out there untested is very dangerous (when a couple thousand users lose their mail due to a bug, people become unhappy). So I'm doing ad hoc testing by running with the "payload" commented out, and multiple prints all over the place to show what it would be doing, and knowing in my gut that there has to be a better way. So I come seeking wisdom.

What are good approaches you've come up with for this sort of thing? Is there a way to use the Test:: modules with programs like this, or is there another approach that works better?

In reply to Test driven development and glue code by Eimi Metamorphoumai

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (10)
    As of 2021-03-04 19:38 GMT
    Find Nodes?
      Voting Booth?
      My favorite kind of desktop background is:

      Results (107 votes). Check out past polls.