shlist

share and manage lists between multiple people
Log | Files | Refs

commit 87f6c4d29d1aa332cc6797c1db01406c47d745ba
parent f60cfdb5914487b55741a5cb4184da36e0c81c38
Author: Kyle Milz <kyle@0x30.net>
Date:   Sat, 27 Feb 2016 12:53:19 -0700

server: add test coverage support to test.pl

Diffstat:
Mserver/SL.pm | 7+++++--
Mserver/test.pl | 18+++++++++++++++---
2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/server/SL.pm b/server/SL.pm @@ -9,8 +9,11 @@ sub new { my $self = {}; bless ($self, $class); - # perl -MDevel::Cover sl -p $PORT -t & - my $pid = open2(\*CHLD_OUT, undef, "perl -T sl -t -p 4729"); + my $perl_args = ''; + if ($ARGV[0] == 1) { + $perl_args = '-MDevel::Cover'; + } + my $pid = open2(\*CHLD_OUT, undef, "perl $perl_args -T sl -t -p 4729"); $self->{pid} = $pid; $self->{CHLD_OUT} = \*CHLD_OUT; diff --git a/server/test.pl b/server/test.pl @@ -1,11 +1,23 @@ +#!/usr/bin/perl use strict; use warnings; use TAP::Harness; use Getopt::Std; -my %args; -getopt("c", \%args); +my %opts; +# -c : enable test coverage +getopts('c', \%opts); -my $harness = TAP::Harness->new({ color => 1 }); +my $harness = TAP::Harness->new({ + color => 1, + test_args => [ $opts{c} ] +}); + +# Run tests $harness->runtests(glob("t/*.t")); + +if ($opts{c}) { + print "Coverage build, running 'cover'\n"; + system("cover"); +}