Title: [103338] trunk/Tools
Revision
103338
Author
[email protected]
Date
2011-12-20 09:40:33 -0800 (Tue, 20 Dec 2011)

Log Message

Replace webkitperl/run-leaks_unittest/RunLeaks.pm with webkitperl/LoadAsModule.pm
https://bugs.webkit.org/show_bug.cgi?id=74836

Reviewed by David Kilzer.

webkitperl/run-leaks_unittest/RunLeaks.pm can be used for unit-testing of run-leaks only.
This patch creates more generalized webkitperl/LoadAsModule.pm, which can be also used
for unit-testing of other Perl scripts. We are planning to use it for unit-testing
of prepare-ChangeLog.

Using LoadAsModule.pm, you can load a Perl script as follows.
The first argument is the arbitrary package name you want to use, and the second argument
is the name of the Perl script you want to load.

    use LoadAsModule qw(RunLeaks run-leaks);
    RunLeaks::someFunctionDefinedInRunLeaks(...);

Tests: Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v1.0.pl
       Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-new.pl
       Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-old.pl

* Scripts/webkitperl/LoadAsModule.pm: Added.
* Scripts/webkitperl/run-leaks_unittest/RunLeaks.pm: Removed.
(import):
(readFile):
* Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v1.0.pl: Used LoadAsModule instead of RunLeaks.
* 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.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Tools/ChangeLog (103337 => 103338)


--- trunk/Tools/ChangeLog	2011-12-20 17:31:39 UTC (rev 103337)
+++ trunk/Tools/ChangeLog	2011-12-20 17:40:33 UTC (rev 103338)
@@ -1,3 +1,34 @@
+2011-12-20  Kentaro Hara  <[email protected]>
+
+        Replace webkitperl/run-leaks_unittest/RunLeaks.pm with webkitperl/LoadAsModule.pm
+        https://bugs.webkit.org/show_bug.cgi?id=74836
+
+        Reviewed by David Kilzer.
+
+        webkitperl/run-leaks_unittest/RunLeaks.pm can be used for unit-testing of run-leaks only.
+        This patch creates more generalized webkitperl/LoadAsModule.pm, which can be also used
+        for unit-testing of other Perl scripts. We are planning to use it for unit-testing
+        of prepare-ChangeLog.
+
+        Using LoadAsModule.pm, you can load a Perl script as follows.
+        The first argument is the arbitrary package name you want to use, and the second argument
+        is the name of the Perl script you want to load.
+
+            use LoadAsModule qw(RunLeaks run-leaks);
+            RunLeaks::someFunctionDefinedInRunLeaks(...);
+
+        Tests: Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v1.0.pl
+               Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-new.pl
+               Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-old.pl
+
+        * Scripts/webkitperl/LoadAsModule.pm: Added.
+        * Scripts/webkitperl/run-leaks_unittest/RunLeaks.pm: Removed.
+        (import):
+        (readFile):
+        * Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v1.0.pl: Used LoadAsModule instead of RunLeaks.
+        * 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-12-20  Balazs Kelemen  <[email protected]>
 
         [Qt] WK2 Debugging quirks need some improvement

Copied: trunk/Tools/Scripts/webkitperl/LoadAsModule.pm (from rev 103337, trunk/Tools/Scripts/webkitperl/run-leaks_unittest/RunLeaks.pm) (0 => 103338)


