3 #------------------------------------------------------------------------------
7 use Test::More 'no_plan';
11 #****h* ROBODoc System Tests/Basics
13 # Tests basic ROBODoc funcionallity. These are all
18 #****v* Basics/Dummy Headers
20 # A dummy header to put into dummy source files.
32 #****x* Basics/Option version
34 # Test robodoc --version, this should report the current version.
37 my ( $out, $err ) = runrobo('--version');
38 like( $out, qr/\d+\.\d+.\d+/, '--version should print version number' );
39 is( $err, '', '... and no error' );
43 #****x* Basics/Option help
45 # Test the option --help.
48 my ( $out, $err ) = runrobo('--help');
49 like( $out, qr/ROBODoc Version/, '--help should print version number' );
50 is( $err, '', '... and no error' );
55 #****x* Basics/Option multidoc
57 # Test --multidoc for html output format.
58 # (Multidoc for other modes does not make much sense).
59 # We create one source file with a simple header and create multidoc
62 add_source( "test.c", $source );
63 my ( $out, $err ) = runrobo(qw(--src Src --doc Doc --multidoc --html));
65 is( $out, '', 'No ouput' );
66 is( $err, '', '... and no error' );
67 file_exists_ok( "Doc/test_c.html", 'there should be documentation' );
68 file_exists_ok( "Doc/robodoc.css", 'and a stylesheet' );
76 # test --multidoc for --troff
83 #****x* Basics/Singledoc Outputmode with Different Formats
85 # Test singledoc mode for all supported output formats
86 # and see if it creates output in this format.
91 add_source( "test.c", $source );
101 foreach my $mode ( keys %output_modes ) {
102 my $file_extension = $output_modes{$mode};
104 my @arguments = qw(--src Src --doc testdoc --singledoc);
105 push( @arguments, $mode );
107 my ( $out, $err ) = runrobo(@arguments);
108 is( $out, '', 'No ouput' );
109 is( $err, '', '... and no error' );
110 file_exists_ok( "testdoc.$file_extension",
111 'there should be documentation' );
112 if ( $mode eq "--html" ) {
113 file_exists_ok( "testdoc.css", 'and a stylesheet' );
116 unlink("testdoc.$file_extension") if -e "testdoc.$file_extension";
117 unlink('testdoc.css') if -e 'testdoc.css';
126 #****v* Basics/test_source_2
128 # A dummy header to put into dummy source files.
129 # This one has headers at several levels.
132 my $test_source_2 = <<'EOF';
133 /****f* Level_1/Level_2
139 /****f* Level_2/_Level_3
145 /****f* Level_3/_Level_4
155 #****x* Basics/Option first section level
157 # Test --first_section_level.
159 # The level of the first section should be
160 # at level 3 instead of 1.
164 add_source( "test.c", $test_source_2 );
166 my ( $out, $err ) = runrobo(
173 --first_section_level 3));
175 is( $out, '', 'No ouput' );
176 is( $err, '', '... and no error' );
177 file_exists_ok( "Doc/test.xml", 'there should be documentation' );
179 # Now test the level of the first header.
180 my $documentation = XMLin( 'Doc/test.xml' );
181 my $section = $documentation->{'section'};
182 is ( $section->[0]->{'depth'}, '3', 'First section is at level 3' );
183 my $subsection = $section->[0]->{'section'};
184 is ( $subsection->{'depth'}, '4', 'First subsection is at level 4' );
185 is ( $section->[1]->{'depth'}, '3', 'Second section is at level 3' );