Title: [103609] trunk/Tools
- Revision
- 103609
- Author
- [email protected]
- Date
- 2011-12-23 00:18:51 -0800 (Fri, 23 Dec 2011)
Log Message
Let parser_unittests.pl call different language parsers
https://bugs.webkit.org/show_bug.cgi?id=75081
Reviewed by David Kilzer.
We introduced parser_unittests.pl in bug 74994 , but it is implemented
to always call get_function_line_ranges_for_perl(). In order to enable unittests
for other languages, this patch lets parser_unittests.pl call different language
parsers depending on the languages.
Test: Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests.pl
* Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl:
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (103608 => 103609)
--- trunk/Tools/ChangeLog 2011-12-23 07:29:32 UTC (rev 103608)
+++ trunk/Tools/ChangeLog 2011-12-23 08:18:51 UTC (rev 103609)
@@ -1,3 +1,19 @@
+2011-12-23 Kentaro Hara <[email protected]>
+
+ Let parser_unittests.pl call different language parsers
+ https://bugs.webkit.org/show_bug.cgi?id=75081
+
+ Reviewed by David Kilzer.
+
+ We introduced parser_unittests.pl in bug 74994 , but it is implemented
+ to always call get_function_line_ranges_for_perl(). In order to enable unittests
+ for other languages, this patch lets parser_unittests.pl call different language
+ parsers depending on the languages.
+
+ Test: Scripts/webkitperl/prepare-ChangeLog_unittest/resources/perl_unittests.pl
+
+ * Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl:
+
2011-12-22 Adam Roben <[email protected]>
Snow Leopard test fix
Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl (103608 => 103609)
--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl 2011-12-23 07:29:32 UTC (rev 103608)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl 2011-12-23 08:18:51 UTC (rev 103609)
@@ -32,35 +32,38 @@
use lib File::Spec->catdir($FindBin::Bin, "..");
use LoadAsModule qw(PrepareChangeLog prepare-ChangeLog);
-my @testFiles = qw(perl_unittests.pl);
+my %testFiles = ("perl_unittests.pl" => "perl");
-my @inputFiles = map { File::Spec->catdir($FindBin::Bin, "resources", $_) } @testFiles;
-my @expectedFiles = map { s/^(.*)\.[^\.]*$/$1/; File::Spec->catdir($FindBin::Bin, "resources", $_ . "-expected.txt") } @testFiles;
-
my $resetResults;
GetOptions('reset-results' => \$resetResults);
-my $testCount = @testFiles;
-plan(tests => $testCount);
-for (my $index = 0; $index < $testCount; $index++) {
- my $inputFile = $inputFiles[$index];
- my $expectedFile = $expectedFiles[$index];
+my @testSet;
+foreach my $testFile (sort keys %testFiles) {
+ my $basename = $testFile;
+ $basename = $1 if $basename =~ /^(.*)\.[^\.]*$/;
+ push @testSet, {language => $testFiles{$testFile},
+ inputFile => File::Spec->catdir($FindBin::Bin, "resources", $testFile),
+ expectedFile => File::Spec->catdir($FindBin::Bin, "resources", $basename . "-expected.txt")};
+}
- open FH, "< $inputFile" or die "Cannot open $inputFile: $!";
- my @actualOutput = PrepareChangeLog::get_function_line_ranges_for_perl(\*FH, $inputFile);
+plan(tests => scalar @testSet);
+foreach my $test (@testSet) {
+ open FH, "< $test->{inputFile}" or die "Cannot open $test->{inputFile}: $!";
+ my $parser = eval "\\&PrepareChangeLog::get_function_line_ranges_for_$test->{language}";
+ my @actualOutput = $parser->(\*FH, $test->{inputFile});;
close FH;
if ($resetResults) {
- open FH, "> $expectedFile" or die "Cannot open $expectedFile: $!";
+ open FH, "> $test->{expectedFile}" or die "Cannot open $test->{expectedFile}: $!";
print FH Data::Dumper->new([\@actualOutput])->Terse(1)->Indent(1)->Dump();
close FH;
next;
}
- open FH, "< $expectedFile" or die "Cannot open $expectedFile: $!";
+ open FH, "< $test->{expectedFile}" or die "Cannot open $test->{expectedFile}: $!";
local $/ = undef;
my $expectedOutput = eval <FH>;
close FH;
- is_deeply(\@actualOutput, $expectedOutput, "Tests $inputFile");
+ is_deeply(\@actualOutput, $expectedOutput, "Tests $test->{inputFile}");
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes