[ Top ] [ Modules ]
FUNCTION
A set of perl scripts that test ROBODoc functionallity. Each script contains one of more system tests. Each test starts ROBODoc with a specific input and then asserts that ROBODoc produces the correct output.
The tests use the Perl unittest framework, that is the modules:
There is also a custom module ROBOTestFrame that contains a set of useful functions that are common to all tests.
You can run the tests with
prove -l
Tests go into files with the extension .t. You can run an individual set of tests with
prove <testfile>
A 'prove' should always result in a 100% score. No test should fail.
[ Top ] [ ROBODoc System Tests ] [ Modules ]
FUNCTION
Test ROBODoc ASCII generator.
[ Top ] [ ASCII Generator ] [ Variables ]
FUNCTION
A dummy header to put into dummy source files.
SOURCE
my $dummy_header_1 = <<'EOF'; C ****f* Lib/Func C NAME C Func -- useless C Computes the value: C |latex \begin{equation} C |latex x = 0 C |latex \end{equation} C app C C SYNOPSIS C Func = Func (n) C Computes the value: C |latex \begin{equation} C |latex x = 0 C |latex \end{equation} C BUGS C Generates screwy TeX C *** real function Func(n) Func = 0 end function Func EOF
[ Top ] [ ASCII Generator ] [ Variables ]
FUNCTION
A dummy header to put into dummy source files.
SOURCE
my $dummy_header_2 = <<'EOF'; C ****f* Lib/Func C NAME C Func -- useless C SYNOPSIS C Example: C Foo foo foo C foo C C Test paragraph. C Do da diddi do da dom dom. C C BUGS C A list test: C * item 1 C * item 2 C * item 3 C C *** real function Func(n) Func = 0 end function Func EOF
[ Top ] [ ASCII Generator ] [ System tests ]
FUNCTION
Try different combination of options. This should not cause any asserts().
SOURCE
{ my @sources = ( \$dummy_header_1, \$dummy_header_2 ); foreach my $source_ref ( @sources ) { foreach my $mode_1 qw( --sections --toc --index --nopre ) { foreach my $mode_2 qw( --singledoc --multidoc ) { mkdocdir(); add_source( "test.c", $$source_ref ); my ( $out, $err ) = runrobo( qw(--src Src --doc Doc/test --ascii ), $mode_1, $mode_2 ); # expected results: is( $out, '', 'No ouput' ); is( $err, '', '... and no error' ); my $file_name; # Docments names differ for the different # modes. if ( $mode_2 eq "--multidoc" ) { $file_name = "Doc/test/test_c.txt"; } else { $file_name = "Doc/test.txt"; } file_exists_ok( $file_name, 'there should be documentation' ); clean(); } } } }
[ Top ] [ ROBODoc System Tests ] [ Modules ]
FUNCTION
Tests basic ROBODoc funcionallity. These are all 'happy paths'.
[ Top ] [ Basics ] [ Variables ]
FUNCTION
A dummy header to put into dummy source files.
SOURCE
my $source = <<'EOF'; /****f* Test/test * NAME * Test ****** */ EOF
[ Top ] [ Basics ] [ System tests ]
FUNCTION
Test --multidoc with --one_file_per_header for html output. We test this with one source file that contains three headers. These should result in three documentation files. To make it nasty we use some special header names.
SOURCE
# A dummy header to put into dummy source files. my $source = <<'EOF'; /****f* Test/Test * NAME * Test foo bar ****** */ /****f* Test/foo, bar * NAME * Test foo bar ****** */ /****f* Test/aa::awaw * NAME * Test foo bar ****** */ EOF { add_source( "test.c", $source ); my ( $out, $err ) = runrobo(qw(--src Src --doc Doc --one_file_per_header --multidoc --html)); # expected results: is( $out, '', 'No ouput' ); is( $err, '', '... and no error' ); # There are three headers, so there should be three documentation files. file_exists_ok( 'Doc/test_cTest2FTest.html', 'Documentation for Test/Test' ); file_exists_ok( 'Doc/test_cTest2Ffoo.html', 'Documentation for Test/foo' ); file_exists_ok( 'Doc/test_cTest2Faa3A3Aawaw.html', 'Documentation for Test/aa::awaw' ); # And a style sheet. file_exists_ok( "Doc/robodoc.css", 'and a stylesheet' ); clean(); }
[ Top ] [ Basics ] [ System tests ]
FUNCTION
Test --first_section_level.
The level of the first section should be at level 3 instead of 1.
SOURCE
{ add_source( "test.c", $test_source_2 ); mkdocdir(); my ( $out, $err ) = runrobo( qw(--src Src --doc Doc/test --singledoc --sections --test --toc --first_section_level 3)); # expected results: is( $out, '', 'No ouput' ); is( $err, '', '... and no error' ); file_exists_ok( "Doc/test.xml", 'there should be documentation' ); # Now test the level of the first header. my $documentation = XMLin( 'Doc/test.xml' ); my $section = $documentation->{'section'}; is ( $section->[0]->{'depth'}, '3', 'First section is at level 3' ); my $subsection = $section->[0]->{'section'}; is ( $subsection->{'depth'}, '4', 'First subsection is at level 4' ); is ( $section->[1]->{'depth'}, '3', 'Second section is at level 3' ); clean(); }
[ Top ] [ Basics ] [ System tests ]
FUNCTION
Test the option --help.
SOURCE
{ my ( $out, $err ) = runrobo('--help'); like( $out, qr/ROBODoc Version/, '--help should print version number' ); is( $err, '', '... and no error' ); }
[ Top ] [ Basics ] [ System tests ]
FUNCTION
Test --multidoc for html output format. (Multidoc for other modes does not make much sense). We create one source file with a simple header and create multidoc
SOURCE
{ add_source( "test.c", $source ); my ( $out, $err ) = runrobo(qw(--src Src --doc Doc --multidoc --html)); # expected results: is( $out, '', 'No ouput' ); is( $err, '', '... and no error' ); file_exists_ok( "Doc/test_c.html", 'there should be documentation' ); file_exists_ok( "Doc/robodoc.css", 'and a stylesheet' ); clean(); }
[ Top ] [ Basics ] [ System tests ]
FUNCTION
Test robodoc --version, this should report the current version.
SOURCE
{ my ( $out, $err ) = runrobo('--version'); like( $out, qr/\d+\.\d+.\d+/, '--version should print version number' ); is( $err, '', '... and no error' ); }
[ Top ] [ Basics ] [ System tests ]
FUNCTION
Test singledoc mode for all supported output formats and see if it creates output in this format.
SOURCE
{ add_source( "test.c", $source ); my %output_modes = ( '--html' => 'html', '--rtf' => 'rtf', '--test' => 'xml', '--latex' => 'tex', '--dbxml' => 'xml', ); foreach my $mode ( keys %output_modes ) { my $file_extension = $output_modes{$mode}; my @arguments = qw(--src Src --doc testdoc --singledoc); push( @arguments, $mode ); my ( $out, $err ) = runrobo(@arguments); is( $out, '', 'No ouput' ); is( $err, '', '... and no error' ); file_exists_ok( "testdoc.$file_extension", 'there should be documentation' ); if ( $mode eq "--html" ) { file_exists_ok( "testdoc.css", 'and a stylesheet' ); } unlink("testdoc.$file_extension") if -e "testdoc.$file_extension"; unlink('testdoc.css') if -e 'testdoc.css'; } clean(); }
[ Top ] [ Basics ] [ Variables ]
FUNCTION
A dummy header to put into dummy source files. This one has headers at several levels.
SOURCE
my $test_source_2 = <<'EOF'; /****f* Level_1/Level_2 * NAME * Test ****** */ /****f* Level_2/_Level_3 * NAME * Test ****** */ /****f* Level_3/_Level_4 * NAME * Test ****** */ EOF
[ Top ] [ ROBODoc System Tests ] [ Modules ]
FUNCTION
Test decoding en encoding of non 7bit ASCII characters.
[ Top ] [ ROBODoc System Tests ] [ Modules ]
FUNCTION
Test wether calling ROBODoc with wrong options or input leads to the correct error messages.
[ Top ] [ Handling Errors ] [ System tests ]
FUNCTION
ROBODoc should complain about options that are specifed more than once.
SOURCE
{ add_source( "test.c", $source ); my ($out, $err) = runrobo( qw( --src Src --doc Doc --multidoc --test --test --test) ); print $out; like($out, qr/Usage/, 'Duplicate options should print usage' ); print $err; like($err, qr/than\sonce/, 'and an error message' ); clean(); }
[ Top ] [ Handling Errors ] [ System tests ]
FUNCTION
ROBODoc should complain about options that can not be used together.
SOURCE
{ add_source( "test.c", $source ); my ($out, $err) = runrobo( qw(--src Src --doc Doc --multidoc --singledoc --html) ); like($out, qr/Usage/, 'Mutual excluding options should print usage' ); print $err; like($err, qr/together/, 'and an error message' ); clean(); }
[ Top ] [ Handling Errors ] [ System tests ]
FUNCTION
ROBODoc should complain about options that can not be used together.
SOURCE
{ add_source( "test.c", $source ); my ($out, $err) = runrobo( qw(--src Src --doc Doc --multidoc --test --dbxml --html) ); like($out, qr/Usage/, 'Mutual excluding options should print usage' ); print $err; like($err, qr/together/, 'and an error message' ); clean(); }
[ Top ] [ Handling Errors ] [ System tests ]
FUNCTION
ROBODoc should complain about non-existing options.
SOURCE
{ my ($out, $err) = runrobo( '--foobar' ); like($out, qr/Usage/, 'Unknown option should print usage' ); like($err, qr/Invalid/, 'and an error message' ); }
[ Top ] [ Handling Errors ] [ System tests ]
FUNCTION
When given a non-existing .rc file, ROBODc should at least report the name of the .rc file.
SOURCE
{ my ($out, $err) = runrobo( '--rc foobar.rc' ); like($err, qr/foobar/, 'should give an error message about foorbar.rc' ); }
[ Top ] [ Handling Errors ] [ System tests ]
FUNCTION
Test ROBODoc's response on a header without an end marker. ROBODoc should detect this.
SOURCE
{ my $source = <<'EOF'; /****f* Test/test * NAME * Test * FUNCTION * Test2 * SOURCE */ some source and no end of the header .... EOF add_source( "test.c", $source ); my ($out, $err) = runrobo( qw(--src Src --doc Doc --multidoc --test) ); is( $out, '', 'no output' ); like( $err, qr/end\smarker/, 'error about end marker' ); clean(); }
[ Top ] [ Handling Errors ] [ System tests ]
FUNCTION
Test ROBODoc's response to a file with two headers that have the same name. This should be reported as an error.
SOURCE
{ my $source = <<'EOF'; /****f* Test/test * NAME * Test * FUNCTION * Test2 ***** */ /****f* Test/test * NAME * Test * FUNCTION * Test2 ***** */ EOF add_source( "test.c", $source ); my ($out, $err) = runrobo( qw(--src Src --doc Doc --multidoc --test) ); is( $out, '', 'no output' ); like( $err, qr/already\sexists/, 'error duplicate header' ); clean(); }
[ Top ] [ Handling Errors ] [ System tests ]
FUNCTION
When given a impossible output filename ROBODoc should at least report the filename.
SOURCE
{ add_source( "test.c", $source ); my ($out, $err) = runrobo( qw(--src Src --doc Foo/Bar/document --singledoc --html) ); like($err, qr/document/, 'should give an error message about document' ); }
[ Top ] [ Handling Errors ] [ System tests ]
FUNCTION
When given a impossible css filename ROBODoc should at least report the filename.
SOURCE
{ add_source( "test.c", $source ); my ($out, $err) = runrobo( qw(--src Src --doc Doc --multidoc --html --css Foo/Bar/cascade.css) ); like($err, qr/cascade/, 'should give an error message about css file' ); }
[ Top ] [ ROBODoc System Tests ] [ Modules ]
FUNCTION
Tests the parsing of ROBODoc headers.
[ Top ] [ Header Test ] [ System tests ]
FUNCTION
Try several header with names that contain spaces. These should be accepted.
SOURCE
{ my $source = <<'EOF'; {****f* xxxxxx/x_xxx_xxxxxxxxxxxxxxxxxxxxxxxx * *OMSCHRIJVING *xxxx xxxxxxx xxxxxxxxx xxxxxxxxxx xxxxxxx xxxxxxxxxxxx xx xx xxxxxxxxxxxxxxx *xxxxxxxxx x_xxx_xxxxxxxxxxxxxxxxxx xxxxxxx * *INVOER *xxxxxxx : xxx xxxxxxx xxxx xxxxxx xxxxxxxxx xxxxxxxxxxxx xxxxx xx xxx xx * xxxxxxxxx xxxxxxxxx xxxxx xxxxxxxxxxxx. *xxxxxxxxxxx : xxx xxxxxxxxx xxxxx xxxxx xxx xx xxxxx xxxxxx xx xxxxxxxxxx * xxxxxxxxx xxxxxxxx xx *RETURNWAARDE *xxxx__xxxxxxx, x_xxx_xxxxxxxxx, xxxx__xxxxxxxx, x_xxx_xxxxxxxx, *x_xxx_xxxxxxxxx, x_xxx_xxxxxxxxxxxxxx xx x_xxxx_xxxxxx_xxx xxxxxx xxxxx. * *VOORBEELD *x_xxx_xxxxxxxxxxxxxxxxxxxxxxxx (xxxxxxx := 5000, * xxxxxxxxxxx := xx_xxxxxxxxxxx); *DECLARATIE *} {*****} EOF my $config = <<'EOF'; items: OMSCHRIJVING WIJZIGINGSOVERZICHT DECLARATIE INVOER UITVOER IN-UITVOER PARAMETERS BOUNDARIES RETURNWAARDE ATTRIBUTEN GEBRUIKTE GEGEVENS VOORBEELD ZIE VERDER OPMERKINGEN PRECONDITIE POSTCONDITIE item order: OMSCHRIJVING DECLARATIE source items: DECLARATIE SOURCE preformatted items: WIJZIGINGSOVERZICHT INVOER UITVOER IN-UITVOER PARAMETERS RETURNWAARDE ATTRIBUTEN VOORBEELD headertypes: h "Modules" vptlib_modules f "Functies" vptlib_functies v "Variabelen" vptlib_variabelen s "Structuren" vptlib_structuren e "Enumeraties" vptlib_enumeraties c "Constanten" vptlib_constanten u "Unittesten" vptlib_unittesten t "Typedefinities" vptlib_typedefs m "Macros" vptlib_macros d "Definities" vptlib_definities options: --documenttitle "Xxxxxxxxxxxxxxxxxxx" --tabsize 8 --index --sections --sectionnameonly --nopre --multidoc header markers: /****
[ Top ] [ Header Test ] [ System tests ]
FUNCTION
The 3rd header points to the first header, completing a circle. ROBODoc should complain about this.
SOURCE
TODO: { local $TODO = "checking circular headers is not implemented yet."; my $source = <<'EOF'; /****f* Foo/Bar * NAME * Bar ****/ /****f* Bar/Fii * NAME * Foo *****/ /****f* Fii/Bar * NAME * Foo *****/ EOF add_source( "test.c", $source ); my ($out, $err) = runrobo( qw( --src Src --doc Doc --multidoc --html --toc --sections ) ); # ROBODoc should complain about circular # headers. isnt( $err, '', 'there should be an error' ); # clean(); }
[ Top ] [ Header Test ] [ System tests ]
FUNCTION
Happy Path Simple plain header. This definitely should work
SOURCE
{ my $source = <<'EOF'; /****f* Test/test * NAME * Test * FUNCTION * Test2 ****** */ EOF add_source( "test.c", $source ); my ($out, $err) = runrobo( qw(--src Src --doc Doc --multidoc --test) ); is( $out, '', 'no output' ); is( $err, '', 'and no error' ); clean(); }
[ Top ] [ Header Test ] [ System tests ]
FUNCTION
Try several header with names that contain spaces. These should be accepted.
SOURCE
{ my $source = <<'EOF'; /****f* Test Foo Bar/Name With Spaces, And Anotherone, * And One More, More * NAME * Test * FUNCTION * Test2 ****** */ EOF add_source( "test.c", $source ); my ($out, $err) = runrobo( qw(--src Src --doc Doc --multidoc --test) ); is( $out, '', 'no output' ); is( $err, '', 'and no error' ); my $documentation = XMLin( 'Doc/test_c.xml' ); my $header = $documentation->{'header'}; is ( $header->{'name'}, 'Test Foo Bar/Name With Spaces', 'Header name' ); clean(); }
[ Top ] [ Header Test ] [ System tests ]
FUNCTION
Try a header name with spaces and some '*' at the end. The '*' should be ignored.
SOURCE
{ my $source = <<'EOF'; /****f* Test Foo Bar/Name With Spaces **** * NAME * Test * FUNCTION * Test2 ****** */ EOF add_source( "test.c", $source ); my ($out, $err) = runrobo( qw(--src Src --doc Doc --multidoc --test) ); is( $out, '', 'no output' ); is( $err, '', 'and no error' ); my $documentation = XMLin( 'Doc/test_c.xml' ); my $header = $documentation->{'header'}; is ( $header->{'name'}, 'Test Foo Bar/Name With Spaces', 'Header name' ); clean(); }
[ Top ] [ ROBODoc System Tests ] [ Modules ]
FUNCTION
Tests the parsing generation of ROBODoc items.
[ Top ] [ Item Test ] [ System tests ]
FUNCTION
Lets see if we can get items sorted according to the order specified in a robodoc.rc file.
SOURCE
{ my $source = <<'EOF'; /****f* Test/test * FIRST * Test 1 * Second * Test 2 * THIRD * Test 3 * SOURCE */ Test 4 /*******/ EOF my $config = <<'EOF'; items: FIRST Second THIRD FOURTH item order: SOURCE THIRD EOF my $config_no_sort = <<'EOF'; items: FIRST Second THIRD FOURTH EOF add_source( "test.c", $source ); add_configuration( "robodoc.rc", $config ); my ($out, $err) = runrobo( qw( --src Src --doc Doc --multidoc --ascii --rc Config/robodoc.rc ) ); is( $out, '', 'no output' ); is( $err, '', 'and no error' ); my $documentation = IO::File->new( "<Doc/test_c.txt" ); ok( $documentation, 'There is a doc file' ); my @items = (); while ( my $line = <$documentation> ) { if ( $line =~ m/(SOURCE|THIRD|Second|FIRST)/ ) { push( @items, $1 ); } } is( $items[ 0 ], 'SOURCE', 'First item it the source item' ); is( $items[ 1 ], 'THIRD', 'Second item it the third item' ); is( $items[ 2 ], 'FIRST', 'Third item it the first item' ); $documentation->close(); # Now the same but without sorting add_configuration( "robodoc.rc", $config_no_sort ); my ($out2, $err2) = runrobo( qw( --src Src --doc Doc --multidoc --ascii --rc Config/robodoc.rc ) ); is( $out2, '', 'no output' ); is( $err2, '', 'and no error' ); $documentation = IO::File->new( "<Doc/test_c.txt" ); ok( $documentation, 'There is a doc file' ); @items = (); while ( my $line = <$documentation> ) { if ( $line =~ m/(SOURCE|THIRD|Second|FIRST)/ ) { push( @items, $1 ); } } is( $items[ 0 ], 'FIRST', 'First item it the first item' ); is( $items[ 1 ], 'Second', 'Second item it the second item' ); is( $items[ 2 ], 'THIRD', 'Third item it the third item' ); is( $items[ 3 ], 'SOURCE', 'Fourth item it the fourth' ); $documentation->close(); clean(); }
[ Top ] [ ROBODoc System Tests ] [ Modules ]
FUNCTION
Test ROBODoc LaTeX generator.
[ Top ] [ LaTeX Generator ] [ Variables ]
FUNCTION
A dummy header to put into dummy source files.
SOURCE
my $dummy_header_1 = <<'EOF'; C ****f* Lib/Func C NAME C Func -- useless C Computes the value: C |latex \begin{equation} C |latex x = 0 C |latex \end{equation} C app C C SYNOPSIS C Func = Func (n) C Computes the value: C |latex \begin{equation} C |latex x = 0 C |latex \end{equation} C BUGS C Generates screwy TeX C *** real function Func(n) Func = 0 end function Func EOF
[ Top ] [ LaTeX Generator ] [ Variables ]
FUNCTION
A dummy header to put into dummy source files.
SOURCE
my $dummy_header_2 = <<'EOF'; C ****f* Lib/Func C NAME C Func -- useless C SYNOPSIS C Example: C Foo foo foo C foo C C Test paragraph. C Do da diddi do da dom dom. C C BUGS C A list test: C * item 1 C * item 2 C * item 3 C C *** real function Func(n) Func = 0 end function Func EOF
[ Top ] [ LaTeX Generator ] [ System tests ]
FUNCTION
This function tests whether a generated latex file is balanced or not. That is every
/begin{xxx}
should end with a
/end{xxx}
at the same level.
This is tested with several headers and in different modes.
SOURCE
{ my @sources = ( \$dummy_header_1, \$dummy_header_2 ); foreach my $source_ref ( @sources ) { foreach my $mode_1 qw( --sections --toc --index ) { foreach my $mode_2 qw( --nopre --altlatex ) { mkdocdir(); add_source( "test.c", $$source_ref ); my ( $out, $err ) = runrobo( qw(--src Src --doc Doc/test --singledoc --latex ), $mode_1, $mode_2 ); # expected results: is( $out, '', 'No ouput' ); is( $err, '', '... and no error' ); file_exists_ok( "Doc/test.tex", 'there should be documentation' ); is( is_latex_balanced( "Doc/test.tex" ), 1, 'latex is balanced' ); clean(); } } } }
[ Top ] [ ROBODoc System Tests ] [ Modules ]
FUNCTION
Test the usage of pipes.
[ Top ] [ Pipes ] [ System tests ]
FUNCTION
Test the use of latex pipes preformatted more.
SOURCE
{ add_source( "test.c", $pipe_source ); mkdocdir(); my ( $out, $err ) = runrobo( qw(--src Src --doc Doc/test --nopre --singledoc --sections --latex )); # expected results: is( $out, '', 'No ouput' ); is( $err, '', '... and no error' ); file_exists_ok( "Doc/test.tex", 'there should be documentation' ); # TODO test content clean(); }
[ Top ] [ ROBODoc System Tests ] [ Modules ]
FUNCTION
Test stuff that can be specified in the robodoc.rc file.
[ Top ] [ ROBODoc Configuration File ] [ System tests ]
FUNCTION
Test whether custum header markers can be specified.
SOURCE
{ my $source = <<'EOF'; / ****f* Test/test / NAME / Test / FUNCTION / Test1 / SOURCE / **** / ****F* Foo/foo / NAME / Foo / FUNCTION / Test2 / SOURCE / **** EOF my $rc_file = <<'EOF'; header markers: / **** remark markers: / end markers: / **** headertypes: f functions 1 F Foos 2 EOF add_source( "test.c", $source ); add_source( "robodoc.rc", $rc_file ); my ($out, $err) = runrobo( qw(--src Src --doc Doc --multidoc --test --rc Src/robodoc.rc ) ); is( $out, '', 'no output' ); is( $err, '', 'no error' ); my $documentation = XMLin( 'Doc/test_c.xml' ); my $header = $documentation->{'header'}; # print Dumper( $documentation ); isnt ( $header->{'Foo/foo'}, undef, 'There is a header named Foo/foo' ); isnt ( $header->{'Test/test'}, undef, 'There is a header named Test/foo' ); clean(); }
[ Top ] [ ROBODoc Configuration File ] [ System tests ]
FUNCTION
ROBODoc should not care about the kind of line-endings that are used. Either cr/lf or cr, or even lf should work without any problem. We test this with two .rc files that have different kind of line-endings.
SOURCE
{ my $source = <<'EOF'; /****f* Test/test * FOO * test ******/ EOF # A rc file with 'unix' line-endings. my $config = read_hexdump( 'TestData/robodoc_unix_rc.xxd' ); add_configuration( "test.rc", $config, 'binary' ); add_source( "test.rc", $source ); mkdocdir(); my ( $out, $err ) = runrobo(qw( --src Src --doc Doc/test --rc Config/test.rc --singledoc --test --nopre )); # expected results: is( $out, '', 'No ouput' ); is( $err, '', '... and no error' ); clean(); # A rc file with 'windows' line-endings. $config = read_hexdump( 'TestData/robodoc_windows_rc.xxd' ); add_configuration( "test.rc", $config, 'binary' ); add_source( "test.rc", $source ); mkdocdir(); ( $out, $err ) = runrobo(qw( --src Src --doc Doc/test --rc Config/test.rc --singledoc --test --nopre )); # expected results: is( $out, '', 'No ouput' ); is( $err, '', '... and no error' ); clean(); }
[ Top ] [ ROBODoc System Tests ] [ Modules ]
FUNCTION
Tests that test the Wiki like formatting that ROBODoc supports.
[ Top ] [ Wiki Formatting ] [ System tests ]
FUNCTION
Test a simple header: contains three lists, some paragraphs, and some source. All should be recognized.
SOURCE
{ my $source = <<'EOF'; /****f* Test/Test * NAME * * Implements serializers for the following * files: * - DZB_ACG - SAP accounting file record. * - DZB_RRP - regularoty reporting file record. * - DZB_MVT - Exchange Position File Record. * * A test * * Implements the following * functions: * - S99304_SERIALIZE_DZB_ACG * - S99304_SERIALIZE_DZB_ACG_TBL * - S99304_SERIALIZE_DZB_MVT * and the functions: * - S99304_SERIALIZE_DZB_MVT_TBL * - S99304_SERIALIZE_DZB_RRP * - S99304_SERIALIZE_DZB_RRP_TBL * SOURCE */ test() /******/ EOF add_source( "test.c", $source ); my ( $out, $err ) = runrobo(qw(--src Src --doc Doc --nopre --multidoc --test)); # expected results: is( $out, '', 'No ouput' ); is( $err, '', '... and no error' ); my $documentation = XMLin( 'Doc/test_c.xml' ); my $header = $documentation->{'header'}; is ( $header->{'name'}, 'Test/Test', 'Header is named Test/Test' ); my $items = $header->{'item'}; ok ( exists( $items->{'NAME'} ), 'header has an item NAME' ); ok ( exists( $items->{'SOURCE'} ), 'header has an item SOURCE' ); my $body = $items->{'NAME'}->{'item_body'}; # There are paragraphs. ok ( exists( $body->{'para'} ), 'item has paragraphs' ); # There are three lists. is ( scalar( @{ $body->{'list'} } ), 3, 'item has three lists' ); clean(); }
[ Top ] [ Modules ]
FUNCTION
A Perl module with a set of handy functions to create test scripts.
These function are:
[ Top ] [ ROBOTestFrame ] [ Functions ]
FUNCTION
Add a configuration file somewhere in Config/
INPUTS
SOURCE
sub add_configuration { my $filepath = shift; my $configuration = shift; my $binary = shift; add_file( $configuration_directory, $filepath, $configuration, $binary ) }
[ Top ] [ ROBOTestFrame ] [ Functions ]
FUNCTION
Add a single file somewhere in base_path.
INPUTS
SOURCE
sub add_file { my $base_path = shift; my $filepath = shift; my $content = shift; my $binary = shift; my $path = $base_path . dirname( $filepath ); $path =~ s/\.$//; # Fix for Perl 5.8.0 under Linux. if ( ! -e "$path" ) { mkpath $path or die "can't create $path"; } my $full_filepath = "$base_path/$filepath"; my $file = IO::File->new(">$full_filepath") or die "Can't open $full_filepath"; if ( $binary and ( $binary eq 'binary' ) ) { binmode( $file ); } print $file $content; $file->close(); }
[ Top ] [ ROBOTestFrame ] [ Functions ]
FUNCTION
Add a single source file somewhere in Src/
INPUTS
SOURCE
sub add_source { my $filepath = shift; my $source_code = shift; my $binary = shift; add_file( $source_directory, $filepath, $source_code, $binary ) }
[ Top ] [ ROBOTestFrame ] [ Functions ]
FUNCTION
Clean source and documentation directories.
SOURCE
sub clean { if ( -e $source_directory ) { rmtree( $source_directory ) or die; } if ( -e $documentation_directory ) { rmtree( $documentation_directory ) or die; } if ( -e $configuration_directory ) { rmtree( $configuration_directory ) or die; } }
[ Top ] [ ROBOTestFrame ] [ Functions ]
FUNCTION
Name of the documentation directory used to test ROBODoc.
SOURCE
my $configuration_directory = "Config";
[ Top ] [ ROBOTestFrame ] [ Functions ]
FUNCTION
Name of the documentation directory used to test ROBODoc.
SOURCE
my $documentation_directory = "Doc";
[ Top ] [ ROBOTestFrame ] [ Functions ]
FUNCTION
Test the balance of a latex file. A latex file is balanced if every
/begin{xxxx}
is ended with a
/end{xxx}
INPUTS
RETURNS * 0 -- file is not balanced * 1 -- file is balanced
SOURCE
sub is_latex_balanced { my $path = shift; my @stack; local( $/ ) ; my $file = IO::File->new("<$path") or die "$path : $!"; my $string = <$file>; $file->close(); while ( $string =~ m/(begin|end)\{([^}]+)\}/g ) { my $b_e = $1; # begin or end my $kind = $2; # document, or equation, or ... if ( $b_e eq "begin" ) { push( @stack, $kind ); } else { if ( pop( @stack ) eq $kind ) { # OK. begin and end matches. } else { # Not OK! # begin{ something } # followed by # end{ something else } return 0; # Failure. } } } if ( scalar( @stack ) ) { # there are items left! return 0; # Not OK. } return 1; # OK! }
[ Top ] [ ROBOTestFrame ] [ Functions ]
FUNCTION
Create a empty documentation directory. This is handy for tests that use --singledoc.
SOURCE
sub mkdocdir { if ( ! -e $documentation_directory ) { mkpath( $documentation_directory ); } }
[ Top ] [ ROBOTestFrame ] [ Functions ]
FUNCTION
Reads a hexdump made with xxd (part of vim http://www.vim.org/) This makes it possible to add files with all kinds of different formats and characters.
Storing it in hexdump format makes sure that these files are not changed when they are checked into cvs or unzipped.
This makes is possible to test cr/lf problems and internationalization issues.
INPUTS
RETURNS The decoded content of the file as a single string.
SOURCE
sub read_hexdump { my $path = shift; my $file = IO::File->new("<$path") or die "$path : $!"; my $string = ''; my @all_bytes = (); while ( my $line = <$file> ) { $line =~ s/^\S+:\s//; # remove address $line =~ s/\s\s+.*$//; # remove ascii $line =~ s/(\S\S)(\S\S)/$1 $2/g; # Now only the words are left. my @data = split( /\s/, $line ); my @bytes = map { chr hex } @data; push( @all_bytes, @bytes ); } # TODO try a join() here. foreach my $c ( @all_bytes ) { $string .= $c; } $file->close(); return $string; }
[ Top ] [ ROBOTestFrame ] [ Functions ]
FUNCTION
Location of the ROBODoc executable.
SOURCE
my $robo_win = "../robodoc.exe"; my $robo_unix = "../robodoc";
[ Top ] [ ROBOTestFrame ] [ Functions ]
FUNCTION
Run robodoc with the given set of arguments and capture all output to stdout en stderr.
INPUTS
A list of options for robodoc.exr RETURNS stdout and stderr.
SOURCE
sub runrobo { my $robo = ''; if ( $^O eq 'linux' ) { $robo = $robo_unix; } else { $robo = $robo_win; } run( [ $robo, @_ ], \my( $in, $out, $err ) ); return ($out, $err); }
[ Top ] [ ROBOTestFrame ] [ Functions ]
FUNCTION
Name of the source directory used to test ROBODoc.
SOURCE
my $source_directory = "Src";