--- trunk/Tools/Scripts/webkitperl/LoadAsModule.pm	                        (rev 0)
+++ trunk/Tools/Scripts/webkitperl/LoadAsModule.pm	2011-12-20 17:40:33 UTC (rev 103338)
@@ -0,0 +1,80 @@
+#!/usr/bin/perl -w
+#
+# Copyright (C) 2011 Apple Inc. All rights reserved.
+# Copyright (C) 2011 Google 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 Perl scripts into a package for easy unit testing.
+
+package LoadAsModule;
+
+use strict;
+use warnings;
+
+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($);
+
+sub import
+{
+    my ($self, $package, $script) = @_;
+    my $scriptPath = File::Spec->catfile(sourceDir(), "Tools", "Scripts", $script);
+    eval "
+        package $package;
+
+        use strict;
+        use warnings;
+
+        use base 'Exporter';
+        use vars qw(\@EXPORT \@EXPORT_OK \%EXPORT_TAGS \$VERSION);
+
+        \@EXPORT = ();
+        \@EXPORT_OK = ();
+        \%EXPORT_TAGS = ();
+        \$VERSION = '1.0';
+
+        sub {" . readFile($scriptPath) . "}
+    ";
+}
+
+sub readFile($)
+{
+    my $path = shift;
+    local $/ = undef; # Read in the whole file at once.
+    open FILE, "<", $path or die "Cannot open $path: $!";
+    my $contents = <FILE>;
+    close FILE;
+    return $contents;
+};
+
+1;

Deleted: trunk/Tools/Scripts/webkitperl/run-leaks_unittest/RunLeaks.pm (103337 => 103338)


--- trunk/Tools/Scripts/webkitperl/run-leaks_unittest/RunLeaks.pm	2011-12-20 17:31:39 UTC (rev 103337)
+++ trunk/Tools/Scripts/webkitperl/run-leaks_unittest/RunLeaks.pm	2011-12-20 17:40:33 UTC (rev 103338)
@@ -1,59 +0,0 @@
-#!/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 (103337 => 103338)


--- trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v1.0.pl	2011-12-20 17:31:39 UTC (rev 103337)
+++ trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v1.0.pl	2011-12-20 17:40:33 UTC (rev 103338)
@@ -27,10 +27,11 @@
 use strict;
 use warnings;
 
+use File::Spec;
 use FindBin;
-use lib $FindBin::Bin;
-use RunLeaks;
+use lib File::Spec->catdir($FindBin::Bin, "..");
 use Test::More;
+use LoadAsModule qw(RunLeaks run-leaks);
 
 my @input = split(/\n/, <<EOF);
 Process 1602: 86671 nodes malloced for 13261 KB

Modified: trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-new.pl (103337 => 103338)


--- trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-new.pl	2011-12-20 17:31:39 UTC (rev 103337)
+++ trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-new.pl	2011-12-20 17:40:33 UTC (rev 103338)
@@ -28,10 +28,11 @@
 use strict;
 use warnings;
 
+use File::Spec;
 use FindBin;
-use lib $FindBin::Bin;
-use RunLeaks;
+use lib File::Spec->catdir($FindBin::Bin, "..");
 use Test::More;
+use LoadAsModule qw(RunLeaks run-leaks);
 
 my @input = split(/\n/, <<EOF);
 Process:         DumpRenderTree [29903]
@@ -122,4 +123,4 @@
 my $actualOutput = RunLeaks::parseLeaksOutput(@input);
 
 plan(tests => 1);
-is_deeply($actualOutput, $expectedOutput, "leaks Report Version 2.0 (old)");
+is_deeply($actualOutput, $expectedOutput, "leaks Report Version 2.0 (new)");

Modified: trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-old.pl (103337 => 103338)


--- trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-old.pl	2011-12-20 17:31:39 UTC (rev 103337)
+++ trunk/Tools/Scripts/webkitperl/run-leaks_unittest/run-leaks-report-v2.0-old.pl	2011-12-20 17:40:33 UTC (rev 103338)
@@ -28,10 +28,11 @@
 use strict;
 use warnings;
 
+use File::Spec;
 use FindBin;
-use lib $FindBin::Bin;
-use RunLeaks;
+use lib File::Spec->catdir($FindBin::Bin, "..");
 use Test::More;
+use LoadAsModule qw(RunLeaks run-leaks);
 
 my @input = split(/\n/, <<EOF);
 leaks Report Version:  2.0
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to