#!/usr/bin/perl
#***************************************************************************************************
# *
# newTest.perl: some additional tests. All written in PERL. This is our new script language. *
# *
#***************************************************************************************************
#***************************************************************************************************
# *
# Copyright (C) 2003, 2004 Joerg Kunze *
# *
# This file is part of siliconBrain. *
# *
# siliconBrain is free software; you can redistribute it and/or modify *
# it under the terms of the GNU General Public License as published by *
# the Free Software Foundation; either version 2 of the License, or *
# (at your option) any later version. *
# *
# siliconBrain is distributed in the hope that it will be useful, *
# but WITHOUT ANY WARRANTY; without even the implied warranty of *
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# GNU General Public License for more details. *
# *
# You should have received a copy of the GNU General Public License *
# along with this program; if not, write to the Free Software *
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
# *
#***************************************************************************************************
$siliconBrainRelease = '$siliconBrainRelease: 0.2.3 $';
$siliconBrainRcsIdentifier = '$Id: newTest.perl,v 1.49 2004/12/14 23:31:26 joerg Exp $';
$siliconBrainSaveStamp = '$siliconBrainSaveStamp: 2004/12/10 22:05:12, Joerg Kunze$';
$scriptName = "newTest.perl";
use Cwd;
use SiliconBrain;
#***************************************************************************************************
# *
# main: *
# *
#***************************************************************************************************
testPrint( "This is a first perl script for testing." );
testPrint( $siliconBrainRelease );
testPrint( $siliconBrainRcsIdentifier );
testPrint( $siliconBrainSaveStamp );
$testWorkingDirectory = getcwd();
#--------------------------------------------------------------------------------------------------#
testPrint( "test the test frame ..." );
#--------------------------------------------------------------------------------------------------#
testAssert( 'testProbe() =~ /probe: 1234566642/' );
testAssert( 'defined $siliconBrainPath' );
#--------------------------------------------------------------------------------------------------#
testPrint( "test stringSearch command ..." );
#--------------------------------------------------------------------------------------------------#
testCommand( " echo \$'High Ut\377, wie High Ute' | stringSearch --expression='High Ute'" );
testCommand( " echo 'High Ute, wie gehts' | stringSearch --expression='High Ute'" );
testCommand( "!echo 'High Ute, wie gehts' | stringSearch --expression='High Xte'" );
testCommand( " echo 'aaadadxxxxxxxxxxxxxx' | stringSearch --expression='adad'" );
testCommand( " { echo 'xxxxab'; sync; echo 'cdyyy' ; } | stringSearch --expression=\$'ab\ncd'" );
testCommand( "!{ echo 'xxxxab'; sync; echo 'cdyyy' ; } | stringSearch --expression=\$'ab\ncx'" );
testCommand( " { echo 'xxxxab'; sync; echo 'cdyabcdyy'; } | stringSearch --expression=\$'abcd'" );
#--------------------------------------------------------------------------------------------------#
testPrint( "generated snippets ..." );
#--------------------------------------------------------------------------------------------------#
testFileExists( "$siliconBrainPath/data/copyingGeneratedFile.snippet.text" );
#--------------------------------------------------------------------------------------------------#
testPrint( "formatHeader ..." );
#--------------------------------------------------------------------------------------------------#
testCommand(
'formatHeader '
. '"#" '
. '"\$siliconBrainRelease: 0.1.1" '
. '"\$Id: spec,v 1.75 2003/09/22 09:49:25 joerg Exp" '
. '"\$siliconBrainSaveStamp: 2003/09/22 08:23:19, Joerg Kunze" '
. '"formatHeader testoutput with no real specification behind" '
. '"\$siliconBrainRelease: 0.0.13" '
. '"\$Id: generator,v 1.75 2003/09/22 09:49:25 joerg Exp" '
. '"\$siliconBrainSaveStamp: 2003/09/22 08:23:19, Joerg Kunze" '
,
'grep /generated with/',
'grep /on host/'
);
#--------------------------------------------------------------------------------------------------#
testPrint( "siliconBrain environment ..." );
#--------------------------------------------------------------------------------------------------#
testAssert( '$ENV{INFOPATH} =~ /$siliconBrainPath\/documentation/' );
#--------------------------------------------------------------------------------------------------#
testPrint( "first make ..." );
#--------------------------------------------------------------------------------------------------#
testMake( "first time to call make" );
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking for info material ..." );
#--------------------------------------------------------------------------------------------------#
testFileExists( "distribution/documentation/dir" );
testFileExists( "distribution/documentation/myProject.ps" );
#--------------------------------------------------------------------------------------------------#
testPrint( "Testing createReleaseInformation ..." );
#--------------------------------------------------------------------------------------------------#
eval `siliconBrainPackageName=myProject createReleaseInformation --perl`;
testAssert( '$releaseArchive =~ /myProject.*\.tar\.gz/' );
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking for install material ..." );
#--------------------------------------------------------------------------------------------------#
testFileExists( "distribution/setEnvironment" );
testCommand( 'siliconBrainInstall 2>&1',
"grep /myProject/",
"grep /distribution/"
);
#--------------------------------------------------------------------------------------------------#
testPrint( "Creating small script to dive into the test environment ..." );
#--------------------------------------------------------------------------------------------------#
$diveInto = $ENV{"HOME"} . "/bin/diveInto";
open( diveInto, ">$diveInto" );
print diveInto "#!/bin/bash\n";
print diveInto "cd $testWorkingDirectory\n";
close( diveInto );
`./siliconBrainInstall >> $diveInto 2> /dev/null`;
open( diveInto, ">>$diveInto" );
print diveInto "xterm -title myProject -bg black -fg white\n";
close( diveInto );
chmod 0775, $diveInto;
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking for include dir ..." );
#--------------------------------------------------------------------------------------------------#
testAssert( '-d "distribution/include"' );
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking for some standard files ..." );
#--------------------------------------------------------------------------------------------------#
testFileExists( "$siliconBrainPath/include/siliconBrainSpecification" );
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking C compilation ..." );
#--------------------------------------------------------------------------------------------------#
open( cProgram, ">cProgram.main.c" );
print cProgram <<endOfCProgram
#include <stdio.h>
#include "siliconBrainSpecification"
int main() {
puts( "High Du!\\n" );
printf( "Specification probe = %d\\n", sbProbe );
return 0;
}
endOfCProgram
;
close( cProgram );
testMake( "compile cProgram.main.c" );
testFileExists( "distribution/programs/cProgram" );
testCommand( 'distribution/programs/cProgram',
"grep /42235/"
);
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking records ..." );
#--------------------------------------------------------------------------------------------------#
open( cProgram, ">myRecord.record.specification.c" );
print cProgram <<endOfCProgram
#include <stdio.h>
#define siliconBrainPrintShortNames
#include "siliconBrainLib"
static const char *siliconBrainRelease = "\$siliconBrain" "Release: 0.0.7 \$";
static const char *siliconBrainRcsIdentifier = "\$I" "d: myRecord.record.specification.c,v 1.4 2003/06/07 21:59:58 joerg Exp \$";
static const char *siliconBrainSaveStamp = "\$siliconBrain" "SaveStamp: 2003/06/17 23:47:40, Joerg Kunze\$";
int main( int argc, const char *argv[] ) {
SiliconBrainPrinter siliconBrainPrinter;
siliconBrainPrinterInit( &siliconBrainPrinter, argc, argv );
tag( "record" );
attribute( "name" , "myRecord" );
attribute( "release" , siliconBrainRelease );
attribute( "rcsIdentifier", siliconBrainRcsIdentifier );
attribute( "saveStamp" , siliconBrainSaveStamp );
attribute( "title" , "This is myRecord. It tests siliconBrains record specs." );
tag( "shortDescription" );
text( "myRecord is used just for the test suit of siliconBrain." );
end();
tag( "longDescription" );
text(
"myRecord is just for testing the different features of the siliconBrain record "
"specification and all the stuff, which is generated out of it. The thing what "
"myRecord does is comparably restricted as it is only used to test the handling of "
"record fields and the like."
);
end();
tag( "field" );
attribute( "name" , "firstName" );
attribute( "typeName" , "char *" );
tag( "shortDescription" );
text( "the first name of a person" );
end();
end();
tag( "field" );
attribute( "name" , "lastName" );
attribute( "typeName" , "char *" );
tag( "shortDescription" );
text( "the last name of a person" );
end();
end();
end();
return 0;
}
endOfCProgram
;
close( cProgram );
testMake( "compile myrecord.record.specification.c" );
testFileExists( "temporary/myRecord.record.specification.o", "temporary/myRecord.record.specification" );
`temporary/myRecord.record.specification | generate --c > temporary/myRecord.record.main.c 2> temporary/test.stderr`;
testFile( "temporary/test.stderr",
'!grep /No such file or directory/',
'!grep /GLib-WARNING/',
);
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking command specification ..." );
#--------------------------------------------------------------------------------------------------#
open( cProgram, ">myCommand.specification.c" );
print cProgram <<endOfCProgram
#include <stdio.h>
#define siliconBrainPrintShortNames
#include "siliconBrainLib"
static const char *siliconBrainRelease = "\$siliconBrain" "Release: 0.0.7 \$";
static const char *siliconBrainRcsIdentifier = "\$I" "d: myCommand.specification.c,v 1.3 2003/06/07 21:59:58 joerg Exp \$";
static const char *siliconBrainSaveStamp = "\$siliconBrain" "SaveStamp: 2003/06/17 23:47:40, Joerg Kunze\$";
int main( int argc, const char *argv[] ) {
SiliconBrainPrinter siliconBrainPrinter;
siliconBrainPrinterInit( &siliconBrainPrinter, argc, argv );
tag( "command" );
attribute( "name" , "myCommand" );
attribute( "release", siliconBrainRelease );
attribute( "rcsIdentifier", siliconBrainRcsIdentifier );
attribute( "saveStamp", siliconBrainSaveStamp );
attribute( "title", "This is myCommand. It tests siliconBrains command specs." );
tag( "shortDescription" );
text( "myCommand is used just for the test suit of siliconBrain." );
end();
tag( "longDescription" );
text(
"myCommand is just for testing the different features of the siliconBrain command "
"specification and all the stuff, which is generated out of it. The thing what "
"myComman does is comparably restricted as it is only used to test the handling of "
"command options and the like."
);
end();
tag( "option" );
attribute( "name" , "myFlag" );
attribute( "type" , "flag" );
attribute( "oneCharacterName", "f" );
tag( "shortDescription" );
text( "a simple yes no flag option" );
end();
end();
tag( "option" );
attribute( "name" , "myValue" );
attribute( "type" , "value" );
attribute( "oneCharacterName", "m" );
tag( "shortDescription" );
text( "a simple value option" );
end();
end();
tag( "option" );
attribute( "name" , "longOnly" );
attribute( "type" , "flag" );
tag( "shortDescription" );
text( "option without short form" );
end();
end();
tag( "option" );
attribute( "name" , "optionWithALongNameWhichShouldNotBeTruncatedInHelpOutput" );
attribute( "type" , "flag" );
tag( "shortDescription" );
text( "this option should align the help output, and its name should not be truncated" );
end();
end();
tag( "option" );
attribute( "name" , "forceError" );
attribute( "type" , "flag" );
tag( "shortDescription" );
text( "If set, the command is forced to retun an non-zero exit status" );
end();
end();
end();
return 0;
}
endOfCProgram
;
close( cProgram );
testMake( "compile myCommand.specification.c" );
testFileExists( "temporary/myCommand.specification.o", "temporary/myCommand.specification" );
testCommand( 'temporary/myCommand.specification',
'grep / myCommand. It tests siliconB/'
);
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking commands ..." );
#--------------------------------------------------------------------------------------------------#
open( cProgram, ">myCommand.command.c" );
print cProgram <<endOfCProgram
#include <stdio.h>
#include "siliconBrainSpecification"
#include "siliconBrainOption"
#include "myCommand"
const char *myCommandSiliconBrainRelease = "\$siliconBrain" "Release: 0.0.7 \$";
const char *myCommandSiliconBrainRcsIdentifier = "\$I" "d: myCommand.command.c,v 1.42 2003/06/07 21:59:58 joerg Exp \$";
const char *myCommandSiliconBrainSaveStamp = "\$siliconBrain" "SaveStamp: 2003/06/17 11:55:55, Joerg Kunze\$";
CommandReturnCode myCommand( const myCommandOptions *options ) {
puts( "probe77756 High Du!" );
if( options->myFlag ) puts( "myFlag was specified." );
if( options->longOnly ) puts( "longOnly was specified." );
if( options->myValue ) printf( "myValue = %s\\n", options->myValue );
return options->forceError ? commandError : commandOk;
}
endOfCProgram
;
close( cProgram );
testMake( "compile myCommand.command.c" );
testFileExists( "temporary/myCommand.main.o", "distribution/programs/myCommand" );
testCommand( 'myCommand -t; exit 0' , '!grep /probe77756/' );
testCommand( 'myCommand' , 'grep /probe77756/', '!grep /myFlag was specified/' );
testCommand( 'myCommand -f' , 'grep /myFlag was specified/' );
testCommand( 'myCommand --myValue=probe98761234', 'grep /probe98761234/' );
testCommand( 'myCommand --longOnly' , 'grep /longOnly/' );
testCommand( 'myCommand --help' , 'grep /optionWithALongNameWhichShouldNotBeTruncatedInHelpOutput/' );
testCommand( 'myCommand --myFlag' , 'grep /myFlag was specified/' );
testCommand( 'myCommand --myFlag=true' , 'grep /myFlag was specified/' );
testCommand( 'myCommand --myFlag=false' , '!grep /myFlag was specified/' );
testCommand( '!myCommand --forceError' , '!grep /myFlag was specified/' );
#--------------------------------------------------------------------------------------------------#
testPrint( "Testing recreation of *.d files ..." );
#--------------------------------------------------------------------------------------------------#
$dotDFilesToTest = "temporary/cProgram.main.d", "temporary/myRecord.record.command.d";
testFileExists( $dotDFilesToTest );
unlink( $dotDFilesToTest );
testMake( "recreate *.d files after deleting (removing, unlinking) them" );
testFileExists( $dotDFilesToTest );
undef $dotDFilesToTest;
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking for 'copying generated file' comment ..." );
#--------------------------------------------------------------------------------------------------#
testFile( "temporary/myCommand.main.c",
'grep /This file is generated by "free" software,/',
'grep /generated with/'
);
testFile( "temporary/myRecord.record.main.c",
'grep /This file is generated by "free" software,/',
'grep /generated with/',
'grep /generate.main.c/',
'!grep /generate.lib.c/'
);
testFile( "temporary/myRecord.record.command.c",
'grep /This file is generated by "free" software,/',
'grep /generated with/',
'grep /generate.main.c/',
'!grep /generate.lib.c/'
);
testFile( "temporary/authors.snippet.texinfo.d",
'grep /This file is generated by "free" software,/',
'grep /generated with/',
'grep /authors.snippet.texinfo.template,v/'
);
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking package specification of standard options ..." );
#--------------------------------------------------------------------------------------------------#
testFile( "temporary/myCommand.main.c",
'!grep /standardFlag/'
);
open( cProgram, ">myProject.specification.c" );
print cProgram <<endOfCProgram
#include <stdio.h>
#define siliconBrainPrintShortNames
#include "siliconBrainLib"
static const char *siliconBrainRelease = "\$siliconBrain" "Release: 0.0.7 \$";
static const char *siliconBrainRcsIdentifier = "\$I" "d: myProject.specification.c,v 1.3 2003/06/07 21:59:58 joerg Exp \$";
static const char *siliconBrainSaveStamp = "\$siliconBrain" "SaveStamp: 2003/06/17 23:47:40, Joerg Kunze\$";
int main( int argc, const char *argv[] ) {
SiliconBrainPrinter siliconBrainPrinter;
siliconBrainPrinterInit( &siliconBrainPrinter, argc, argv );
tag( "command" );
attribute( "name" , "myProject" );
attribute( "release", siliconBrainRelease );
attribute( "rcsIdentifier", siliconBrainRcsIdentifier );
attribute( "saveStamp", siliconBrainSaveStamp );
attribute( "title", "This is myProject. It tests siliconBrains command and package specifications." );
tag( "shortDescription" );
text( "myProject is used just for the test suit of siliconBrain: the injection of standard options" );
end();
tag( "longDescription" );
text(
"The option specified here should be generated into myCommand as package "
"standard options."
);
end();
tag( "option" );
attribute( "name" , "standardFlag" );
attribute( "type" , "flag" );
tag( "shortDescription" );
text( "a simple standard yes no flag option" );
end();
end();
tag( "option" );
attribute( "name" , "standardValue" );
attribute( "type" , "value" );
tag( "shortDescription" );
text( "a simple standard value option" );
end();
end();
end();
return 0;
}
endOfCProgram
;
close( cProgram );
unlink( "temporary/myCommand.main.c" );
testMake( "compile myProject.specification.c" );
testFileExists( "temporary/myProject.specification.o", "temporary/myProject.specification" );
testFile( "temporary/myCommand.main.c",
'grep /standardFlag/'
);
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking package configurationReader ..." );
#--------------------------------------------------------------------------------------------------#
testFileExists( "distribution/programs/myProject.configurationReader" );
eval `myProject.configurationReader --standardValue=foo -- --perl`;
testAssert( '$standardValue eq "foo"' );
testAssert( '!defined $output' );
testAssert( '$complete' );
$ENV{ 'siliconBrainLibPrintIndent' } = 'true';
testCommand( 'myProject.configurationReader --standardValue=foo -- --xml',
'grep /<!-- .* a simple standard yes no flag option/',
'grep /<!-- .* It tests siliconBrains command and package specifications/',
'!grep /<standardFlag>/'
);
testCommand( 'myCommand --complete' );
$ENV{ 'myProject_standardValue' } = 'bar';
eval `myProject.configurationReader -- --perl`;
testAssert( '$standardValue eq "bar"' );
testAssert( '!defined $standardFlag' );
undef $standardValue;
eval `myProject.configurationReader --complete -- --perl`;
testAssert( '!defined $standardValue' );
undef $standardFlag;
eval `myProject.configurationReader --standardFlag -- --perl`;
testAssert( '$standardFlag' );
undef $standardFlag;
$ENV{ 'myProject_standardFlag' } = '';
eval `myProject.configurationReader -- --perl`;
testAssert( '$standardFlag' );
undef $standardFlag;
$ENV{ 'myProject_standardFlag' } = 'true';
eval `myProject.configurationReader -- --perl`;
testAssert( '$standardFlag' );
undef $standardFlag;
$ENV{ 'myProject_standardFlag' } = 'false';
eval `myProject.configurationReader -- --perl`;
testAssert( '!$standardFlag' );
undef $standardFlag;
$ENV{ 'myProject_standardFlag' } = 'false';
eval `myProject.configurationReader --standardFlag -- --perl`;
testAssert( '$standardFlag' );
$standardFlag = 1;
$ENV{ 'myProject_standardFlag' } = 'true';
eval `myProject.configurationReader --no-standardFlag -- --perl`;
testAssert( '!$standardFlag' );
open( cProgram, ">myProject.configuration.main.c" );
print cProgram <<endOfCProgram
#include <stdio.h>
#define siliconBrainPrintShortNames
#include "siliconBrainLib"
// static const char *siliconBrainRelease = "\$siliconBrain" "Release: 0.0.7 \$";
// static const char *siliconBrainRcsIdentifier = "\$I" "d: myProject.configuration.main.c,v 1.3 2003/06/07 21:59:58 joerg Exp \$";
// static const char *siliconBrainSaveStamp = "\$siliconBrain" "SaveStamp: 2003/06/17 23:47:40, Joerg Kunze\$";
int main( int argc, const char *argv[] ) {
SiliconBrainPrinter siliconBrainPrinter;
siliconBrainPrinterInit( &siliconBrainPrinter, argc, argv );
tag( "myProject" );
keyBool( "standardFlag", true );
keyBool( "verbose" , true );
key( "oops" , "well, ehm ..." );
end();
return 0;
}
endOfCProgram
;
close( cProgram );
testMake( "compile myProject.configuration.main.c" );
testFileExists( "distribution/programs/myProject.configuration" );
testCommand( 'myProject.configuration --xml',
'grep /<myProject>/',
'grep /<standardFlag\/>/'
);
undef $verbose;
eval `myProject.configurationReader --standardFlag=false -- --perl`;
testAssert( '$verbose' );
testAssert( '!$standardFlag' );
unlink 'temporary/myProject.configuration';
$ENV{ 'siliconBrainConfigurationPath' } = 'temporary:.:~:/etc';
undef $verbose;
eval `myProject.configurationReader --standardFlag=false -- --perl`;
testAssert( '!defined $verbose' );
testAssert( '!$standardFlag' );
rename 'distribution/programs/myProject.configuration', 'temporary/myProject.configuration';
undef $verbose;
eval `myProject.configurationReader --standardFlag=false -- --perl`;
testAssert( '$verbose' );
testAssert( '!$standardFlag' );
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking file command ..." );
#--------------------------------------------------------------------------------------------------#
open( cProgram, ">myFileCommand.specification.c" );
print cProgram <<endOfCProgram
#include <stdio.h>
#define siliconBrainPrintShortNames
#include "siliconBrainLib"
static const char *siliconBrainRelease = "\$siliconBrain" "Release: 0.0.7 \$";
static const char *siliconBrainRcsIdentifier = "\$I" "d: myFileCommand.specification.c,v 1.3 2003/06/07 21:59:58 joerg Exp \$";
static const char *siliconBrainSaveStamp = "\$siliconBrain" "SaveStamp: 2003/06/17 23:47:40, Joerg Kunze\$";
/* probe: first file */
int main( int argc, const char *argv[] ) {
SiliconBrainPrinter siliconBrainPrinter;
siliconBrainPrinterInit( &siliconBrainPrinter, argc, argv );
tag( "command" );
attribute( "name" , "myFileCommand" );
attribute( "release", siliconBrainRelease );
attribute( "rcsIdentifier", siliconBrainRcsIdentifier );
attribute( "saveStamp", siliconBrainSaveStamp );
attribute( "title", "This is myFileCommand. It tests stream mode file input." );
tag( "file" );
/* anchor: callBackFunctions */
end();
tag( "shortDescription" );
text( "myFileCommand just writes out all non printable chars." );
end();
tag( "longDescription" );
text(
"myFileCommand just does some analysis work on the input files."
);
end();
end();
return 0;
}
endOfCProgram
;
close( cProgram );
testMake( "compile myFileCommand.specification.c" );
testFileExists( "temporary/myFileCommand.specification.o", "temporary/myFileCommand.specification" );
open( cProgram, ">myFileCommand.command.c" );
print cProgram <<endOfCProgram
#include <stdio.h>
#include "siliconBrainSpecification"
#include "siliconBrainOption"
#include "myFileCommand"
const char *myFileCommandSiliconBrainRelease = "\$siliconBrain" "Release: 0.0.7 \$";
const char *myFileCommandSiliconBrainRcsIdentifier = "\$I" "d: myFileCommand.command.c,v 1.42 2003/06/07 21:59:58 joerg Exp \$";
const char *myFileCommandSiliconBrainSaveStamp = "\$siliconBrain" "SaveStamp: 2003/06/17 11:55:55, Joerg Kunze\$";
/* probe: second file */
/* anchor: callBackFunctions */
CommandReturnCode myFileCommand( const myFileCommandOptions *options, void *commandData, String source ) {
println( c( "-------------------------------> call" ) );
print( source );
return commandOk;
}
endOfCProgram
;
close( cProgram );
testMake( "compile myFileCommand.command.c" );
testFileExists( "temporary/myFileCommand.main.o", "distribution/programs/myFileCommand" );
testCommand( 'echo "probe6664223" | myFileCommand', 'grep /probe6664223/', '!grep /myFlag was specified/' );
testCommand( 'myFileCommand myFileCommand.specification.c myFileCommand.command.c', 'grep /probe: first file/', 'grep /probe: second file/' );
editFile "myFileCommand.specification.c", <<END
/anchor: callBackFunctions/
a
key( "openCommand" , "myOpenCommand" );
key( "openFile" , "myOpenFile" );
key( "closeFile" , "myCloseFile" );
key( "closeCommand", "myCloseCommand" );
.
END
;
editFile "myFileCommand.command.c", <<END
/anchor: callBackFunctions/
a
typedef struct {
int numberOfFiles;
} MyFileData;
extern void *myOpenCommand( const myFileCommandOptions *options ) {
MyFileData *data = malloc( sizeof( MyFileData ) );
data->numberOfFiles = 0;
return data;
}
extern CommandReturnCode myOpenFile( const myFileCommandOptions *options, void *data, String fileName ) {
print( fileName ); println( c( ":" ) );
return commandOk;
}
extern CommandReturnCode myCloseFile( const myFileCommandOptions *options, void *data, String fileName ) {
++((MyFileData *)data)->numberOfFiles;
return commandOk;
}
extern CommandReturnCode myCloseCommand( const myFileCommandOptions *options, void *data ) {
printf( "number of files is %d\\n", ((MyFileData *)data)->numberOfFiles );
free( data );
return commandOk;
}
.
END
;
testMake( "compile changed myFileCommand.command.c" );
testCommand( 'myFileCommand myFileCommand.specification.c myFileCommand.command.c',
'grep /probe: first file/',
'grep /probe: second file/',
'grep /myFileCommand.specification.c:/',
'grep /myFileCommand.command.c:/',
'grep /number of files is 2/',
);
#-------------------------------------------------------------------#
# suddenly a "(null)" has been generated for shortDescription. Bad! #
#-------------------------------------------------------------------#
testFile( "temporary/myFileCommand.texinfo",
'!grep /\(null\)/'
);
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking webifying ..." );
#--------------------------------------------------------------------------------------------------#
open( webifyExtensionBash, ">packageSpecificWebify" );
print webifyExtensionBash <<endOfwebifyExtensionBash
echo \"High Du!\" > \$web/jk.txt
endOfwebifyExtensionBash
;
close( webifyExtensionBash );
testMake( "test packageSpecificWebify", "web" );
testFile( "distribution/documentation/web/jk.txt",
'grep /High Du!/'
);
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking publishing ..." );
#--------------------------------------------------------------------------------------------------#
$publishHost = 'localhost';
$publishArchive = $testWorkingDirectory . '/temporary/publish/archive';
$publishWeb = $testWorkingDirectory . '/temporary/publish/web';
`mkdir --parents $publishArchive $publishWeb`;
$ENV{ 'siliconBrain_publishTargetHost' } = $publishHost;
$ENV{ 'siliconBrain_publishTargetArchive' } = $publishArchive;
$ENV{ 'siliconBrain_publishTargetWeb' } = $publishWeb;
`siliconBrain.configurationReader -- --bash > sb.cfg`;
testMake( "test publishing", "public" );
@archiveFiles = glob( "$publishArchive/*.tar.gz" );
testAssert( "\$#archiveFiles != -1" );
testAssert( '-x "siliconBrainInstall"' );
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking downloading ..." );
#--------------------------------------------------------------------------------------------------#
eval `siliconBrainPackageName=myProject createReleaseInformation --perl`;
`mkdir --parents temporary/download`;
chdir 'temporary/download';
open ftp, "|ftp $publishHost 1> /dev/null 2> /dev/null";
print ftp "prompt\n";
print ftp "bin\n";
print ftp "cd $publishArchive\n";
print ftp "get $releaseArchive\n";
print ftp "quit\n";
close ftp;
`tar --extract --ungzip --file=$releaseArchive`;
testAssert( '-d "$releasePackageName"' );
#--------------------------------------------------------------------------------------------------#
testPrint( "Checking installation ..." );
#--------------------------------------------------------------------------------------------------#
chdir "$releasePackageName";
`mkdir --parents $testWorkingDirectory/temporary/install`;
`./siliconBrainInstall $testWorkingDirectory/temporary/install myProject 1> /dev/null 2> /dev/null`;
$installationDirectory = "$testWorkingDirectory/temporary/install/myProject";
testAssert( '-x "$installationDirectory/programs/myCommand"' );
#--------------------------------------------------------------------------------------------------#
testPrint( "End (of this part off test)\n" );
#--------------------------------------------------------------------------------------------------#
exit 0;
# $Log: newTest.perl,v $
# Revision 1.49 2004/12/14 23:31:26 joerg
# published for new release 0.2.3
#
# Revision 1.48 2004/12/14 23:17:05 joerg
# published for new release 0.2.2
#
# Revision 1.47 2004/12/14 22:20:09 joerg
# pipe output of make command into stringSearch c-function
# without creating a process for stringSearch. The later is used as a C-function command, not as a main.
#
# Revision 1.46 2004/12/02 22:45:23 joerg
# Correct and test error when last character of needel apears somewhere else in needle additionally.
# And prepare (already test) for buffer spanning expresions.
#