Skip to content

Commit 7083afe

Browse files
committed
CI test before release
1 parent f652db4 commit 7083afe

14 files changed

+250
-105
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.precomp/
22
/Pod-TreeWalker-*
3+
*.rakucov

Changes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Revision history for Pod-TreeWalker
99
- Added three-OS testing.
1010
- Renamed 't/lib/TestListener.pm6' to 't/lib/TestListener.rakumod'.
1111
- Updated copyright date.
12-
- Make the module title bold in the SYNOPSIS.
1312

1413
0.0.4 2022-05-24T20:43:16+02:00
1514
- First release in the zef ecosystem.

META6.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"resources": [
1919
],
2020
"source-url": "https://github.com/raku-community-modules/Pod-TreeWalker.git",
21-
"tags": [
21+
"tags": [ "POD","TREE"
2222
],
2323
"test-depends": [
2424
],

dist.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ source-url = https://github.com/raku-community-modules/Pod-TreeWalker.git
44

55
[ReadmeFromPod]
66
; enabled = false
7-
filename = lib/Pod/TreeWalker.rakumod
7+
filename = doc/Pod-TreeWalker.rakudoc
88

99
[UploadToZef]
1010

doc/Pod-TreeWalker.rakudoc

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
=begin pod
2+
3+
=head1 NAME
4+
5+
Pod::TreeWalker - Walk a Pod tree and generate an event for each node
6+
7+
=head1 SYNOPSIS
8+
9+
=begin code :lang<raku>
10+
11+
use Pod::TreeWalker;
12+
13+
my $to-html = Pod::To::HTML.new(...);
14+
Pod::TreeWalker.new( :listener($to-html) ).walk-pod($=pod);
15+
16+
=end code
17+
18+
=head1 DESCRIPTION
19+
20+
This class provides an API for walking a pod tree (as provided by
21+
C<$=pod>). Each node in the tree will trigger one or more events. These events
22+
cause methods to be called on a listener object that you provide. This lets
23+
you do something with a Pod document without having to know much about the
24+
underlying tree structure of Pod.
25+
26+
=head1 METHODS
27+
28+
=head2 new
29+
30+
=begin code :lang<raku>
31+
32+
my $walker = Pod::TreeWalker.new( :listener($object) )
33+
34+
=end code
35+
36+
The constructor requires a single named argument C<:listener>. This object must
37+
implement the L<Pod::TreeWalker::Listener|./t/lib/TestListener.rakumod> API
38+
as demonstrated in file './t/lib/TestListener.rakumod'.
39+
40+
=head2 walk-pod
41+
42+
=begin code :lang<raku>
43+
44+
$walker.walk-pod($pod);
45+
46+
=end code
47+
48+
This method walks through a pod tree starting with the top node in
49+
C<$pod>. You can provide either an array of pod nodes (as stored in C<$=pod>)
50+
or a single top-level node (such as C<$=pod[0]>).
51+
52+
=head2 text-content-of
53+
54+
=begin code :lang<raku>
55+
56+
say $walker.text-contents-of($pod)
57+
58+
=end code
59+
60+
Given a C<Pod::Block> of any sort, this method recursively descends the
61+
blocks contents and returns the concatenation of all the plain text that
62+
it finds.
63+
64+
=head1 AUTHOR
65+
66+
Dave Rolsky
67+
68+
=head1 COPYRIGHT AND LICENSE
69+
70+
Copyright 2015 - 2018 Dave Rolsky
71+
72+
Copyright 2019 - 2025 Raku Community
73+
74+
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.
75+
76+
=end pod
77+
78+
# vim: expandtab shiftwidth=4

lib/Pod/TreeWalker.rakumod

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use Pod::TreeWalker::Listener;
22

33
unit class Pod::TreeWalker;
4-
has Pod::TreeWalker::Listener $!listener is built;
4+
has Pod::TreeWalker::Listener $.listener is required;
55
has Int:D $!list-level = 0;
66
has Int:D $!list-start-depth = 0;
77
has Bool:D $!last-list-was-numbered = False;
@@ -145,81 +145,4 @@ my sub d(Cool:D $d --> Nil) {
145145
}
146146
}
147147

