aboutsummaryrefslogtreecommitdiffstats
path: root/test.sh
diff options
context:
space:
mode:
authorTeddy Wing2015-06-14 00:34:18 -0400
committerTeddy Wing2015-06-14 00:41:35 -0400
commitb40bd57c22669263ea2db88da07c5abac17157cf (patch)
treed9dccac119f8ebca8c98e9c54b89620dee76247f /test.sh
parent721c0d3b86f3c31152d3c757a82f9318dcbbe7ea (diff)
downloadirssi-hipchat-stfu-b40bd57c22669263ea2db88da07c5abac17157cf.tar.bz2
Create test.sh
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
Diffstat (limited to 'test.sh')
-rw-r--r--test.sh3
1 files changed, 3 insertions, 0 deletions
diff --git a/test.sh b/test.sh
new file mode 100644
index 0000000..209ccdb
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env sh
+
+pcregrep -M '^sub prettify_hipchat {.*(\n|.)*?}' hipchat-stfu.pl