Skip to content

Commit

Permalink
Merge remote branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
bubaflub committed Dec 3, 2009
2 parents 0aa472c + c16947a commit acdb637
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 30 deletions.
6 changes: 6 additions & 0 deletions CREDITS
Expand Up @@ -22,4 +22,10 @@ E: jonathan@leto.net
W: http://leto.net
U: leto
S: Portland, OR
D: Lead Yak Shaver

N: Geoff Broadwell
U: japhb
E: geoff@broadwell.org
D: implementation of qx() borrowed from Plumage

13 changes: 13 additions & 0 deletions THANKS
@@ -0,0 +1,13 @@
=head1 These people deserve thanks

* Larry Wall, for creating the Perl community and the original TEST script

* The Perl 5 community, for driving the testing world kicking and screaming
into the future via Test::Harness. A few usual suspects are:

Tim Bunce, Andreas Koenig, Schwern, chromatic, Andy Lester and Andy Armstrong

* The Parrot Team, for hacking on the coolest VM around

* Joshua Isom, for writing Getopt::Obj in PIR, which Tapir uses to parse
command line options
13 changes: 5 additions & 8 deletions TODO
Expand Up @@ -10,20 +10,17 @@ Please let me know if you start hacking on one of these or if you have any amazi

We also have the option of using proc_exec from the global parrot config

* Use Getopt to have some nice command line options, like
* Use Getopt::Obj to have some nice command line options, like
--help
--shuffle

* Parse todo/skips/bailout correctly
See _parse_opts() in t/harness.pir for examples

http://cpansearch.perl.org/src/ANDYA/Test-Harness-3.17/lib/TAP/Parser/Grammar.pm

* Exit codes are not being dealt with correctly. This will require some internal redesign.
stream.'is_pass' should take exit codes into account
* Parse skips/bailout correctly

* More detailed statistics in test summary
http://cpansearch.perl.org/src/ANDYA/Test-Harness-3.17/lib/TAP/Parser/Grammar.pm

exit codes if nonzero and test runtime
* More detailed statistics in test summary : test runtime

* Aggregation step in t/harness.pir needs to be abstracted out into Tapir::Harness and tested properly

Expand Down
23 changes: 16 additions & 7 deletions lib/Tapir/Parser.pir
Expand Up @@ -89,19 +89,28 @@ Written and maintained by Jonathan "Duke" Leto C<< jonathan@leto.net >>.
.sub parse_plan :method
.param string plan_line
.local pmc plan_parts
.local int num_expected_tests
# yes, a numeric
.local num num_expected_tests

plan_parts = new 'ResizablePMCArray'
split plan_parts, "..", plan_line
$I0 = length plan_line
if $I0 < 4 goto plan_error

# this needs to take into account TAP Versions
$S0 = substr plan_line, 0, 3
unless $S0 == "1.." goto plan_error

unless plan_parts goto plan_error
plan_parts = new 'FixedPMCArray'
plan_parts = 2

split plan_parts, "..", plan_line
num_expected_tests = plan_parts[1]

$I1 = num_expected_tests
unless $I1 == num_expected_tests goto plan_error
.return (num_expected_tests)
error:
die 'Invalid TAP Stream'
plan_error:
die 'Invalid TAP Plan'
# this indicates an invalid plan
.return (-1)
.end


Expand Down
35 changes: 31 additions & 4 deletions t/01-parse_plan.t
Expand Up @@ -7,14 +7,15 @@
.include 'test_more.pir'
.local pmc tapir, klass

plan(4)
plan(11)

# setup test data
klass = newclass [ 'Tapir'; 'Parser' ]
tapir = klass.'new'()

# run tests
test_parse_plan(tapir)
test_parse_invalid_plan(tapir)
.end


Expand All @@ -31,11 +32,37 @@
num_tests = tapir.'parse_plan'("1..0")
is(num_tests,0,'parse_plan can parse a no-test plan')

# what should happen?
num_tests = tapir.'parse_plan'("-42..0")
is(num_tests,0,'parse_plan can parse an invalid plan')
.end

.sub test_parse_invalid_plan
.param pmc tapir
.local int num_tests

# these are not valid and should cause an "invalid plan" error
num_tests = tapir.'parse_plan'("-42..0")
is(num_tests,-1,'parse_plan indicates an invalid plan for -42..0')

num_tests = tapir.'parse_plan'("-42..42")
is(num_tests,-1,'parse_plan indicates an invalid plan for -42..42')

num_tests = tapir.'parse_plan'("0..1")
is(num_tests,-1,'parse_plan indicates an invalid plan for 0..1')

num_tests = tapir.'parse_plan'("1...69")
is(num_tests,-1,'parse_plan indicates an invalid plan for 1...69')

num_tests = tapir.'parse_plan'("1..")
is(num_tests,-1,'parse_plan indicates an invalid plan for 1..')

num_tests = tapir.'parse_plan'("1.2..69")
is(num_tests,-1,'parse_plan indicates an invalid plan for 1.2..69')

num_tests = tapir.'parse_plan'("This is not even close to a valid plan!")
is(num_tests,-1,'parse_plan indicates an invalid plan for junk')

num_tests = tapir.'parse_plan'("....2")
is(num_tests,-1,'parse_plan indicates an invalid plan for ....2')
.end

# Local Variables:
# mode: pir
Expand Down
34 changes: 23 additions & 11 deletions t/harness.pir
Expand Up @@ -8,25 +8,31 @@
exit 0
.end

.sub main :main
.sub _parse_opts
.param pmc argv

load_bytecode "Getopt/Obj.pbc"
$S0 = shift argv # get rid of harness.pir in the args list

getopt:
# parse command line args
.local pmc getopts, opts
load_bytecode "Getopt/Obj.pbc"
getopts = new "Getopt::Obj"
getopts."notOptStop"(1)
push getopts, "exec|e:s"
push getopts, "version"
opts = getopts."get_options"(argv)
.return(opts)
.end

.sub main :main
.param pmc argv
.local pmc opts
.local string exec

$S0 = shift argv # get rid of harness.pir in the args list

# parse command line args
opts = _parse_opts(argv)
exec = opts["exec"]
$S0 = opts["version"]
unless $S0 goto make_parser
$S1 = opts["version"]

unless $S1 goto make_parser
version()

make_parser:
Expand Down Expand Up @@ -89,7 +95,12 @@
$S1 = stream.'total'()
$S0 = "/" . $S1
print $S0
say " tests"
print " tests"
$I1 = stream.'get_exit_code'()
unless $I1 goto redo
print ", exit code = "
say $I1

redo:
inc i
goto loop
Expand Down Expand Up @@ -139,7 +150,8 @@
skip_exit_status:

# hack
$P0 = new 'ResizablePMCArray'
$P0 = new 'FixedPMCArray'
$P0 = 2
$P0[0] = output
$P0[1] = exit_status
.return ($P0)
Expand Down

0 comments on commit acdb637

Please sign in to comment.