You can probably rewrite foo.pl like this:
sub foo {
# original foo.pl code here
return "all right";
}
foo() unless defined caller(); # call foo() unless require'd
And then in your tests do something like
# Test::More style used....
use Test::More tests => 1;
require "foo.pl";
is(foo(),"all right","Foo() executed normally")
Update:
You'll probably not want everything in the foo() function, just the stuff that's needed to set up the gui.
For instance, the run loop will probably be set up by the test module (but I'm only guessing, I've never used the Gtk test modules).
Update 2::
Actually, most of the above is wrong. It will give you some hints on how to solve your problem, though. I'm going to eat something now.
Joost.
|