148-
=begin pod
149-
150-
=head1 NAME
151-
152-
B<Pod::TreeWalker> - Walk a Pod tree and generate an event for each node
153-
154-
=head1 SYNOPSIS
155-
156-
=begin code :lang<raku>
157-
158-
use Pod::TreeWalker;
159-
160-
my $to-html = Pod::To::HTML.new(...);
161-
Pod::TreeWalker.new( :listener($to-html) ).walk-pod($=pod);
162-
163-
=end code
164-
165-
=head1 DESCRIPTION
166-
167-
This class provides an API for walking a pod tree (as provided by
168-
C<$=pod>). Each node in the tree will trigger one or more events. These events
169-
cause methods to be called on a listener object that you provide. This lets
170-
you do something with a Pod document without having to know much about the
171-
underlying tree structure of Pod.
172-
173-
=head1 METHODS
174-
175-
=head2 new
176-
177-
=begin code :lang<raku>
178-
179-
my $walker = Pod::TreeWalker.new( :listener($object) )
180-
181-
=end code
182-
183-
The constructor requires a single named argument C<:listener>. This object must
184-
implement the L<Pod::TreeWalker::Listener|./t/lib/TestListener.rakumod> API
185-
as demonstrated in file './t/lib/TestListener.rakumod'.
186-
187-
=head2 walk-pod
188-
189-
=begin code :lang<raku>
190-
191-
$walker.walk-pod($pod);
192-
193-
=end code
194-
195-
This method walks through a pod tree starting with the top node in
196-
C<$pod>. You can provide either an array of pod nodes (as stored in C<$=pod>)
197-
or a single top-level node (such as C<$=pod[0]>).
198-
199-
=head2 text-content-of
200-
201-
=begin code :lang<raku>
202-
203-
say $walker.text-contents-of($pod)
204-
205-
=end code
206-
207-
Given a C<Pod::Block> of any sort, this method recursively descends the
208-
blocks contents and returns the concatenation of all the plain text that
209-
it finds.
210-
211-
=head1 AUTHOR
212-
213-
Dave Rolsky
214-
215-
=head1 COPYRIGHT AND LICENSE
216-
217-
Copyright 2015 - 2018 Dave Rolsky
218-
219-
Copyright 2019 - 2025 Raku Community
220-
221-
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.
222-
223-
=end pod
224-
225148
# vim: expandtab shiftwidth=4

