html.mk

static html creation framework using make(1) and cpp(1)
git clone git://0x30.net/html.mk
Log | Files | Refs | README | LICENSE

xliterate.t (1442B)


      1 #
      2 # #include "foo.xliterate" works.
      3 #
      4 use Modern::Perl;
      5 use Test::Cmd;
      6 use Test::File::Contents;
      7 use Test::More tests => 7;
      8 
      9 
     10 my $cmd = Test::Cmd->new( prog => '/usr/bin/make', workdir => '' );
     11 my $html_mk = $cmd->here . "/bsd.html.mk";
     12 
     13 $cmd->write( 'c_frag.c', '#include <stdio.h>' );
     14 $cmd->write( 'html_frag.html', '<head><body> <img /> </body>' );
     15 $cmd->write( 'in_frag.in', 'line one  \n
     16 line two' );
     17 $cmd->write( 'txt_frag.txt', 'whatever' );
     18 $cmd->write( 'sh_frag.sh', '#!/bin/sh' );
     19 
     20 $cmd->write( 'index.in', <<EOF );
     21 #include "c_frag.xliterate"
     22 --
     23 #include "html_frag.xliterate"
     24 --
     25 #include "in_frag.xliterate"
     26 --
     27 #include "txt_frag.xliterate"
     28 --
     29 #include "sh_frag.xliterate"
     30 EOF
     31 
     32 $cmd->write( 'Makefile', <<EOF );
     33 .include "$html_mk"
     34 EOF
     35 
     36 # make depend
     37 $cmd->run( args => 'depend', chdir => $cmd->curdir );
     38 like( $cmd->stdout,	qr/.*/,		'make stdout' );
     39 is( $cmd->stderr,	"",		'make stderr' );
     40 is( $? >> 8,		0,		'make exit status' );
     41 
     42 # make
     43 $cmd->run( chdir => $cmd->curdir );
     44 like( $cmd->stdout,	qr/sed .*/,	'make stdout' );
     45 is( $cmd->stderr,	"",		'make stderr' );
     46 is( $? >> 8,		0,		'make exit status' );
     47 
     48 #
     49 # Compare index.html with known good output.
     50 #
     51 my $good = <<'EOF';
     52 
     53 
     54 &num;include &lt;stdio.h&gt;
     55 --
     56 &lt;head&gt;&lt;body&gt; &lt;img /&gt; &lt;/body&gt;
     57 --
     58 line one  &bsol;n
     59 line two
     60 --
     61 whatever
     62 --
     63 &num;!/bin/sh
     64 EOF
     65 
     66 file_contents_eq_or_diff( $cmd->workdir . "/index.html", $good,
     67 	'index.html contents transliterated' );