Bug 34574 - check-webkit-style should ignore underscore in Qt autotests
Summary: check-webkit-style should ignore underscore in Qt autotests
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Chris Jerdonek
URL:
Keywords:
Depends on: 33684
Blocks:
  Show dependency treegraph
 
Reported: 2010-02-04 04:47 PST by Jędrzej Nowacki
Modified: 2010-12-22 05:53 PST (History)
8 users (show)

See Also:


Attachments
Proposed patch (9.62 KB, patch)
2010-02-05 22:08 PST, Chris Jerdonek
no flags Details | Formatted Diff | Diff
Proposed patch 2 (9.64 KB, patch)
2010-02-05 22:16 PST, Chris Jerdonek
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jędrzej Nowacki 2010-02-04 04:47:03 PST
I believe that check-webkit-style should ignore "Don't use underscores in your identifier names.  [readability/naming] [4]" rule inside Qt's autotests. There is no clean way to avoid a xxx_data methods as they are called automatically by the QtTest Module.

Please ignore the rule inside these sub-folders:
Webkit/qt/tests
JavaScriptCore/qt/tests
Comment 1 Chris Jerdonek 2010-02-05 22:08:50 PST
Created attachment 48286 [details]
Proposed patch
Comment 2 Chris Jerdonek 2010-02-05 22:16:05 PST
Created attachment 48287 [details]
Proposed patch 2

Minor fixes to ChangeLog and a code comment.
Comment 3 Shinichiro Hamaji 2010-02-07 20:48:55 PST
Adding Gustavo in CC list.

My comment about GTK+ isn't related to this bug. Please feel free to land this patch as is (or you may want to modify the list-comprehension), and I'll open another bug to decide path-rules for GTK+.

