Skip to content

Commit

Permalink
org2bbd.t: increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
eserte committed Aug 15, 2024
1 parent b21094c commit 97e2e6b
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions t/org2bbd.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,27 @@ SKIP: {
}

SKIP: {
skip "Need IPC::Run for further testing", 3
skip "Need IPC::Run for further testing", 6
if !eval { require IPC::Run; 1};

open my $ofh, '>:encoding(utf-8)', "$tmpdir/test.org" or die $!;
print $ofh <<EOF;
{
open my $ofh, '>:encoding(utf-8)', "$tmpdir/test.org" or die $!;
print $ofh <<EOF;
Ignored location without headline: [[geo:52.50109,13.45051?z=19]]
* TODO My Location
Here is my location: [[geo:52.50109,13.45051?z=19][OpenStreetMap]]
[[geo:52.50109,13.45051?z=19]]
[[geo:52.50109,13.45051]]
[[geo:-22.97291,-43.18420?z=17]]
* TODO Without Location
* DONE Location but already resolved
Here is my location: [[geo:52.50109,13.45051?z=19][Wrong]]
EOF
close $ofh or die $!;
close $ofh or die $!;

ok IPC::Run::run([$^X, $org2bbd, "$tmpdir/test.org"], '>', \my $bbd_out, '2>', \my $stderr), 'org2bbd runs ok';
unlike $stderr, qr{No locations found in}, 'no unexpected stderr';
$bbd_out =~ s{Converted from .* at .*}{Converted from __FILE__ at __TIME__};
eq_or_diff $bbd_out, <<"EOF", 'bbd as expected';
ok IPC::Run::run([$^X, $org2bbd, "$tmpdir/test.org"], '>', \my $bbd_out, '2>', \my $stderr), 'org2bbd runs ok';
unlike $stderr, qr{No locations found in}, 'no unexpected stderr';
$bbd_out =~ s{Converted from .* at .*}{Converted from __FILE__ at __TIME__};
eq_or_diff $bbd_out, <<"EOF", 'bbd as expected';
#: encoding: utf-8
#: map: polar
#:
Expand All @@ -54,6 +56,21 @@ OpenStreetMap\tX 13.45051,52.50109
My Location\tX 13.45051,52.50109
My Location\tX -43.18420,-22.97291
EOF
}

{
open my $ofh, '>:encoding(utf-8)', "$tmpdir/test-no-loc.org" or die $!;
print $ofh <<EOF;
Ignored location without headline: [[geo:52.50109,13.45051?z=19]]
* DONE Location but already resolved
Here is my location: [[geo:52.50109,13.45051?z=19][Wrong]]
EOF
close $ofh or die $!;

ok !IPC::Run::run([$^X, $org2bbd, "$tmpdir/test-no-loc.org"], '>', \my $bbd_out, '2>', \my $stderr), 'org2bbd expected to fail';
like $stderr, qr{No locations found in}, 'expected stderr';
is $bbd_out, '', 'no bbd output';
}
}

__END__

0 comments on commit 97e2e6b

Please sign in to comment.