Bug 220995

Summary: [LayoutTests] Convert xmlhttprequest php to Python
Product: WebKit Reporter: Jonathan Bedard <jbedard>
Component: Tools / TestsAssignee: Jonathan Bedard <jbedard>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, ap, eric.carlson, ews-watchlist, glenn, gsnedders, jer.noble, philipj, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=220749
https://bugs.webkit.org/show_bug.cgi?id=221007
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
ews-feeder: commit-queue-
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Jonathan Bedard
Reported 2021-01-26 10:58:47 PST
Converting all php in xmlhttprequest to Python to gauge the difficulty of doing this across all layout tests.
Attachments
Patch (86.57 KB, patch)
2021-01-26 13:21 PST, Jonathan Bedard
no flags
Patch (139.15 KB, patch)
2021-01-27 11:06 PST, Jonathan Bedard
no flags
Patch (219.26 KB, patch)
2021-01-27 16:47 PST, Jonathan Bedard
no flags
Patch (342.66 KB, patch)
2021-01-29 12:57 PST, Jonathan Bedard
no flags
Patch (346.02 KB, patch)
2021-02-01 09:52 PST, Jonathan Bedard
no flags
Patch (375.14 KB, patch)
2021-02-01 14:39 PST, Jonathan Bedard
no flags
Patch (374.91 KB, patch)
2021-02-02 09:44 PST, Jonathan Bedard
ews-feeder: commit-queue-
Patch (375.83 KB, patch)
2021-02-03 19:45 PST, Jonathan Bedard
no flags
Patch (375.48 KB, patch)
2021-02-05 12:10 PST, Jonathan Bedard
no flags
Patch (375.70 KB, patch)
2021-02-05 13:16 PST, Jonathan Bedard
no flags
Patch (377.75 KB, patch)
2021-02-08 11:03 PST, Jonathan Bedard
no flags
Patch (4.55 KB, patch)
2021-02-09 12:55 PST, Jonathan Bedard
no flags
Radar WebKit Bug Importer
Comment 1 2021-01-26 13:18:17 PST
Jonathan Bedard
Comment 2 2021-01-26 13:21:55 PST
Jonathan Bedard
Comment 3 2021-01-27 11:06:57 PST
Jonathan Bedard
Comment 4 2021-01-27 16:47:45 PST
Jonathan Bedard
Comment 5 2021-01-27 20:12:25 PST
(In reply to Jonathan Bedard from comment #4) > Created attachment 418599 [details] > Patch The test failures caused by this change are because Mojave does not have Python 3. We’re about to update our Mac EWS bots, though.
Jonathan Bedard
Comment 6 2021-01-29 12:57:25 PST
Jonathan Bedard
Comment 7 2021-02-01 09:52:06 PST
Jonathan Bedard
Comment 8 2021-02-01 14:39:01 PST
Jonathan Bedard
Comment 9 2021-02-02 09:44:15 PST
Jonathan Bedard
Comment 10 2021-02-03 19:45:41 PST
Sam Sneddon [:gsnedders]
Comment 11 2021-02-05 07:49:44 PST
Comment on attachment 419220 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=419220&action=review Non-reviewer review: I'll point out that we have Python-using copies of most of these in wpt/xhr today, as both are ultimately derived from the same written-in-PHP-from-Opera-Software test suite. So starting with XHR might not be the most valuable place to start! That said, this mostly looks good. > LayoutTests/http/tests/xmlhttprequest/null-auth.py:9 > +sys.stdout.write('Content-Type: text/html') > +sys.stdout.write('\r\n\r\n') > + > +print('<p>Test that null values in XHR login/password parameters are treated correctly.</p>') > +print('<p>No auth tokens should be sent with this request.</p>') I find the combination of sys.stdout.write and print somewhat surprising, even though I understand _why_ it's doing it (to ensure headers are terminated with CRLF, and not caring about the body of the response). Equally, it feels like in many cases the print could be of a triple-quoted multi-line string, rather than like this. Not sure how difficult/worthwhile making such changes is, though? > LayoutTests/http/tests/xmlhttprequest/resources/multipart-post-echo.py:16 > +for key in sorted(form.keys()): That this is sorting them is a notable change from the original PHP, and causes changed expectations. I can't recall quite how precisely this is specified, but it would be nice to avoid changing the order? (Especially when CPython 3.6+ preserves order with dicts, so the iteration order isn't at the mercy of the dict construction any more.) > LayoutTests/http/tests/local/formdata/send-form-data-constructed-from-form-using-open-panel-expected.txt:5 > -Response: submitted=true&checkbox=value2&radio=value3&text=value4&file=test.txt:text/plain:Hello > +Response: checkbox=value2&radio=value3&submitted=true&text=value4&file=test.txt:text/plain:Hello e.g., this change
Jonathan Bedard
Comment 12 2021-02-05 12:08:31 PST
Comment on attachment 419220 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=419220&action=review >> LayoutTests/http/tests/xmlhttprequest/null-auth.py:9 >> +print('<p>No auth tokens should be sent with this request.</p>') > > I find the combination of sys.stdout.write and print somewhat surprising, even though I understand _why_ it's doing it (to ensure headers are terminated with CRLF, and not caring about the body of the response). Equally, it feels like in many cases the print could be of a triple-quoted multi-line string, rather than like this. Not sure how difficult/worthwhile making such changes is, though? I'll upload a change that makes an attempt to standardize this...I think it's really going to be a question about style preferences. >> LayoutTests/http/tests/xmlhttprequest/resources/multipart-post-echo.py:16 >> +for key in sorted(form.keys()): > > That this is sorting them is a notable change from the original PHP, and causes changed expectations. I can't recall quite how precisely this is specified, but it would be nice to avoid changing the order? (Especially when CPython 3.6+ preserves order with dicts, so the iteration order isn't at the mercy of the dict construction any more.) Turns out the cgi module pretty much always sorts this (ie, key in sorted(form.keys()), key in form.keys(), key in form are all sorted) I'd sort of like to keep it sorted(form.keys()), so future contributors will immediately know how this is organized.
Jonathan Bedard
Comment 13 2021-02-05 12:10:00 PST
Jonathan Bedard
Comment 14 2021-02-05 13:16:48 PST
Jonathan Bedard
Comment 15 2021-02-05 13:25:19 PST
(In reply to Jonathan Bedard from comment #14) > Created attachment 419453 [details] > Patch Not a big fan of how the multi-line strings end up looking....
Alex Christensen
Comment 16 2021-02-05 14:11:59 PST
Comment on attachment 419442 [details] Patch Why not perl? r=me
Jonathan Bedard
Comment 17 2021-02-05 14:22:12 PST
(In reply to Alex Christensen from comment #16) > Comment on attachment 419442 [details] > Patch > > Why not perl? > r=me Because there are many folks who want to replace our perl with Python :)
Jonathan Bedard
Comment 18 2021-02-08 11:03:15 PST
EWS
Comment 19 2021-02-08 14:04:17 PST
Committed r272548: <https://commits.webkit.org/r272548> All reviewed patches have been landed. Closing bug and clearing flags on attachment 419608 [details].
Jonathan Bedard
Comment 20 2021-02-09 12:55:14 PST
Reopening to attach new patch.
Jonathan Bedard
Comment 21 2021-02-09 12:55:16 PST
EWS
Comment 22 2021-02-09 13:51:48 PST
Committed r272609: <https://commits.webkit.org/r272609> All reviewed patches have been landed. Closing bug and clearing flags on attachment 419752 [details].
Note You need to log in before you can comment on or make changes to this bug.