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 2, 2009
2 parents 841098a + 1c4c873 commit bd7ee02
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 25 deletions.
5 changes: 5 additions & 0 deletions TODO
Expand Up @@ -5,8 +5,13 @@ Please let me know if you start hacking on one of these or if you have any amazi
* Be able to run any test file, not just PIR tests

Run /bin/sh -c or ./file, and then default to parrot if neither work ?

Turns out /bin/sh -c foo.t means foo.t must be executable.

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

* Use Getopt to have some nice command line options, like --help and --version

* Parse todo/skips/bailout correctly

http://cpansearch.perl.org/src/ANDYA/Test-Harness-3.17/lib/TAP/Parser/Grammar.pm
Expand Down
44 changes: 21 additions & 23 deletions lib/Tapir/Parser.pir
Expand Up @@ -10,22 +10,22 @@ Written and maintained by Jonathan "Duke" Leto C<< jonathan@leto.net >>.

.sub parse_tapstream :method
.param string tap
.local string curr_line, delim
.local string curr_line
.local pmc plan, pass, fail, skip, todo
.local int i, curr_test
.local int i, curr_test, reported_test
.local pmc tap_lines, parts, klass, stream
i = 0
fail = new 'Integer'
skip = new 'Integer'
todo = new 'Integer'
pass = new 'Integer'
plan = new 'Integer'


i = 0
curr_test = 1
fail = new 'Integer'
skip = new 'Integer'
todo = new 'Integer'
pass = new 'Integer'
plan = new 'Integer'
tap_lines = new 'ResizablePMCArray'
parts = new 'ResizablePMCArray'
delim = "\n"
split tap_lines, delim, tap

split tap_lines, "\n", tap
$I0 = tap_lines

.local string plan_line
Expand All @@ -36,23 +36,24 @@ Written and maintained by Jonathan "Duke" Leto C<< jonathan@leto.net >>.
loop:
if i >= $I0 goto done
curr_line = tap_lines[i]
unless curr_line goto done
delim = "ok "

split parts, delim, curr_line
split parts, "ok ", curr_line

prefix = parts[0]
curr_test = parts[1]
prefix = parts[0]
reported_test = parts[1]

if prefix == 'not ' goto fail_or_todo

if curr_test == i goto got_pass
if reported_test == curr_test goto got_pass

# it was an unrecognized line
inc i
goto loop
got_pass:
# check curr_test for comments
inc pass
inc i
inc curr_test
goto loop
fail_or_todo:
split parts, "# ", curr_line
Expand All @@ -62,17 +63,16 @@ Written and maintained by Jonathan "Duke" Leto C<< jonathan@leto.net >>.
if $S0 != "todo" goto failz
# it is a TODO test!
inc todo
inc curr_test
inc i
goto loop
failz:
inc fail
inc curr_test
inc i
goto loop

done:
# XXX hack
dec pass # passes get mis-counted by 1

stream = new [ 'Tapir'; 'Stream' ]
stream.'set_pass'(pass)
stream.'set_fail'(fail)
Expand All @@ -88,11 +88,9 @@ Written and maintained by Jonathan "Duke" Leto C<< jonathan@leto.net >>.
.param string plan_line
.local pmc plan_parts
.local int num_expected_tests
.local string delim

delim = ".."
plan_parts = new 'ResizablePMCArray'
split plan_parts, delim, plan_line
split plan_parts, "..", plan_line

unless plan_parts goto plan_error
num_expected_tests = plan_parts[1]
Expand Down
Empty file modified t/00-sanity.t 100644 → 100755
Empty file.
Empty file modified t/01-parse_plan.t 100644 → 100755
Empty file.
Empty file modified t/02-parse_tapstream.t 100644 → 100755
Empty file.
63 changes: 62 additions & 1 deletion t/03-parse_tapstream_error.t 100644 → 100755
Expand Up @@ -7,15 +7,76 @@
.include 'test_more.pir'
.local pmc tapir, klass

plan(12)
plan(19)

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

test_parse_death(tapir)
test_parse_death_with_passing_tests(tapir)
test_plumage_sanity(tapir)
.end

.sub test_plumage_sanity
.param pmc tapir
.local string tap_error
.local pmc stream
tap_error = <<"TAP"
1..18
invalidjunkdoesnotexist
ok 1 - do_run()ing invalidjunk returns false
./plumage asdfversion
I don't know how to 'asdfversion'!
ok 2 - plumage returns failure for invalid commands
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8 - no args give usage
ok 9 - no args give usage
ok 10 - plumage fetch no args
ok 11
ok 12
./plumage version
This is Parrot Plumage, version 0.
Copyright (C) 2009, Parrot Foundation.
This code is distributed under the terms of the Artistic License 2.0.
For more details, see the full text of the license in the LICENSE file
included in the Parrot Plumage source tree.
ok 13 - plumage version returns success
ok 14 - plumage version knows its name
ok 15 - version mentions Parrot Foundation
ok 16 - version mentions Artistic License
ok 17 - info rakudo
ok 18 - info rakudo
.end
TAP
stream = tapir.'parse_tapstream'(tap_error)
$I0 = stream.'get_plan'()
is($I0,18,"plan is correct")
$I0 = stream.'is_pass'()
is($I0,1,"parse_tapstream passes Plumage's sanity test")
$I0 = stream.'get_pass'()
is($I0,18,"parse_tapstream gets 18 tests")
$I0 = stream.'get_todo'()
is($I0,0,"parse_tapstream gets no todo tests")
$I0 = stream.'get_skip'()
is($I0,0,"parse_tapstream gets no skip tests")
$I0 = stream.'get_fail'()
is($I0,0,"parse_tapstream gets no fails")
$I0 = stream.'total'()
is($I0,18,"parse_tapstream gets 18 tests in total")
.end
.sub test_parse_death
Expand Down
23 changes: 22 additions & 1 deletion t/harness.pir
Expand Up @@ -5,10 +5,22 @@

.sub main :main
.param pmc argv

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

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

.local string exec
exec = opts["exec"]

.local pmc tapir, klass
klass = newclass [ 'Tapir'; 'Parser' ]
tapir = klass.'new'()
Expand All @@ -30,8 +42,17 @@
unless file goto done
inc total_files
print file
# these should be normalized to make the output format 'pretty'
print ".........."
output = qx('parrot',file)

# we assume the test is PIR unless given an --exec flag
# how to do proper shebang-line detection?
.local string exec_cmd
exec_cmd = 'parrot'
unless exec goto run_cmd
exec_cmd = exec
run_cmd:
output = qx(exec,file)
stream = tapir.'parse_tapstream'(output)
success = stream.'is_pass'()
unless success goto fail
Expand Down

0 comments on commit bd7ee02

Please sign in to comment.