Bug 224622 - [LayoutTests] Convert http/tests/resources convert PHP to Python
Summary: [LayoutTests] Convert http/tests/resources convert PHP to Python
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Gambrell
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-04-15 13:55 PDT by Chris Gambrell
Modified: 2021-04-26 10:45 PDT (History)
11 users (show)

See Also:


Attachments
Patch (137.55 KB, patch)
2021-04-15 14:08 PDT, Chris Gambrell
no flags Details | Formatted Diff | Diff
Patch (142.08 KB, patch)
2021-04-15 15:47 PDT, Chris Gambrell
no flags Details | Formatted Diff | Diff
Patch (142.76 KB, patch)
2021-04-16 09:30 PDT, Chris Gambrell
no flags Details | Formatted Diff | Diff
Patch (142.83 KB, patch)
2021-04-19 11:31 PDT, Chris Gambrell
no flags Details | Formatted Diff | Diff
Patch (142.91 KB, patch)
2021-04-19 17:26 PDT, Chris Gambrell
no flags Details | Formatted Diff | Diff
Patch (142.40 KB, patch)
2021-04-20 11:24 PDT, Chris Gambrell
no flags Details | Formatted Diff | Diff
Patch (139.42 KB, patch)
2021-04-22 08:30 PDT, Chris Gambrell
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Gambrell 2021-04-15 13:55:40 PDT
Replacing PHP with equivalent Python CGI scripts
Comment 1 Chris Gambrell 2021-04-15 14:08:30 PDT
Created attachment 426136 [details]
Patch
Comment 2 Chris Gambrell 2021-04-15 15:47:16 PDT
Created attachment 426145 [details]
Patch
Comment 3 Ryan Haddad 2021-04-15 15:51:06 PDT
rdar://76727052
Comment 4 Chris Gambrell 2021-04-16 09:30:51 PDT
Created attachment 426237 [details]
Patch
Comment 5 Chris Gambrell 2021-04-19 11:31:14 PDT
Created attachment 426448 [details]
Patch
Comment 6 Chris Gambrell 2021-04-19 11:34:01 PDT
Comment on attachment 426448 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=426448&action=review

> LayoutTests/http/tests/resources/last-modified.py:8
> +date = parse_qs(os.environ.get('QUERY_STRING', ''), keep_blank_values=True).get('date', [datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')])[0]

Python will not send the 'Last-Modified' header if it is empty or an invalid date format. Adding this as the default protects against an empty date
Comment 7 Jonathan Bedard 2021-04-19 11:39:55 PDT
(In reply to Chris Gambrell from comment #6)
> Comment on attachment 426448 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=426448&action=review
> 
> > LayoutTests/http/tests/resources/last-modified.py:8
> > +date = parse_qs(os.environ.get('QUERY_STRING', ''), keep_blank_values=True).get('date', [datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')])[0]
> 
> Python will not send the 'Last-Modified' header if it is empty or an invalid
> date format. Adding this as the default protects against an empty date

More accurately, Apache will not send the Last-Modified header if Python prints an empty or invalid header.
Comment 8 Chris Gambrell 2021-04-19 17:26:49 PDT
Created attachment 426496 [details]
Patch
Comment 9 Jonathan Bedard 2021-04-20 09:15:13 PDT
Comment on attachment 426496 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=426496&action=review

> LayoutTests/http/tests/misc/last-modified-parsing.html:17
> +test('Mon, 03 Mar 2008 01:03:33 GMT');

...which port was this required to fix? Looking at the test name, I think we're meaningfully changing the behavior of this test.

> LayoutTests/http/tests/resources/portabilityLayer.py:82
> +def set_state(file, state):

This has big implications for all of this function's callers. What motivated the change?

> LayoutTests/http/tests/resources/reset-temp-file.py:7
> +filename = parse_qs(os.environ.get('QUERY_STRING', ''), keep_blank_values=True).get('filename', ['404.txt'])[0]

Why did we change the name of the default file?

> LayoutTests/http/tests/resources/touch-temp-file.py:8
> +filename = parse_qs(os.environ.get('QUERY_STRING', ''), keep_blank_values=True).get('filename', ['404.txt'])[0]

Why did we change the name of the default file?
Comment 10 Chris Gambrell 2021-04-20 11:24:46 PDT
Created attachment 426573 [details]
Patch
Comment 11 Chris Gambrell 2021-04-20 11:27:27 PDT
Comment on attachment 426573 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=426573&action=review

> LayoutTests/http/tests/misc/last-modified-parsing.html:8
> +    document.write('<iframe src="../resources/last-modified.py?date=' + escape(text) + '"></iframe>');

Reverted to keep different formats of dates in this test

> LayoutTests/http/tests/resources/last-modified.py:14
> +else:

Re-format date if it isn't in an appropriate format for Last-Modified header.

> LayoutTests/http/tests/resources/portabilityLayer.py:82
> +def set_state(file, state):

Moved file to first arg to keep consistent with all other functions in this script. Addressed every instance of a caller of this function and made sure they were all changed to match the argument order.
Comment 12 Chris Gambrell 2021-04-22 08:30:18 PDT
Created attachment 426813 [details]
Patch
Comment 13 Chris Gambrell 2021-04-26 10:20:40 PDT
http/tests/images/mp4-partial-load.html is failing mac-wk2-stress. When running the same test with its PHP version instead of Python, it is failing the same way. There is a separate issue with this test and a separate bug will be created to fix it.
Comment 14 EWS 2021-04-26 10:45:15 PDT
Committed r276602 (237034@main): <https://commits.webkit.org/237034@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 426813 [details].