* Try to load the script in irssi
* Check perlcritic report
+To run tests yourself, you first need several programs installed:
+* [zsh](http://zsh.sourceforge.net/)
+* [irssi](https://irssi.org)
+* cpan [Perl::Critic](https://metacpan.org/pod/Perl::Critic)
+* cpan [Perl::PrereqScanner](https://metacpan.org/pod/Perl::PrereqScanner)
+* cpan -f [Tree::XPathEngine](https://metacpan.org/pod/Tree::XPathEngine)
+* cpan [PPIx::XPath](https://metacpan.org/pod/PPIx::XPath)
+
+Then, run it like this:
+
+ ./_testing/run-test.zsh yourscript
+
+One "." should be printed.
+
Evaluation of test success is done in report-test.zsh. Currently the
following criteria lead to fail:
* Script doesn't compile/load
* Script doesn't use strict; or uses two-arg "open"
* Script doesn't define %IRSSI and $VERSION
+To see the test results, run:
+
+ ./_testing/report-test.zsh yourscript
+
The output table is as follows:
- LOAD: did the script compile/load successfully?
- HDR: was %IRSSI and $VERSION given?
guidance for reviewers, but a lot of perl "critic" is stupid and a
style question only.
+To see the detailed output, run:
+
+ ./_testing/travis/show-failures.zsh yourscript
+
Errors and warnings visible in the Irssi log can serve as further
pointers to both authors and reviewers.
+You can also inspect the raw outputs in the following folder:
+
+ ./Test/yourscript
+
The following keys are recognised in config.yml:
* cpan:
because they hang Travis
* whitelist: - list of scripts that are allowed to fail
* scripts_yaml_keys: - list of keys to copy from irssi header to scripts.dmp
+
+To manually generate the _data/scripts.yaml file, run:
+
+ perl ./_testing/travis/update-scripts-yaml.pl
+
+To download the cached test results, run:
+
+ git fetch origin ci-artefacts:ci-artefacts
+ ln -s ci-artefacts Test
+
my $SWD = "$PWD/../..";
Irssi::command('^window log on');
Irssi::command("script load $CURRENT_SCRIPT");
-Irssi::command('^window log off');
my (@packages) = grep { !/^_/ } keys %Irssi::Script::;
my $tp = $CURRENT_SCRIPT; $tp =~ s/^.*\///; $tp =~ s/\W/_/g; my @tmp;
$info{commands} = \@commands if @commands;
$info{default_package} = $package =~ s/::$//r if $package;
YAML::Tiny::DumpFile("info.yml", [\%info]);
+Irssi::command('^window log off');
if [[ $MARKDOWN_REPORT == 1 ]] { print -n '](Test/'$scriptfile:t:r'/)' }
print -n $T
local pass=0
+
+ # LOAD
if [[ -f "Test/${scriptfile:t:r}/failed.yml" ]] { print -n ' '$failmark' ' } \
- else { print -n ' '$passmark' '; ((++pass)) }; print -n $T
+ elif [[ -f "Test/${scriptfile:t:r}/info.yml" ]] { print -n ' '$passmark' '; ((++pass)) } \
+ else { print -n ' '$skipmark' '; }; print -n $T
+
+ # HDR
if { grep -qs 'Severity: 6' "Test/${scriptfile:t:r}/perlcritic.log" } { print -n ' '$failmark' ' } \
+ elif { grep -qs 'command not found:' "Test/${scriptfile:t:r}/perlcritic.log" } { print -n ' '$skipmark' ' } \
else { print -n ' '$passmark' '; ((++pass)) }; print -n $T
+
+ # CRIT
if { grep -qs 'Code before strictures are enabled\|Two-argument "open" used' "Test/${scriptfile:t:r}/perlcritic.log" } { print -n ' '$failmark' ' } \
+ elif { grep -qs 'command not found:' "Test/${scriptfile:t:r}/perlcritic.log" } { print -n ' '$skipmark' ' } \
else { print -n ' '$passmark' '; ((++pass)) }; print -n $T
+
+ # SCORE
perl -ne '$score += $1 -1 if /Severity: (\d+)/; END { printf "%3d", $score }' "Test/${scriptfile:t:r}/perlcritic.log" 2>/dev/null
print -n ' '$T
if [[ $pass -lt 3 ]] {
#!/bin/zsh
-mkdir -p Test
local base_path="`pwd`"
local test_script="$base_path/_testing/_irssi_test.pl"
for scriptfile ($filelist) {
rm -rf "Test/${scriptfile:t:r}"
- mkdir "Test/${scriptfile:t:r}"
- perlcritic --theme certrule --exclude RequireEndWithOne -2 $scriptfile >"Test/${scriptfile:t:r}/perlcritic.log"
+ mkdir -p "Test/${scriptfile:t:r}"
+ perlcritic --theme certrule --exclude RequireEndWithOne -2 $scriptfile >"Test/${scriptfile:t:r}/perlcritic.log" 2>&1
pushd Test
rm -fr .home
mkdir .home