- Revision
- 103667
- Author
- hara...@chromium.org
- Date
- 2011-12-25 00:09:36 -0800 (Sun, 25 Dec 2011)
Log Message
Add unittests for the Python parser of prepare-ChangeLog
https://bugs.webkit.org/show_bug.cgi?id=75197
Reviewed by Ryosuke Niwa.
python_unittests.py is the unittest for get_function_line_ranges_for_python()
of prepare-ChangeLog. The unittest just contains classes and defs that are not nested.
This is because the current python parser is wrong, and it cannot correctly parse nested
classes and defs (even one def in a class), nor class inheritance.
We will fix it in another patch.
* Scripts/prepare-ChangeLog:
(get_function_line_ranges_for_python): Ignores comment lines that starts from #.
* Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl:
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests-expected.txt: Added.
* Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests.py: Added.
(func1):
(func2):
(func3):
(funcInsideComment):
(func4):
(func5):
(func6):
(funcOverloaded):
(Class1):
Modified Paths
Added Paths
Diff
Modified: trunk/Tools/ChangeLog (103666 => 103667)
--- trunk/Tools/ChangeLog 2011-12-25 01:09:56 UTC (rev 103666)
+++ trunk/Tools/ChangeLog 2011-12-25 08:09:36 UTC (rev 103667)
@@ -1,3 +1,31 @@
+2011-12-24 Kentaro Hara <hara...@chromium.org>
+
+ Add unittests for the Python parser of prepare-ChangeLog
+ https://bugs.webkit.org/show_bug.cgi?id=75197
+
+ Reviewed by Ryosuke Niwa.
+
+ python_unittests.py is the unittest for get_function_line_ranges_for_python()
+ of prepare-ChangeLog. The unittest just contains classes and defs that are not nested.
+ This is because the current python parser is wrong, and it cannot correctly parse nested
+ classes and defs (even one def in a class), nor class inheritance.
+ We will fix it in another patch.
+
+ * Scripts/prepare-ChangeLog:
+ (get_function_line_ranges_for_python): Ignores comment lines that starts from #.
+ * Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl:
+ * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests-expected.txt: Added.
+ * Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests.py: Added.
+ (func1):
+ (func2):
+ (func3):
+ (funcInsideComment):
+ (func4):
+ (func5):
+ (func6):
+ (funcOverloaded):
+ (Class1):
+
2011-12-24 Dan Bernstein <m...@apple.com>
Set SHARED_PRECOMPS_DIR when Xcode is set to use a custom build product path.
Modified: trunk/Tools/Scripts/prepare-ChangeLog (103666 => 103667)
--- trunk/Tools/Scripts/prepare-ChangeLog 2011-12-25 01:09:56 UTC (rev 103666)
+++ trunk/Tools/Scripts/prepare-ChangeLog 2011-12-25 08:09:36 UTC (rev 103667)
@@ -1319,7 +1319,7 @@
my @scopeStack = ({ line => 0, indent => -1, name => undef });
while (<$fileHandle>) {
- next unless /^(\s*)(\S.*)$/;
+ next unless /^(\s*)([^#].*)$/;
my $indent = length $1;
my $rest = $2;
Modified: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl (103666 => 103667)
--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl 2011-12-25 01:09:56 UTC (rev 103666)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/parser_unittests.pl 2011-12-25 08:09:36 UTC (rev 103667)
@@ -32,7 +32,8 @@
use lib File::Spec->catdir($FindBin::Bin, "..");
use LoadAsModule qw(PrepareChangeLog prepare-ChangeLog);
-my %testFiles = ("perl_unittests.pl" => "perl");
+my %testFiles = ("perl_unittests.pl" => "perl",
+ "python_unittests.py" => "python");
my $resetResults;
GetOptions('reset-results' => \$resetResults);
Added: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests-expected.txt (0 => 103667)
--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests-expected.txt (rev 0)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests-expected.txt 2011-12-25 08:09:36 UTC (rev 103667)
@@ -0,0 +1,52 @@
+[
+ [
+ '21',
+ '21',
+ 'func1'
+ ],
+ [
+ '24',
+ '25',
+ 'func2'
+ ],
+ [
+ '28',
+ '30',
+ 'func3'
+ ],
+ [
+ '35',
+ '36',
+ 'func4'
+ ],
+ [
+ '39',
+ '40',
+ 'func5'
+ ],
+ [
+ '43',
+ '45',
+ 'func6'
+ ],
+ [
+ '48',
+ '49',
+ 'funcOverloaded'
+ ],
+ [
+ '52',
+ '53',
+ 'funcOverloaded'
+ ],
+ [
+ '56',
+ '57',
+ 'funcOverloaded'
+ ],
+ [
+ '60',
+ '61',
+ 'Class1'
+ ]
+]
Added: trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests.py (0 => 103667)
--- trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests.py (rev 0)
+++ trunk/Tools/Scripts/webkitperl/prepare-ChangeLog_unittest/resources/python_unittests.py 2011-12-25 08:09:36 UTC (rev 103667)
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2011 Google Inc. All rights reserved.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with this library; see the file COPYING.LIB. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+#
+
+
+def func1():
+
+
+def func2():
+ return
+
+
+def func3():
+ # comment
+ return
+
+# def funcInsideComment():
+
+
+def func4(a):
+ return
+
+
+def func5(a, b, c):
+ return
+
+
+def func6(a, b, \
+ c, d):
+ return
+
+
+def funcOverloaded(a):
+ return
+
+
+def funcOverloaded(a, b):
+ return
+
+
+def funcOverloaded(a, b, c=100):
+ return
+
+
+class Class1:
+ pass
+