RESOLVED FIXED 221981
[LayoutTests] Convert http/tests/misc convert PHP to Python
https://bugs.webkit.org/show_bug.cgi?id=221981
Summary [LayoutTests] Convert http/tests/misc convert PHP to Python
Chris Gambrell
Reported 2021-02-16 11:28:55 PST
Replacing PHP with equivalent Python CGI scripts
Attachments
Patch (74.17 KB, patch)
2021-02-17 12:33 PST, Chris Gambrell
no flags
Patch (90.47 KB, patch)
2021-02-17 14:22 PST, Chris Gambrell
no flags
Patch (84.63 KB, patch)
2021-02-17 14:53 PST, Chris Gambrell
no flags
Patch (88.17 KB, patch)
2021-02-17 15:06 PST, Chris Gambrell
no flags
Patch (84.58 KB, patch)
2021-02-17 16:08 PST, Chris Gambrell
ews-feeder: commit-queue-
Patch (84.59 KB, patch)
2021-02-17 20:39 PST, Chris Gambrell
no flags
Patch (110.71 KB, patch)
2021-02-18 14:23 PST, Chris Gambrell
ews-feeder: commit-queue-
Patch (132.78 KB, patch)
2021-02-18 16:56 PST, Chris Gambrell
no flags
Patch (138.77 KB, patch)
2021-02-18 21:20 PST, Chris Gambrell
no flags
Patch (14.11 KB, patch)
2021-02-19 11:41 PST, Chris Gambrell
no flags
Patch (23.73 KB, patch)
2021-02-19 12:31 PST, Chris Gambrell
no flags
Patch (26.00 KB, patch)
2021-02-19 12:56 PST, Chris Gambrell
no flags
Patch (25.27 KB, patch)
2021-02-19 13:09 PST, Chris Gambrell
no flags
Patch (22.93 KB, patch)
2021-02-19 13:13 PST, Chris Gambrell
no flags
Patch (40.08 KB, patch)
2021-02-19 15:36 PST, Chris Gambrell
no flags
Patch (59.37 KB, patch)
2021-02-19 16:07 PST, Chris Gambrell
no flags
Patch (104.23 KB, patch)
2021-02-19 17:07 PST, Chris Gambrell
no flags
Patch (102.51 KB, patch)
2021-02-22 07:21 PST, Chris Gambrell
no flags
Patch (105.89 KB, patch)
2021-02-22 08:11 PST, Chris Gambrell
no flags
Patch (121.03 KB, patch)
2021-02-22 09:38 PST, Chris Gambrell
no flags
Patch (114.36 KB, patch)
2021-02-22 10:22 PST, Chris Gambrell
no flags
Patch (126.18 KB, patch)
2021-02-22 11:05 PST, Chris Gambrell
no flags
Patch (189.85 KB, patch)
2021-02-22 13:58 PST, Chris Gambrell
ews-feeder: commit-queue-
Patch (188.95 KB, patch)
2021-02-22 21:07 PST, Chris Gambrell
no flags
Patch (195.98 KB, patch)
2021-02-23 06:19 PST, Chris Gambrell
no flags
Patch (189.78 KB, patch)
2021-02-23 14:30 PST, Chris Gambrell
no flags
Patch (191.63 KB, patch)
2021-03-01 13:15 PST, Chris Gambrell
no flags
Patch (189.48 KB, patch)
2021-03-01 13:33 PST, Chris Gambrell
no flags
Patch (185.90 KB, patch)
2021-03-01 17:22 PST, Chris Gambrell
no flags
Patch (186.97 KB, patch)
2021-03-02 08:17 PST, Chris Gambrell
no flags
Patch (24.38 KB, patch)
2021-04-01 21:34 PDT, Chris Gambrell
no flags
Patch (19.91 KB, patch)
2021-04-01 21:39 PDT, Chris Gambrell
no flags
Patch (14.01 KB, patch)
2021-04-01 21:47 PDT, Chris Gambrell
no flags
Patch (15.20 KB, patch)
2021-04-02 11:23 PDT, Chris Gambrell
no flags
Patch (14.04 KB, patch)
2021-04-02 12:04 PDT, Chris Gambrell
jbedard: review+
Radar WebKit Bug Importer
Comment 1 2021-02-16 11:29:38 PST
Chris Gambrell
Comment 2 2021-02-17 12:33:23 PST
Chris Gambrell
Comment 3 2021-02-17 14:22:26 PST
Chris Gambrell
Comment 4 2021-02-17 14:53:09 PST
Chris Gambrell
Comment 5 2021-02-17 15:06:16 PST
Chris Gambrell
Comment 6 2021-02-17 16:08:15 PST
Chris Gambrell
Comment 7 2021-02-17 20:39:01 PST
Jonathan Bedard
Comment 8 2021-02-18 11:06:45 PST
Comment on attachment 420792 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=420792&action=review > LayoutTests/http/tests/misc/resources/charset-sniffer-end-sniffing.py:15 > +for i in range(0, 10000): The usual idiom when you have a variable that you need to complete a statement but that you are not actually going to use is to use '_' > LayoutTests/http/tests/misc/resources/check-test-file.py:28 > + 'PASS: File upload was successful\n' Is there any "error" equivalent in Python? This code isn't exactly the same, although it's the same in the successful case, so that's probably sufficient. > LayoutTests/http/tests/misc/resources/check-unnamed-file-included-in-formdata.py:23 > +if data != None: Style is to use "data is not None" in this case. > LayoutTests/http/tests/misc/resources/redirect-to-http-url.py:1 > +#!/usr/bin/env python3 Is there a php file being removed here? > LayoutTests/http/tests/misc/resources/referrer-main-resource.py:6 > +referer = os.environ.get('HTTP_REFERER', '') Don't need the default empty string (since you aren't printing it) and you probably don't need the variable either and could just put the os.environ.get in the if statement > LayoutTests/http/tests/misc/resources/referrer-result.py:14 > +# formatting string Remove this comment. I suspect the issue is about the brackets in the string, and can be mitigated with double brackets, but it's not a huge issue if these stay as "prints" > LayoutTests/http/tests/misc/resources/stylesheet-bad-mime-type.py:18 > + sys.stdout.write('\r\n') I think we want the 406 status code here
Chris Gambrell
Comment 9 2021-02-18 14:23:26 PST
Chris Gambrell
Comment 10 2021-02-18 16:56:25 PST
Chris Gambrell
Comment 11 2021-02-18 21:20:54 PST
Chris Gambrell
Comment 12 2021-02-19 11:41:27 PST
Chris Gambrell
Comment 13 2021-02-19 12:31:05 PST
Chris Gambrell
Comment 14 2021-02-19 12:56:18 PST
Chris Gambrell
Comment 15 2021-02-19 13:09:42 PST
Chris Gambrell
Comment 16 2021-02-19 13:13:45 PST
Chris Gambrell
Comment 17 2021-02-19 15:36:50 PST
Chris Gambrell
Comment 18 2021-02-19 15:41:46 PST
(In reply to Jonathan Bedard from comment #8) > Comment on attachment 420792 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=420792&action=review > > > LayoutTests/http/tests/misc/resources/charset-sniffer-end-sniffing.py:15 > > +for i in range(0, 10000): > > The usual idiom when you have a variable that you need to complete a > statement but that you are not actually going to use is to use '_' > > > LayoutTests/http/tests/misc/resources/check-test-file.py:28 > > + 'PASS: File upload was successful\n' > > Is there any "error" equivalent in Python? This code isn't exactly the same, > although it's the same in the successful case, so that's probably sufficient. > > > LayoutTests/http/tests/misc/resources/check-unnamed-file-included-in-formdata.py:23 > > +if data != None: > > Style is to use "data is not None" in this case. > > > LayoutTests/http/tests/misc/resources/redirect-to-http-url.py:1 > > +#!/usr/bin/env python3 > > Is there a php file being removed here? > > > LayoutTests/http/tests/misc/resources/referrer-main-resource.py:6 > > +referer = os.environ.get('HTTP_REFERER', '') > > Don't need the default empty string (since you aren't printing it) and you > probably don't need the variable either and could just put the > os.environ.get in the if statement > > > LayoutTests/http/tests/misc/resources/referrer-result.py:14 > > +# formatting string > > Remove this comment. I suspect the issue is about the brackets in the > string, and can be mitigated with double brackets, but it's not a huge issue > if these stay as "prints" > > > LayoutTests/http/tests/misc/resources/stylesheet-bad-mime-type.py:18 > > + sys.stdout.write('\r\n') > > I think we want the 406 status code here Fixed in comment 17
Chris Gambrell
Comment 19 2021-02-19 16:07:31 PST
Chris Gambrell
Comment 20 2021-02-19 17:07:18 PST
Chris Gambrell
Comment 21 2021-02-22 07:21:21 PST
Chris Gambrell
Comment 22 2021-02-22 08:11:48 PST
Chris Gambrell
Comment 23 2021-02-22 09:38:26 PST
Chris Gambrell
Comment 24 2021-02-22 10:22:18 PST
Chris Gambrell
Comment 25 2021-02-22 11:05:29 PST
Chris Gambrell
Comment 26 2021-02-22 13:58:05 PST
Chris Gambrell
Comment 27 2021-02-22 21:07:31 PST
Chris Gambrell
Comment 28 2021-02-23 06:19:24 PST
Chris Gambrell
Comment 29 2021-02-23 14:30:13 PST
Chris Gambrell
Comment 30 2021-02-23 14:32:47 PST
(In reply to Chris Gambrell from comment #29) > Created attachment 421351 [details] > Patch There are still 3 PHP files remaining. Talked to Jonathan and it is beneficial to proceed with committing the changes that are complete and move on to more directories to keep progressing through the files we need to convert. This directory will be revisited later. After cq+ the bug should remain open and not resolved. LayoutTests/http/tests/misc/resources/redirect-to-http-url.php LayoutTests/http/tests/misc/resources/prefetch-purpose.php LayoutTests/http/tests/misc/resources/check-query-param.php
Jonathan Bedard
Comment 31 2021-02-25 11:49:10 PST
Comment on attachment 421351 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=421351&action=review > LayoutTests/http/tests/loading/resources/slowimage.py:1 > +#!/usr/bin/env python3 I don't see the file that this is replacing, and it looks like a duplicate? > LayoutTests/http/tests/misc/refresh-headers.py:11 > +if cache_control.lower() == 'no-cache' or pragma.lower == 'no-cache': Should be pragma.lower() > LayoutTests/http/tests/misc/resources/char-encoding-in-hidden-charset-field.py:7 > +data = ''.join(sys.stdin.readlines()) It seems wrong to read data if our request method is not a POST request > LayoutTests/http/tests/misc/resources/check-query-param.py:1 > +#!/usr/bin/env python3 I don't see the PHP file we are replacing removed. > LayoutTests/http/tests/misc/resources/dns-prefetch-control.py:10 > +sys.stdout.write('Content-Type: text/html\r\n\r\n') X-DNS-Prefetch-Control is part of the header. You are ending the header here. > LayoutTests/http/tests/misc/resources/dns-prefetch-control.py:17 > + sys.stdout.write('X-DNS-Prefetch-Control: foo\r\n\r\n') Maybe just: if value in ['on', 'off', 'foo']: sys.stdout.write('X-DNS-Prefetch-Control: off\r\n'.format(value)) > LayoutTests/http/tests/misc/resources/image-checks-for-accept.py:6 > +allimages = 'image/*' This doesn't really need be a variable. > LayoutTests/http/tests/misc/resources/webtiming-cross-origin-and-back-redirect2.php:-2 > - // 127.0.0.1 is where the test originally started. We redirected to "localhost" before this. I would keep this comment in the Python file > LayoutTests/http/tests/misc/resources/protected/protected-image.py:15 > +if !username: Use `not username`
Chris Gambrell
Comment 32 2021-03-01 13:15:36 PST
Chris Gambrell
Comment 33 2021-03-01 13:33:58 PST
Chris Gambrell
Comment 34 2021-03-01 17:22:52 PST
Chris Gambrell
Comment 35 2021-03-02 08:17:45 PST
EWS
Comment 36 2021-03-03 09:14:57 PST
Committed r273819: <https://commits.webkit.org/r273819> All reviewed patches have been landed. Closing bug and clearing flags on attachment 421937 [details].
Chris Gambrell
Comment 37 2021-04-01 20:34:49 PDT
Reopening for second pass
Chris Gambrell
Comment 38 2021-04-01 21:34:05 PDT
Chris Gambrell
Comment 39 2021-04-01 21:39:42 PDT
Chris Gambrell
Comment 40 2021-04-01 21:47:24 PDT
Chris Gambrell
Comment 41 2021-04-01 21:53:11 PDT
Comment on attachment 424987 [details] Patch apply-patch is having issues processing http/tests/misc/will-send-request-returns-null-on-redirect.html's resources being converted from .php to .py. No other tests use http/tests/misc/resources/redirect-to-http-url.php so I have included the .py version without removing the .php file so that EWS can chew on the other converted files. The test file that references http/tests/misc/resources/redirect-to-http-url.py (the file that is having trouble going through apply-patch) passes locally on wk1 and wk2. platform/wk2/http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt will need to be updated along with http/tests/misc/will-send-request-returns-null-on-redirect.html and http/tests/misc/will-send-request-returns-null-on-redirect-expected.txt. Once r+, I will remove the .php version and update the files in question to reflect the .py version instead of the .php and will land it manually to bypass the apply-patch issues
Jonathan Bedard
Comment 42 2021-04-02 10:02:20 PDT
Comment on attachment 424987 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=424987&action=review > LayoutTests/http/tests/misc/resources/check-query-param.py:21 > +if 'HTTP_COOKIE' in os.environ: Might consider using get_cookies and request.update() > LayoutTests/http/tests/misc/resources/redirect-to-http-url.py:1 > +#!/usr/bin/env python3 Where is the php file we're replacing? Is it still used elsewhere?
Chris Gambrell
Comment 43 2021-04-02 11:23:14 PDT
Chris Gambrell
Comment 44 2021-04-02 11:23:59 PDT
(In reply to Jonathan Bedard from comment #42) > Comment on attachment 424987 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=424987&action=review > > > LayoutTests/http/tests/misc/resources/check-query-param.py:21 > > +if 'HTTP_COOKIE' in os.environ: > > Might consider using get_cookies and request.update() > > > LayoutTests/http/tests/misc/resources/redirect-to-http-url.py:1 > > +#!/usr/bin/env python3 > > Where is the php file we're replacing? Is it still used elsewhere? See comment 41
Jonathan Bedard
Comment 45 2021-04-02 11:44:51 PDT
Comment on attachment 425034 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425034&action=review > LayoutTests/http/tests/misc/resources/check-query-param.py:29 > + request.update({ key: cookies[key] }) Don't need a loop here, request.update(get_cookies()) should work
Chris Gambrell
Comment 46 2021-04-02 12:04:16 PDT
Chris Gambrell
Comment 47 2021-04-06 15:20:23 PDT
Note You need to log in before you can comment on or make changes to this bug.