run-tests

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
unit sub MAIN(
2+
:a($author),
3+
:i($install),
4+
:$rmd,
5+
:$disable-spesh,
6+
:$disable-spesh-inline,
7+
:$disable-JIT,
8+
:$enable-spesh-nodelay,
9+
:$enable-spesh-blocking,
10+
:$enable-spesh-log,
11+
);
12+
13+
say run(<raku --version>, :out).out.slurp.chomp;
14+
say "Running on $*DISTRO.gist().\n";
15+
16+
if $rmd {
17+
%*ENV<RAKUDO_MODULE_DEBUG> := 1;
18+
say "RAKUDO_MODULE_DEBUG=1";
19+
}
20+
21+
if $disable-spesh {
22+
%*ENV<MVM_SPESH_DISABLE> := 1;
23+
say "MVM_SPESH_DISABLE=1";
24+
}
25+
26+
if $disable-spesh-inline {
27+
%*ENV<MVM_SPESH_INLINE_DISABLE> := 1;
28+
say "MVM_SPESH_INLINE_DISABLE=1";
29+
}
30+
31+
if $disable-JIT {
32+
%*ENV<MVM_JIT_DISABLE> := 1;
33+
say "MVM_JIT_DISABLE=1";
34+
}
35+
36+
if $enable-spesh-nodelay {
37+
%*ENV<MVM_SPESH_NODELAY> := 1;
38+
say "MVM_SPESH_NODELAY=1";
39+
}
40+
41+
if $enable-spesh-blocking {
42+
%*ENV<MVM_SPESH_BLOCKING> := 1;
43+
say "MVM_SPESH_BLOCKING=1";
44+
}
45+
46+
my $spesh-log;
47+
if $enable-spesh-log {
48+
$spesh-log = (
49+
$enable-spesh-log ~~ Bool ?? "spesh-log" !! $enable-spesh-log
50+
).IO;
51+
%*ENV<MVM_SPESH_LOG> := $spesh-log.absolute;
52+
say "MVM_SPESH_LOG=$spesh-log.relative()";
53+
}
54+
55+
say ""
56+
if $rmd
57+
|| $disable-spesh
58+
|| $disable-spesh-inline
59+
|| $disable-JIT
60+
|| $enable-spesh-nodelay
61+
|| $enable-spesh-blocking
62+
|| $enable-spesh-log;
63+
64+
say "Testing {
65+
(try "dist.ini".IO.lines.head.substr(7)) // "..."
66+
}{
67+
" including author tests" if $author
68+
}";
69+
70+
my @failed;
71+
my $done = 0;
72+
73+
sub process($proc, $filename) {
74+
if $proc {
75+
$proc.out.slurp;
76+
$spesh-log.unlink if $spesh-log;
77+
}
78+
else {
79+
@failed.push($filename);
80+
if $proc.out.slurp -> $stdout {
81+
my @lines = $stdout.lines;
82+
with @lines.first(
83+
*.starts-with(" from gen/moar/stage2"),:k)
84+
-> $index {
85+
say @lines[^$index].join("\n");
86+
}
87+
else {
88+
say $stdout;
89+
}
90+
}
91+
else {
92+
say "No output received, exit-code $proc.exitcode() ($proc.signal()):\n$proc.os-error()";
93+
}
94+
95+
if $spesh-log {
96+
say "\nSpesh log requested, showing last 20000 lines:";
97+
say $spesh-log.lines(:!chomp).tail(20000).join;
98+
$spesh-log.unlink;
99+
}
100+
}
101+
}
102+
103+
sub install() {
104+
my $zef := $*DISTRO.is-win ?? 'zef.bat' !! 'zef';
105+
my $proc := run $zef, "install", ".", "--verbose", "--/test", :out,:err,:merge;
106+
process($proc, "*installation*");
107+
}
108+
109+
sub test-dir($dir) {
110+
for $dir.IO.dir(:test(*.ends-with: '.t' | '.rakutest')).map(*.Str).sort {
111+
say "=== $_";
112+
my $proc := run "raku", "--ll-exception", "-I.", $_, :out,:err,:merge;
113+
process($proc, $_);
114+
$done++;
115+
}
116+
}
117+
118+
test-dir("t");
119+
test-dir($_) for dir("t", :test({ !.starts-with(".") && "t/$_".IO.d})).map(*.Str).sort;
120+
test-dir("xt") if $author && "xt".IO.e;
121+
if $install {
122+
install;
123+
++$done;
124+
}
125+
126+
if @failed {
127+
say "\nFAILED: {+@failed} of $done:";
128+
say " $_" for @failed;
129+
exit +@failed;
130+
}
131+
132+
say "\nALL {"$done " if $done > 1}OK";
133+
134+
# vim: expandtab shiftwidth=4

t/basic.rakutest

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use v6;
21
use Test;
3-
use lib 'lib', 't/lib';;
42
use Pod::TreeWalker;
3+
use lib $*PROGRAM.sibling('lib');
54
use TestListener;
65

6+
plan 9;
7+
78
my $pod_i = 0;
89

910
=begin pod
@@ -241,4 +242,4 @@ subtest {
241242
is-deeply $l.events, @expect, 'got expected events';
242243
}, '=defn block';
243244

244-
done-testing;
245+
# vim: expandtab shiftwidth=4

t/declarators.rakutest

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use v6;
21
use Test;
3-
use lib 'lib', 't/lib';;
42
use Pod::TreeWalker;
3+
use lib $*PROGRAM.sibling('lib');
54
use TestListener;
65

6+
plan 1;
7+
78
my $pod_i = 0;
89

910
#| before class
@@ -36,4 +37,4 @@ subtest {
3637
is-deeply $l.events, @expect, 'got expected events for attribute declarator';
3738
}, 'declarators';
3839

39-
done-testing;
40+
# vim: expandtab shiftwidth=4

t/document.rakutest

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use v6;
21
use Test;
3-
use lib 'lib', 't/lib';;
42
use Pod::TreeWalker;
3+
use lib $*PROGRAM.sibling('lib');
54
use TestListener;
65

6+
plan 1;
7+
78
=begin pod
89

910
=NAME Some::Module
@@ -61,10 +62,10 @@ my @expect = (
6162

6263
is-deeply $l.events, @expect, 'got expected events for pod document';
6364

64-
done-testing;
65-
6665
=begin pod
6766

6867
=AUTHOR Dave Rolsky <[email protected]>
6968

7069
=end pod
70+
71+
# vim: expandtab shiftwidth=4

0 commit comments

Comments
 (0)