aboutsummaryrefslogtreecommitdiffstats
path: root/test.sh
AgeCommit message (Collapse)Author
2015-06-14test.sh: Ensure closing '}' is at the start of a lineTeddy Wing
Otherwise, any '}' inside the subroutine will get matched, and none of the rest of the sub will get outputted to our temporary prettify_hipchat.pl file, causing an error when trying to run our tests.
2015-06-14Get tests working to test `prettify_hipchat` subTeddy Wing
* test.sh: Create a temporary file `prettify_hipchat.pl` that contains only the `prettify_hipchat` subroutine. Then run `test.pl`. Finally remove the file we created to contain the subroutine. * Require `prettify_hipchat.pl` from test.pl. This file contains only the `prettify_hipchat` subroutine, allowing us to require it without concern.
2015-06-14Create test.shTeddy Wing
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