Skip to content
Browse files

Make a fakecutable and PBC's which can be more easily dropped into ex…

…ternal projects # chromatic++

We now generate PBC for all PIR files and then load_bytecode() those instead of include()'ing PIR.
Thanks to chromatic++ for showing me the ":load :anon" black magic trick.
  • Loading branch information...
1 parent 7ae5c81 commit b2e6ebda3a907b481254645d7100412988331c69 @leto committed
Showing with 39 additions and 24 deletions.
  1. +12 −1 Makefile
  2. +10 −11 README
  3. +6 −2 lib/Tapir/Stream.pir
  4. +2 −2 t/00-sanity.t
  5. +2 −2 t/01-parse_plan.t
  6. +2 −2 t/02-parse_tapstream.t
  7. +2 −2 t/03-parse_tapstream_error.t
  8. +3 −2 t/harness.pir
View
13 Makefile
@@ -1,3 +1,14 @@
-pbc:
+all:
parrot -o t/harness.pbc t/harness.pir
+ parrot -o lib/Tapir/Parser.pbc lib/Tapir/Parser.pir
+ parrot -o lib/Tapir/Stream.pbc lib/Tapir/Stream.pir
+ pbc_merge -o tapir.pbc t/harness.pbc lib/Tapir/Parser.pbc lib/Tapir/Stream.pbc
+ pbc_to_exe tapir.pbc
+
+clean:
+ rm t/harness.pbc
+ rm lib/Tapir/*.pbc
+
+test:
+ ./tapir t/*.t
View
21 README
@@ -1,23 +1,22 @@
-
Tapir is a PIR-based TAP (Test Anything Protocol) Harness
-It eats test output and tells humans if the test suite passed, and if not,
+It eats test output (i.e. is a TAP consumer) and tells humans if the test suite passed, and if not,
which kind of pretty colors of smoke came out.
The only requirement for Tapir is Parrot 1.8.0 or higher.
-To run the Tapir test suite with Tapir:
+To run the Tapir test suite with Tapir, first you must generate the PBC files with
- $ parrot t/harness.pir t/*.t
+ $ make
-Also, you can always use parrot or prove to run Tapir tests individually:
+The dependency on 'make' will disappear once we move to a pure-Parrot build (setup.pir)
- $ parrot t/01-parse_plan.t
+Now to run the test suite:
-You should see something like:
+ $ ./tapir t/*.t
-1..3
-ok 1 - parse_plan can parse a simple plan
-ok 2 - parse_plan can parse a single test plan
-ok 3 - parse_plan can parse a no-test plan
+Also, you can always use parrot or prove to run Tapir tests individually:
+
+ $ parrot t/01-parse_plan.t
+ $ prove -v t/01-parse_plan.t
View
8 lib/Tapir/Stream.pir
@@ -2,8 +2,12 @@
.namespace [ 'Tapir'; 'Stream' ]
-.sub _initialize :load :init
- #say "Initializing!"
+# 06:28:33 <@chromatic> :load executes only when loading from bytecode.
+# 06:28:48 <@chromatic> :init executes right after compilation.
+# 06:29:17 <@chromatic> The effects of :init should be frozen into PBC.
+# 06:37:26 <@chromatic> :anon :init trips the "Do something special with bytecode" magic.
+
+.sub _initialize :load :anon
.local pmc klass
klass = newclass [ 'Tapir'; 'Stream' ]
View
4 t/00-sanity.t
@@ -1,11 +1,11 @@
#!/usr/bin/env parrot
-.include 'lib/Tapir/Parser.pir'
-.include 'lib/Tapir/Stream.pir'
.sub main :main
.include 'test_more.pir'
.local pmc tapir, klass
+ load_bytecode 'lib/Tapir/Parser.pir'
+ load_bytecode 'lib/Tapir/Stream.pir'
plan(2)
View
4 t/01-parse_plan.t
@@ -1,11 +1,11 @@
#!/usr/bin/env parrot
-.include 'lib/Tapir/Parser.pir'
-.include 'lib/Tapir/Stream.pir'
.sub main :main
.include 'test_more.pir'
.local pmc tapir, klass
+ load_bytecode 'lib/Tapir/Parser.pbc'
+ load_bytecode 'lib/Tapir/Stream.pbc'
plan(11)
View
4 t/02-parse_tapstream.t
@@ -1,11 +1,11 @@
#!/usr/bin/env parrot
-.include 'lib/Tapir/Parser.pir'
-.include 'lib/Tapir/Stream.pir'
.sub main :main
.include 'test_more.pir'
.local pmc tapir, klass
+ load_bytecode 'lib/Tapir/Parser.pbc'
+ load_bytecode 'lib/Tapir/Stream.pbc'
plan(59)
View
4 t/03-parse_tapstream_error.t
@@ -1,11 +1,11 @@
#!/usr/bin/env parrot
-.include 'lib/Tapir/Parser.pir'
-.include 'lib/Tapir/Stream.pir'
.sub main :main
.include 'test_more.pir'
.local pmc tapir, klass
+ load_bytecode 'lib/Tapir/Stream.pir'
+ load_bytecode 'lib/Tapir/Parser.pir'
plan(28)
View
5 t/harness.pir
@@ -1,7 +1,5 @@
# Copyright (C) 2009, Jonathan "Duke" Leto <jonathan@leto.net>
-.include 'lib/Tapir/Parser.pir'
-.include 'lib/Tapir/Stream.pir'
.sub version
say "Tapir version 0.01"
@@ -58,6 +56,9 @@
.local pmc opts
.local string exec
+ load_bytecode 'lib/Tapir/Parser.pbc'
+ load_bytecode 'lib/Tapir/Stream.pbc'
+
$S0 = shift argv # get rid of harness.pir in the args list
# parse command line args

0 comments on commit b2e6ebd

Please sign in to comment.
Something went wrong with that request. Please try again.