Bug 100062

Summary: nrwt: truncate meter lines properly on windows
Product: WebKit Reporter: Dirk Pranke <dpranke>
Component: New BugsAssignee: Dirk Pranke <dpranke>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, ojan, tony, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
update w/ review feedback
none
fix typos, verify works on cygwin as well
none
update w/ more review feedback tony: review+

Dirk Pranke
Reported 2012-10-22 19:26:09 PDT
nrwt: truncate meter lines properly on windows
Attachments
Patch (10.00 KB, patch)
2012-10-22 19:27 PDT, Dirk Pranke
no flags
update w/ review feedback (6.63 KB, patch)
2012-10-24 15:28 PDT, Dirk Pranke
no flags
fix typos, verify works on cygwin as well (7.54 KB, patch)
2012-10-24 15:54 PDT, Dirk Pranke
no flags
update w/ more review feedback (7.55 KB, patch)
2012-10-24 15:56 PDT, Dirk Pranke
tony: review+
Dirk Pranke
Comment 1 2012-10-22 19:27:03 PDT
Dirk Pranke
Comment 2 2012-10-22 19:28:38 PDT
Tony, this modifies the change you made to truncate lines to the terminal width (ninja-style) so that it works on windows as well. I'm not entirely happy with this patch - the layering is a bit weird - so I'm open to feedback. Maybe I should just leave the code in MeteredStream and not add a platforminfo object until some other class needs it?
Tony Chang
Comment 3 2012-10-23 10:21:07 PDT
Comment on attachment 170046 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=170046&action=review Putting the method in platforminfo seems fine. I would probably pass in the number of columns rather than the whole platforminfo object (Makes it easier to test? I think I read this in a TotT.). > Tools/Scripts/webkitpy/common/system/platforminfo.py:92 > + if self.is_win(): Looks like cygwin is also considered win, but I think we want cygwin to take the 'else' code path. > Tools/Scripts/webkitpy/common/system/platforminfo.py:95 > + h = windll.kernel32.GetStdHandle(-12) # handle for stderr Nit: h -> handle > Tools/Scripts/webkitpy/common/system/platforminfo.py:96 > + csbi = create_string_buffer(22) csbi -> console_screen_buffer_info > Tools/Scripts/webkitpy/common/system/platforminfo.py:98 > + res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi) > + if res: Nit: Remove the temp variable? > Tools/Scripts/webkitpy/common/system/platforminfo.py:100 > + (_, _, _, _, _, left, _, right, _, _, _) = struct.unpack("hhhhHhhhhhh", csbi.raw) Nit: Don't need () on the left side of the assignment. > Tools/Scripts/webkitpy/layout_tests/views/printing.py:333 > + # We don't write into the rightmost column of a terminal since this may cause lines to wrap on Windows. > + max_line_length = self._meter.number_of_columns() - 1 Can we subtract the extra column only no Windows? I would be annoyed by the wasted column on Linux. Maybe we can do the -1 in number_of_columns to make the testing easier.
Dirk Pranke
Comment 4 2012-10-24 15:21:29 PDT
(In reply to comment #3) > (From update of attachment 170046 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=170046&action=review > > Putting the method in platforminfo seems fine. I would probably pass in the number of columns rather than the whole platforminfo object (Makes it easier to test? I think I read this in a TotT.). > It's a bit of a tossup, since platform info is so small, but will do. > > Tools/Scripts/webkitpy/common/system/platforminfo.py:92 > > + if self.is_win(): > > Looks like cygwin is also considered win, but I think we want cygwin to take the 'else' code path. > Will verify. > > Tools/Scripts/webkitpy/common/system/platforminfo.py:95 > > + h = windll.kernel32.GetStdHandle(-12) # handle for stderr > > Nit: h -> handle > Will do. > > Tools/Scripts/webkitpy/common/system/platforminfo.py:96 > > + csbi = create_string_buffer(22) > > csbi -> console_screen_buffer_info > > > Tools/Scripts/webkitpy/common/system/platforminfo.py:98 > > + res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi) > > + if res: > > Nit: Remove the temp variable? > What temp variable? > > Tools/Scripts/webkitpy/common/system/platforminfo.py:100 > > + (_, _, _, _, _, left, _, right, _, _, _) = struct.unpack("hhhhHhhhhhh", csbi.raw) > > Nit: Don't need () on the left side of the assignment. > Done. > > Tools/Scripts/webkitpy/layout_tests/views/printing.py:333 > > + # We don't write into the rightmost column of a terminal since this may cause lines to wrap on Windows. > > + max_line_length = self._meter.number_of_columns() - 1 > > Can we subtract the extra column only no Windows? I would be annoyed by the wasted column on Linux. Maybe we can do the -1 in number_of_columns to make the testing easier. Yeah, I waffled on this. I will push it inside number_of_columns().
Dirk Pranke
Comment 5 2012-10-24 15:28:27 PDT
Created attachment 170487 [details] update w/ review feedback
Tony Chang
Comment 6 2012-10-24 15:41:35 PDT
Comment on attachment 170487 [details] update w/ review feedback View in context: https://bugs.webkit.org/attachment.cgi?id=170487&action=review > Tools/Scripts/webkitpy/common/system/platforminfo.py:96 > + console_screen_buffer_info = create_string_buffer(22) Maybe make a variable for 22 explaining what it is? sizeof_console_screen_buffer_info, I assume. > Tools/Scripts/webkitpy/common/system/platforminfo.py:98 > + res = windll.kernel32.GetConsoleScreenBufferInfo(handle, console_screen_buffer_info) > + if res: I meant you don't need |res|. This could just be: if windll.kernel32.GetConsoleScreenBufferInfo(handle, console_screen_buffer_info):
Dirk Pranke
Comment 7 2012-10-24 15:54:10 PDT
Created attachment 170496 [details] fix typos, verify works on cygwin as well
Dirk Pranke
Comment 8 2012-10-24 15:56:31 PDT
Created attachment 170499 [details] update w/ more review feedback
Dirk Pranke
Comment 9 2012-10-24 15:57:07 PDT
(In reply to comment #6) > (From update of attachment 170487 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=170487&action=review > > > Tools/Scripts/webkitpy/common/system/platforminfo.py:96 > > + console_screen_buffer_info = create_string_buffer(22) > > Maybe make a variable for 22 explaining what it is? sizeof_console_screen_buffer_info, I assume. > Added a comment; a variable seemed like overkill. > > Tools/Scripts/webkitpy/common/system/platforminfo.py:98 > > + res = windll.kernel32.GetConsoleScreenBufferInfo(handle, console_screen_buffer_info) > > + if res: > > I meant you don't need |res|. This could just be: > if windll.kernel32.GetConsoleScreenBufferInfo(handle, console_screen_buffer_info): Ah. Done.
Dirk Pranke
Comment 10 2012-10-24 16:46:29 PDT
Note You need to log in before you can comment on or make changes to this bug.