### ----------------------------------------------------
### -- Pod::From::Cache
### -- Licenses: Artistic-2.0
### -- Authors: Richard Hainsworth, aka finanalyst
### -- File: xt/40-compile-error.rakutest
### ----------------------------------------------------
use Test;

use File::Directory::Tree;
use Pod::From::Cache;

constant CACHE = 'xt/cache';
constant DOC = 'xt/tmp';

my Pod::From::Cache $m;

plan 1;
rmtree CACHE;
if DOC.IO.d { empty-directory(DOC) }
else { mktree DOC }

(DOC ~ '/a-pod-file.pod6').IO.spurt(q:to/POD-CONTENT/);
    =pod A test file
    =TITLE This is a title

    Some text

    =end pod
    POD-CONTENT


throws-like { $m .= new(:doc-source(DOC), :cache-path(CACHE)) },
        X::Pod::From::Cache::BadSource, 'Caught compile error', message => / 'File source' .+ 'a-pod-file' .+ 'has error:' /;

diag 'Prepare for xt/45-compile-ok';

(DOC ~ '/a-pod-file.pod6').IO.spurt(q:to/POD-CONTENT/);
    =begin pod

    =TITLE This is a title

    Some text

    =end pod
    POD-CONTENT

done-testing;


