-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
BEGIN %*ENV<RAKU_TEST_DIE_ON_FAIL> = 1; | ||
use Test; | ||
|
||
plan 6; | ||
|
||
my $dir = $*PROGRAM.parent; | ||
my $dira = $dir.absolute ~ $*SPEC.dir-sep; | ||
my $rel := $dir.relative ~ $*SPEC.dir-sep; | ||
my $dot = $?FILE.IO.parent.parent; | ||
my $rak := $dot.add("bin").add("rak").relative; | ||
|
||
# using paths from here on out | ||
$dot .= relative; | ||
$dir .= absolute; | ||
|
||
my sub query-ok( | ||
*@query, # the actual parameters | ||
:$ok is copy, # the expected result | ||
:$head = 1, # whether to do the --only-first test with this number | ||
:$add-human = True, # add human specification | ||
) is test-assertion { | ||
my @args = $*EXECUTABLE.absolute, "-I$dot", $rak, @query.Slip; | ||
@args.push: "--human" if $add-human; | ||
$ok .= chomp; | ||
|
||
# Logic to run the query | ||
my sub run-query() { | ||
my $proc := run @args, :out, :err; | ||
my $key = "huh?"; | ||
|
||
is $proc.err.slurp(:close), "", "is '@query[]' STDERR clean?"; | ||
$proc.out.lines.map(*.subst($rel, :g)).join("\n") | ||
} | ||
|
||
# Base query | ||
is run-query, $ok, "is '@query[]' result ok?"; | ||
} | ||
|
||
query-ok '--pdf-info', Q/*.<Author>/, 'pdf', ok => qq:to/OK/; | ||
pdf/basic.pdf | ||
Philip Hutchison | ||
OK | ||
|
||
query-ok <--pdf-per-line varius pdf --/highlight>, ok => qq:to/OK/; | ||
pdf/basic.pdf | ||
8:erat dolor, blandit in, rutrum quis, semper pulvinar, enim. Nullam varius congue risus. | ||
24:varius. Donec lacinia, neque a luctus aliquet, pede massa imperdiet ante, at varius lorem | ||
33:penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus varius. Ut sit | ||
34:amet diam suscipit mauris ornare aliquam. Sed varius. Duis arcu. Etiam tristique massa | ||
OK | ||
|
||
query-ok <--pdf-per-file /eget.pharetra/ pdf --matches-only>, ok => qq:to/OK/; | ||
pdf/basic.pdf | ||
eget | ||
pharetra | ||
OK | ||
|
||
# vim: expandtab shiftwidth=4 |