Testing iTunes

brian_d_foy on 2002-09-20T22:30:24

I am adding all sorts of nifty things to Mac::iTunes which I will show off at the Mac OS X Conference in a couple of weeks. Besides the modules, I have recently added a couple of CGI script examples, and now have a half-done Tk version of iTunes (which means I can control it from other machines anywhere on the network).

Testing example scripts is not as easy as modules, though. MakeMaker handles it just fine, but it is not clear what I should put in the tests.

Of course, I want to make sure that they compile. I can do something like I did in a recent project (that does not use Test::More)

foreach my $file ( @files )
        {
        my $syntax_check = `perl -c $file 2>&1`;
        print $syntax_check =~ /syntax OK/ ? '' : 'not ', 
                "ok - syntax check for $file\n";
        print STDERR " $file - syntax OK\n" if $syntax_check =~ /syntax OK/;
        }


From there I can do similar things with command line arguments.

From there it gets more complex. If I need to set up the environment (either adding to, taking from, or changing), I need to run another process which then runs the script and somehow get any output back to the original test script.

One thing I need to do immediately is test a CGI script, but I do not want to really on a web server to do it. The CGI is really simple, and all I need to do is do what the server normally does: set some environment variables and sometimes make STDIN available.

If I figure that out, I need something to do regression testing with templates. If my CGI program uses Text::Template, for instance, I need to make sure that the right things get filled in. The CGI script decides what to put in the template, so I need a way other than that script to test its output. Imagine a script that inserts the current date into the template. The tests should pass even if the times differ by a couple of seconds, are in a different time zone, and so on.

All of this should work on anyone's machine.

Sounds like I have some more Test:: modules to write. :)