include_comments.t (964B)
1 # 2 # Make sure comments are not stripped from preprocessed files. 3 # 4 use Modern::Perl; 5 use Test::Cmd; 6 use Test::File::Contents; 7 use Test::More tests => 5; 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( 'Makefile', <<EOF ); 14 .include "$html_mk" 15 EOF 16 $cmd->write( 'index.in', '#include "comments.c"' ); 17 $cmd->write( 'comments.c', <<EOF ); 18 /* single line comment */ 19 -- 20 /* 21 * multi line comment 22 */ 23 -- 24 // C++ style comment 25 EOF 26 27 $cmd->run( args => 'depend', chdir => $cmd->curdir ); 28 is( $cmd->stderr, '', 'make depend stderr' ); 29 is( $? >> 8, 0, 'make depend exit status' ); 30 31 $cmd->run( chdir => $cmd->curdir ); 32 is( $cmd->stderr, '', 'make stderr' ); 33 is( $? >> 8, 0, 'make exit status' ); 34 35 my $contents; 36 $cmd->read( \$contents, 'index.html' ); 37 $contents =~ s/^\n//mg; 38 $cmd->write( 'index.html', $contents ); 39 40 files_eq_or_diff( $cmd->workdir . '/comments.c', 41 $cmd->workdir . '/index.html' );