Diff
Modified: trunk/Tools/ChangeLog (100286 => 100287)
--- trunk/Tools/ChangeLog 2011-11-15 16:37:58 UTC (rev 100286)
+++ trunk/Tools/ChangeLog 2011-11-15 17:25:51 UTC (rev 100287)
@@ -1,3 +1,17 @@
+2011-11-15 David Kilzer <ddkil...@apple.com>
+
+ Don't use File::Slurp for run-leaks unit tests
+ <http://webkit.org/b/72356>
+
+ Reviewed by Daniel Bates.
+
+ * Scripts/webkitperl/run-leaks_unittest/RunLeaks.pm: Added.
+ * Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v1.0.pl:
+ Extracted common package logic into RunLeaks.pm. Fixed call to
+ RunLeaks::parseLeaksOutput().
+ * Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-new.pl: Ditto.
+ * Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-old.pl: Ditto.
+
2011-11-15 Peter Kasting <pkast...@google.com>
Handle svn 1.7 when detecting whether a directory is in an svn checkout.
Added: trunk/Tools/Scripts/webkitperl/run-leaks_unittest/RunLeaks.pm (0 => 100287)
--- trunk/Tools/Scripts/webkitperl/run-leaks_unittest/RunLeaks.pm (rev 0)
+++ trunk/Tools/Scripts/webkitperl/run-leaks_unittest/RunLeaks.pm 2011-11-15 17:25:51 UTC (rev 100287)
@@ -0,0 +1,59 @@
+#!/usr/bin/perl -w
+
+# Copyright (C) 2011 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Imports run-leaks into a package for easy unit testing.
+
+package RunLeaks;
+
+use strict;
+use warnings;
+
+use English;
+use File::Spec;
+use FindBin;
+use lib File::Spec->catdir($FindBin::Bin, "..", "..");
+use webkitdirs;
+
+use base 'Exporter' ;
+use vars qw( @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION ) ;
+
+@EXPORT = ();
+@EXPORT_OK = ();
+%EXPORT_TAGS = ();
+$VERSION = '1.0';
+
+sub readFile($);
+
+my $runLeaksPath = File::Spec->catfile(sourceDir(), "Tools", "Scripts", "run-leaks");
+eval "sub {" . readFile($runLeaksPath) . "}";
+
+sub readFile($) {
+ local $INPUT_RECORD_SEPARATOR = undef; # Read in the whole file at once.
+ open FILE, "<", shift || die $!;
+ my $contents = <FILE>;
+ close FILE || die $!;
+ return $contents;
+};
+
+1;
Modified: trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v1.0.pl (100286 => 100287)
--- trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v1.0.pl 2011-11-15 16:37:58 UTC (rev 100286)
+++ trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v1.0.pl 2011-11-15 17:25:51 UTC (rev 100287)
@@ -25,16 +25,13 @@
# tests run-leaks using original leaks report version 1.0
use strict;
-use diagnostics;
use warnings;
-use File::Slurp qw(read_file);
-use File::Spec;
use FindBin;
+use lib $FindBin::Bin;
+use RunLeaks;
use Test::More;
-eval "package RunLeaks; sub {" . read_file(File::Spec->catfile($FindBin::Bin, "..", "..", "run-leaks")) . "}";
-
my @input = split(/\n/, <<EOF);
Process 1602: 86671 nodes malloced for 13261 KB
Process 1602: 8 leaks for 160 total leaked bytes.
@@ -158,7 +155,7 @@
},
];
-my $actualOutput = RunLeaks::parseLeaksOutput(\@input);
+my $actualOutput = RunLeaks::parseLeaksOutput(@input);
plan(tests => 1);
is_deeply($actualOutput, $expectedOutput, "leaks Report Version 1.0 - no call stack");
Modified: trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-new.pl (100286 => 100287)
--- trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-new.pl 2011-11-15 16:37:58 UTC (rev 100286)
+++ trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-new.pl 2011-11-15 17:25:51 UTC (rev 100287)
@@ -26,16 +26,13 @@
# - The "new" 2.0 format has "leaks Report Version: 2.0" after the two header sections.
use strict;
-use diagnostics;
use warnings;
-use File::Slurp qw(read_file);
-use File::Spec;
use FindBin;
+use lib $FindBin::Bin;
+use RunLeaks;
use Test::More;
-eval "package RunLeaks; sub {" . read_file(File::Spec->catfile($FindBin::Bin, "..", "..", "run-leaks")) . "}";
-
my @input = split(/\n/, <<EOF);
Process: DumpRenderTree [29903]
Path: /Volumes/Data/Build/Debug/DumpRenderTree
@@ -122,7 +119,7 @@
},
];
-my $actualOutput = RunLeaks::parseLeaksOutput(\@input);
+my $actualOutput = RunLeaks::parseLeaksOutput(@input);
plan(tests => 1);
is_deeply($actualOutput, $expectedOutput, "leaks Report Version 2.0 (old)");
Modified: trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-old.pl (100286 => 100287)
--- trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-old.pl 2011-11-15 16:37:58 UTC (rev 100286)
+++ trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-old.pl 2011-11-15 17:25:51 UTC (rev 100287)
@@ -26,16 +26,13 @@
# - The "old" 2.0 format has "leaks Report Version: 2.0" at the top of the report.
use strict;
-use diagnostics;
use warnings;
-use File::Slurp qw(read_file);
-use File::Spec;
use FindBin;
+use lib $FindBin::Bin;
+use RunLeaks;
use Test::More;
-eval "package RunLeaks; sub {" . read_file(File::Spec->catfile($FindBin::Bin, "..", "..", "run-leaks")) . "}";
-
my @input = split(/\n/, <<EOF);
leaks Report Version: 2.0
Process: Safari [53606]
@@ -72,7 +69,7 @@
},
];
-my $actualOutput = RunLeaks::parseLeaksOutput(\@input);
+my $actualOutput = RunLeaks::parseLeaksOutput(@input);
plan(tests => 1);
is_deeply($actualOutput, $expectedOutput, "leaks Report Version 2.0 (old)");