1# -*- perl -*-
2
3BEGIN {
4    use File::Spec::Functions ':ALL';
5    @INC = map { rel2abs($_) }
6             (qw| ./lib ./t/lib ../../lib |);
7}
8
9use strict;
10use warnings;
11use Test::More tests => 3;
12use Testing qw( setup_testing_dir xconvert );
13use Cwd;
14
15my $debug = 0;
16my $startdir = cwd();
17END { chdir($startdir) or die("Cannot change back to $startdir: $!"); }
18my ($expect_raw, $args);
19{ local $/; $expect_raw = <DATA>; }
20
21my $tdir = setup_testing_dir( {
22    debug       => $debug,
23} );
24
25my $cwd = cwd();
26my ($v, $d) = splitpath($cwd, 1);
27my @dirs = splitdir($d);
28shift @dirs if $dirs[0] eq '';
29my $relcwd = join '/', @dirs;
30
31$args = {
32    podstub => "htmldir3",
33    description => "test --htmldir and --htmlroot 3c: as expected pod file not yet locatable either under podroot or in cache: GH 12271",
34    expect => $expect_raw,
35    expect_fail => 1,
36    p2h => {
37        podpath    => catdir($relcwd, 't'),
38        podroot    => catpath($v, '/', ''),
39        htmldir    => 't',
40        outfile    => 't/htmldir3.html',
41        quiet      => 1,
42    },
43    debug => $debug,
44};
45$args->{core} = 1 if $ENV{PERL_CORE};
46xconvert($args);
47
48$args = {
49    podstub => "htmldir3",
50    description => "test --htmldir and --htmlroot 3a",
51    expect => $expect_raw,
52    p2h => {
53        podpath    => $relcwd,
54        podroot    => catpath($v, '/', ''),
55        htmldir    => catdir($cwd, 't', ''), # test removal trailing slash,
56        quiet      => 1,
57    },
58    debug => $debug,
59};
60xconvert($args);
61
62$args = {
63    podstub => "htmldir3",
64    description => "test --htmldir and --htmlroot 3b: as expected pod file not yet locatable either under podroot or in cache: GH 12271",
65    expect => $expect_raw,
66    expect_fail => 1,
67    p2h => {
68        podpath    => catdir($relcwd, 't'),
69        podroot    => catpath($v, '/', ''),
70        htmldir    => 't',
71        outfile    => 't/htmldir3.html',
72        quiet      => 1,
73    },
74    debug => $debug,
75};
76xconvert($args);
77
78__DATA__
79<?xml version="1.0" ?>
80<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
81<html xmlns="http://www.w3.org/1999/xhtml">
82<head>
83<title>htmldir - Test --htmldir feature</title>
84<meta http-equiv="content-type" content="text/html; charset=utf-8" />
85<link rev="made" href="mailto:[PERLADMIN]" />
86</head>
87
88<body>
89
90
91
92<ul id="index">
93  <li><a href="#NAME">NAME</a></li>
94  <li><a href="#LINKS">LINKS</a></li>
95</ul>
96
97<h1 id="NAME">NAME</h1>
98
99<p>htmldir - Test --htmldir feature</p>
100
101<h1 id="LINKS">LINKS</h1>
102
103<p>Normal text, a <a>link</a> to nowhere,</p>
104
105<p>a link to <a href="[RELCURRENTWORKINGDIRECTORY]/corpus/test.lib/var-copy.html">var-copy</a>,</p>
106
107<p><a href="[RELCURRENTWORKINGDIRECTORY]/t/htmlescp.html">htmlescp</a>,</p>
108
109<p><a href="[RELCURRENTWORKINGDIRECTORY]/t/feature.html#Another-Head-1">&quot;Another Head 1&quot; in feature</a>,</p>
110
111<p>and another <a href="[RELCURRENTWORKINGDIRECTORY]/t/feature.html#Another-Head-1">&quot;Another Head 1&quot; in feature</a>.</p>
112
113
114</body>
115
116</html>
117
118
119