> @@ -98,6 +106,15 @@ _PATH_RULES_SPECIFIER = [
>        "WebKit/qt/QGVLauncher/"],
>       ("-build/include",
>        "-readability/streams")),
> +    ([# The GTK+ APIs use GTK+ naming style, which includes
> +      # lower-cased, underscore-separated values.
> +      "WebKit/gtk/webkit/",
> +      # There is no clean way to avoid "xxx_data" methods inside
> +      # Qt's autotests since they are called automatically by the
> +      # QtTest module.
> +      "WebKit/qt/tests/",
> +      "JavaScriptCore/qt/tests"],
> +     ("-readability/naming",)),
>      # These are test file patterns.
>      (["_test.cpp",
>        "_unittest.cpp",

Per discussion in Bug 34572, we need to add WebKitTools/DumpRenderTree/gtk. I guess gtk code doesn't care build/include_order (#includes should be alphabetically sorted) and readability/null (don't use NULL, use 0 instead) as well. So, I'd propose

    ([# The GTK+ APIs use GTK+ naming style, which includes
      # lower-cased, underscore-separated values.
      # GTK+ code uses NULL and unsorted #includes, too.
      "WebKit/gtk/webkit/",
      "WebKitTools/DumpRenderTree/gtk",],
     ("-build/include_order",
      "-readability/naming",
      "-readability/null")),
    ([# There is no clean way to avoid "xxx_data" methods inside
      # Qt's autotests since they are called automatically by the
      # QtTest module.
      "WebKit/qt/tests/",
      "JavaScriptCore/qt/tests"],
     ("-readability/naming",)),

or something like this. Gustavo, could you check my guess is correct?

> +    def _get_path_specific_lower(self):
> +        """Return a copy of self._path_specific with the paths lower-cased."""
> +        if self._path_specific_lower is None:
> +            self._path_specific_lower = []
> +            for (sub_paths, path_rules) in self._path_specific:
> +                sub_paths = [sub_path.lower() for sub_path in sub_paths]

Though this is fine as is, I think there's a bit simpler way:

sub_paths = map(str.lower, sub_paths)
Comment 4 Shinichiro Hamaji 2010-02-07 20:52:40 PST
Probably, for gtk, we may want to disable whitespace/declaration as well? See the review bot's comment in Bug 32170.
Comment 5 Chris Jerdonek 2010-02-08 05:16:31 PST
Comment on attachment 48287 [details]
Proposed patch 2

cq- to use webkit-patch
Comment 6 Chris Jerdonek 2010-02-08 05:28:35 PST
Manually committed (via "git svn dcommit"):

http://trac.webkit.org/changeset/54482
Comment 7 Adam Barth 2010-02-08 08:41:53 PST
any particular reason you removed

- self.assert_lint('void this_is_a_gtk_style_name(int var1, int var2)', '', 'WebKit/gtk/webkit/foo.cpp')

?  Seems like a good test to have...
Comment 8 Chris Jerdonek 2010-02-08 09:30:39 PST
(In reply to comment #7)
> any particular reason you removed
> 
> - self.assert_lint('void this_is_a_gtk_style_name(int var1, int var2)', '',
> 'WebKit/gtk/webkit/foo.cpp')
> 
> ?  Seems like a good test to have...

Yes.  I removed it because cpp.py is no longer responsible for checking that file path. All of that is now encoded by the _PATH_RULES_SPECIFIER configuration variable and taken care of by the FilterConfiguration class.

I had a similar discussion with Shinichiro at the end of this comment

https://bugs.webkit.org/show_bug.cgi?id=33684#c19

after removing similar hard-coded directory names from cpp.py and their corresponding unit tests.

Testing like the above can now go in the GlobalVariablesTest.test_path_rules_specifier() unit test method.  That method is responsible for checking that the _PATH_RULES_SPECIFIER variable is functioning as expected.

I suppose I could have added another assert to that method for a gtk file path, but there is already an assert in there for a qt file path that tests the same exemption:

>        self.assertFalse(config.should_check("readability/naming",
>                             "WebKit/qt/tests/qwebelement/tst_qwebelement.cpp"))

The exemption is encoded here:

>    ([# The GTK+ APIs use GTK+ naming style, which includes
>      # lower-cased, underscore-separated values.
>      "WebKit/gtk/webkit/",
>      # There is no clean way to avoid "xxx_data" methods inside
>      # Qt's autotests since they are called automatically by the
>      # QtTest module.
>      "WebKit/qt/tests/",
>      "JavaScriptCore/qt/tests"],
>     ["-readability/naming"]),
Comment 9 Chris Jerdonek 2010-02-08 10:18:59 PST
(In reply to comment #8)
> I suppose I could have added another assert to that method for a gtk file path,
> but there is already an assert in there for a qt file path that tests the same
> exemption:
> 
> >        self.assertFalse(config.should_check("readability/naming",
> >                             "WebKit/qt/tests/qwebelement/tst_qwebelement.cpp"))

I do think it makes sense to have at least one assert per string that appears in _PATH_RULES_SPECIFIER (to have complete code coverage and avoid typos, etc).  I will do that the next time I modify this area of code.
Comment 10 Chris Jerdonek 2010-02-16 22:53:55 PST
(In reply to comment #7)
> any particular reason you removed
> 
> - self.assert_lint('void this_is_a_gtk_style_name(int var1, int var2)', '',
> 'WebKit/gtk/webkit/foo.cpp')
> 
> ?  Seems like a good test to have...

FYI, as I mentioned in comment 9 of this report, I restored the unit test for a "WebKit/gtk/webkit/" path in the proposed patches of this report:

https://bugs.webkit.org/show_bug.cgi?id=34932

I also added a unit test for every other path that appears in the _PATH_RULES_SPECIFIER configuration variable.
Comment 11 Jędrzej Nowacki 2010-06-23 04:15:29 PDT
It seems that the problem is still valid. Please look at bug 40911.
Comment 12 Eric Seidel (no email) 2010-12-20 22:28:06 PST
This bug has been waiting to land for 6 months?  Or did it get landed already?
Comment 13 Adam Barth 2010-12-20 23:38:39 PST
Sadly, cjerdonek seems to have moved on to geener pastures.
Comment 14 Shinichiro Hamaji 2010-12-21 04:25:36 PST
I think there are no reason we cannot land this patch. I guess Chris put cq- just because this requires Bug 33684 closed. As the patch for Bug 33684 seems to be landed already, I think we should be able to land this patch. I'll try.
Comment 15 Shinichiro Hamaji 2010-12-22 05:43:00 PST
Comment on attachment 48287 [details]
Proposed patch 2

(In reply to comment #14)
> I think there are no reason we cannot land this patch. I guess Chris put cq- just because this requires Bug 33684 closed. As the patch for Bug 33684 seems to be landed already, I think we should be able to land this patch. I'll try.

Actually, this patch has already been landed: http://trac.webkit.org/changeset/54482

The false-positives in Bug 40911 happened because we don't have qt/benchmark in the exemption list.
Comment 16 Shinichiro Hamaji 2010-12-22 05:53:55 PST
Filed Bug 51467.