Bug 27549 - Make run-webkit-lint supports files as arguments
Summary: Make run-webkit-lint supports files as arguments
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Minor
Assignee: Kenneth Rohde Christiansen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-22 11:19 PDT by Kenneth Rohde Christiansen
Modified: 2009-07-29 08:14 PDT (History)
2 users (show)

See Also:


Attachments
Make run-webkit-lint supports files as arguments (2.62 KB, patch)
2009-07-22 11:22 PDT, Kenneth Rohde Christiansen
levin: review-
Details | Formatted Diff | Diff
Updates and improved patch (4.75 KB, patch)
2009-07-29 06:03 PDT, Kenneth Rohde Christiansen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kenneth Rohde Christiansen 2009-07-22 11:19:09 PDT
Make run-webkit-lint supports files as arguments so that we dont need to call
python WebKitTools/Scripts/modules/cpplint.py on individual files.

Patch coming up.
Comment 1 Kenneth Rohde Christiansen 2009-07-22 11:22:13 PDT
Created attachment 33274 [details]
Make run-webkit-lint supports files as arguments
Comment 2 David Levin 2009-07-23 09:03:37 PDT
Comment on attachment 33274 [details]
Make run-webkit-lint supports files as arguments

Thanks for the patch.  This is a nice addition.

Just a few things to address at the moment.

Well, first off, sorry, I changed the name of the tool on you. So if you would switch the patch over to check-webkit-style, that would be excellent.

fwiw, you don't need to request me as the reviewer - Adam has been also reviewing these and doing a great job (The funny thing is that it delayed your review because I typically scan the general queue -- not used to being asked for by name). cc'ing me did get my attention though :)


> diff --git a/WebKitTools/Scripts/run-webkit-lint b/WebKitTools/Scripts/run-webkit-lint

Please fix up "cpplint._USAGE" to reflect the fact that you may optionally pass in files.

What should happen if the user passes in --git-commit and files?  (Personally I recommend something simple like an error message that you need to choose one or the other.)

> +    if not filenames:
> +        cwd = os.path.abspath('.')
> +        scm = detect_scm_system(cwd)
> +
> +        process_patch(scm.create_patch())
> +    else:
> +        # Change stderr to write with replacement characters so we don't die
> +        # if we try to print something containing non-ASCII characters.
> +        sys.stderr = codecs.StreamReaderWriter(sys.stderr,
> +                                               codecs.getreader('utf8'),
> +                                               codecs.getwriter('utf8'),
> +                                               'replace')

If this is useful (and I think it is), it seems like it would be needed for both code paths, so I'd move this outside of the "if".

> +
> +        for filename in filenames:
> +            cpplint.process_file(filename)
Comment 3 Kenneth Rohde Christiansen 2009-07-29 06:03:30 PDT
Created attachment 33712 [details]
Updates and improved patch
Comment 4 David Levin 2009-07-29 08:04:14 PDT
Comment on attachment 33712 [details]
Updates and improved patch

I'm willing to do these changes, but I'd like to know how you feel about the "consider" comments.


> diff --git a/WebKitTools/Scripts/check-webkit-style b/WebKitTools/Scripts/check-webkit-style
> +  The file parameter is optional and multiple file scan be passed in. Leaving

Consider:
  The file parameter is optional and multiple files to scan may be passed in

> +  out the file parameter will apply the check to the files currently not

Consider:
  out the file parameter will apply the check to the files changed 
  according to the scm system.


> +    if files and "--git-commit" in flags:
> +        sys.stderr.write("ERROR: It is not possible to check files "
> +                          "and a specific commit at the same time.\n" + cpp_style._USAGE)
>          sys.exit(1)
> +    elif files:

Make this an "if" since the pre if "exits".
Comment 5 Kenneth Rohde Christiansen 2009-07-29 08:08:15 PDT
I feel fine about these changes.
Comment 6 Kenneth Rohde Christiansen 2009-07-29 08:13:58 PDT
Comment on attachment 33712 [details]
Updates and improved patch

Landed (with the above changes) in 46542.