|
Add a shell script for running tests. This will be the main runner for
our test cases (not test.pl). From here, we'll do the necessary setup,
call test.pl, and finally to our cleanup.
Decided to make a shell script for running tests because you can't
directly include Perl subs from another file (i.e. including
`prettify_hipchat` in test.pl).
One option would have been to `require` the file, which also executes the
entire file. This means that things that are not my sub also get
executed which is not what I want, and the script will bork on the `use
Irssi` line because we have no Irssi available when running our tests.
Another option would have been to create a Perl module for my sub which
could then be easily included in my test. The trouble with this approach
is that I don't think I should be making my Irssi script into a module,
and I think it could be bad practise and potentially a small performance
hit if I were to include a custom module from my Irssi script. Not to
mention having to needing 2 different files for a single plugin.
What I'm going to do instead is grab the sub from hipchat-stfu.pl, send
that to a new script, run test.pl (which will require that new script),
and finally rm the newly-created script. Pretty hackish but it gets the
job done with the least amount of disruption and extra formalities in
the code.
Found out about `pcregrep` after I searched for multi-line grep (turns
out this is something grep can't do). Never knew pcregrep existed
before. That's pretty cool. Here's the Stack Overflow post that I copied
to grab the `prettify_hipchat` sub from hipchat-stfu.pl:
http://stackoverflow.com/questions/2686147/how-to-find-patterns-across-multiple-lines-using-grep
|