Skip to content
Permalink
Browse files

Add stubs for methods from class being tested automatically

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5234 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux
timlinux committed Apr 9, 2006
1 parent e347705 commit 13b458617986bb7ed3bede13fde23e15300fbb0e
Showing with 22 additions and 5 deletions.
  1. +22 −5 tests/src/core/test_builder.pl
@@ -29,6 +29,27 @@
$testClass =<STDIN>;
chop $testClass;
$testClassLowerCaseName = lc($testClass); #todo convert to lower case
print "Stubs will be created for the following methods:\n";
open CPPFILE, "<../../../src/core/$testClassLowerCaseName.cpp"|| die 'Unable to open header file $testClassLowerCaseName.cpp';
$stubString="";
while(<CPPFILE>)
{
if(m/${testClass}::[A-Za-z0-9]*\(/)
{
#get the matched part of the line
$line = $&;
#strip off the ::
$line =~ s/:://g;
#strip off the (
$line =~ s/\(//g;
#add it to our stub code
$stubString = $stubString . " void $line()\n\(\n\n\)\n";
#show the user the list
print $line;
}
}
print $stubString;
print "-----------------------------\n";
print "Create the unit test? [y/n]: ";
$createIt = <STDIN>;
chop $createIt;
@@ -43,11 +64,7 @@
# Substitute the class name in the file
system("perl -pi -e 's/\\\[testClassLowerCaseName\\\]/$testClassLowerCaseName/g' test$testClassLowerCaseName.cpp");
system("perl -pi -e 's/\\\[testClassCamelCaseName\\\]/$testClass/g' test$testClassLowerCaseName.cpp");
#
# TODO: write a parser to pull out method signatures from class bing tested and create a stub
# for each method in the generated test class to replace teh [TestMethods] placeholder
#

system("perl -pi -e 's/\\\[TestMethods\\\]/$stubString/g' test$testClassLowerCaseName.cpp");
# Add an entry to Makefile.am
open MAKEFILE, "<./Makefile.am" || die 'Unable to open Makefile.am';
open MAKEFILEMOD, ">./Makefile.am.mod" || die 'Unable to create Makefile.am.mod';

0 comments on commit 13b4586

Please sign in to comment.
You can’t perform that action at this time.