Bug 194283 - webkit-patch print-expectations fails to format TestExpectationLine with DumpJSConsoleLogInStdErr
Summary: webkit-patch print-expectations fails to format TestExpectationLine with Dump...
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: Fujii Hironori
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-02-05 00:10 PST by Fujii Hironori
Modified: 2019-12-12 17:52 PST (History)
12 users (show)

See Also:


Attachments
Patch (3.07 KB, patch)
2019-02-05 01:06 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (3.00 KB, patch)
2019-02-13 00:32 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (3.02 KB, patch)
2019-12-10 18:07 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 2019-02-05 00:10:37 PST
webkit-patch print-expectations fails to format TestExpectationLine with DumpJSConsoleLogInStdErr

> $ ./Tools/Scripts/webkit-patch print-expectations --port=wincairo imported/w3c/web-platform-tests/fetch/
> --lint-test-files warnings:
> LayoutTests/platform/gtk/TestExpectations:3782 Path does not exist. imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html
> 
> Traceback (most recent call last):
>   File "./Tools/Scripts/webkit-patch", line 84, in <module>
>     main()
>   File "./Tools/Scripts/webkit-patch", line 79, in main
>     WebKitPatch(os.path.abspath(__file__)).main()
>   File "/mnt/c/webkit/ga/Tools/Scripts/webkitpy/tool/multicommandtool.py", line 305, in main
>     result = command.check_arguments_and_execute(options, args, self)
>   File "/mnt/c/webkit/ga/Tools/Scripts/webkitpy/tool/multicommandtool.py", line 123, in check_arguments_and_execute
>     return self.execute(options, args, tool) or 0
>   File "/mnt/c/webkit/ga/Tools/Scripts/webkitpy/tool/commands/queries.py", line 501, in execute
>     print('\n'.join(self._format_lines(options, port_name, lines)))
>   File "/mnt/c/webkit/ga/Tools/Scripts/webkitpy/tool/commands/queries.py", line 525, in _format_lines
>     output.append("%s" % line.to_string(None, include_modifiers, include_expectations, include_comment=False))
>   File "/mnt/c/webkit/ga/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py", line 460, in to_string
>     include_modifiers, include_expectations, include_comment)
>   File "/mnt/c/webkit/ga/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py", line 510, in _format_line
>     result += ' [ %s ]' % ' '.join(sorted(set(new_expectations)))
> TypeError: sequence item 0: expected string, NoneType found
Comment 1 Fujii Hironori 2019-02-05 01:06:12 PST
Created attachment 361173 [details]
Patch
Comment 2 Alexey Proskuryakov 2019-02-05 10:44:06 PST
Comment on attachment 361173 [details]
Patch

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

> Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py:244
> +        'DumpJSConsoleLogInStdErr': 'DUMPJSCONSOLELOGINSTDERR',

Would we need changes in the flakiness dashboard to support this value?

I think that we are hitting a design mistake with regards to DumpJSConsoleLogInStdErr - it is not an expectation, so mixing it with expectations causes trouble.
Comment 3 Jonathan Bedard 2019-02-05 13:08:49 PST
This bug very much confuses me. Why would we have a test expectation with DumpJSConsoleLogInStdErr in it? That feels like an abuse of the TestExpectations.
Comment 4 youenn fablet 2019-02-05 19:21:13 PST
> Would we need changes in the flakiness dashboard to support this value?

No

> I think that we are hitting a design mistake with regards to
> DumpJSConsoleLogInStdErr - it is not an expectation, so mixing it with
> expectations causes trouble.

It is not really a test expectation, it is closer to 'Slow' in the sense it is changing the way the test is run.
It was put there and not in some other file for convenience following the 'one place is better than two'.
Comment 5 Fujii Hironori 2019-02-06 19:33:07 PST
DumpJSConsoleLogInStdErr has been introduced in Bug 161310.

webkit-test-runner magic comments or window.testRunner or window.internals can be the alternatives.

Some imported tests have been modifed to have a webkit-test-runner magic comment.
E.g. https://trac.webkit.org/browser/webkit/trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-logical/logical-box-border-color.html?rev=241112#L1

internals.setConsoleMessageListener() doesn't prevent console log.

Settings::logsPageMessagesToSystemConsoleEnabled doesn't prevent console log.
Comment 6 youenn fablet 2019-02-06 19:55:43 PST
(In reply to Fujii Hironori from comment #5)
> DumpJSConsoleLogInStdErr has been introduced in Bug 161310.
> 
> webkit-test-runner magic comments or window.testRunner or window.internals
> can be the alternatives.

DumpJSConsoleLogInStdErr is mostly useful for imported tests that we do not want to modify.
For tests that we can modify, there are usually ways, though not always, to not rely on it.

> Some imported tests have been modifed to have a webkit-test-runner magic
> comment.
> E.g.
> https://trac.webkit.org/browser/webkit/trunk/LayoutTests/imported/w3c/web-
> platform-tests/css/css-logical/logical-box-border-color.html?rev=241112#L1


When reimporting these files, these comments will be lost by the importer and one will need to add them again. I hope these changes are expected to be temporary until we can activate the feature globally.

The test importer could try to preserve these comments.
In some cases, this is not possible though.
Tests like like imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin.any.html are templates generated by the WPT server.
The only way would be to modify the WPT server and we would certainly not be able to upstream these changes.

An alternative is to apply DumpJSConsoleLogInStdErr to all WPT tests but we decided not to do that as it sometimes catches regressions.

Another alternative would be to have some ways to grab the test options outside of the test content itself, either a central file or a file close to each test. I don't think we reached consensus there.
Comment 7 Fujii Hironori 2019-02-07 00:23:14 PST
(In reply to youenn fablet from comment #6)
> Another alternative would be to have some ways to grab the test options
> outside of the test content itself, either a central file or a file close to
> each test. I don't think we reached consensus there.

This seems the best. 
How about the idea reusing tests-options.json for such purpose?
https://trac.webkit.org/browser/webkit/trunk/LayoutTests/tests-options.json?rev=241112
tests-options.json has been introduced in Bug 161601.
Comment 8 Fujii Hironori 2019-02-07 00:26:01 PST
I realize a tiny problem of DumpJSConsoleLogInStdErr that it outputs into stderr even though it is not a error message.
Windows port has "EDITING DELEGATE:" filter in do_text_results_differ.
https://trac.webkit.org/browser/webkit/trunk/Tools/Scripts/webkitpy/port/win.py?rev=241112#L108
We can have "CONSOLE:" filter for the purpose without modifying DRT and WTR.
This approach wouldn't pollute the content of -stderr.txt.
Comment 9 Fujii Hironori 2019-02-07 02:20:44 PST
(In reply to Fujii Hironori from comment #7)
> How about the idea reusing tests-options.json for such purpose?

This is not easy because magic comments are retrieved by DRT and WTR, not by webkit-test-runner.
DRT and WTR need to be changed to parse tests-options.json.

It is easier to use a option file for each test, which is placed close to the test.
Comment 10 Fujii Hironori 2019-02-07 06:07:14 PST
(In reply to Fujii Hironori from comment #8)
> I realize a tiny problem of DumpJSConsoleLogInStdErr that it outputs into
> stderr even though it is not a error message.

Darin mentioned this in Bug 161310 Comment 15.
I didn't read the lengthy discussion. I should have read it first.
Comment 11 Fujii Hironori 2019-02-12 23:29:17 PST
Bug 177027 has introduced dumpJSConsoleLogInStdErr test option.

> webkit-test-runner [ dumpJSConsoleLogInStdErr=true ]

I think we should use this for non-imported tests instead of using DumpJSConsoleLogInStdErr expectation in TestExpectations.
Comment 12 Fujii Hironori 2019-02-13 00:32:30 PST
Created attachment 361901 [details]
Patch
Comment 13 Fujii Hironori 2019-02-13 00:56:53 PST
Comment on attachment 361901 [details]
Patch

Oops, wrong patch.
Comment 14 Fujii Hironori 2019-02-13 02:39:29 PST
(In reply to Fujii Hironori from comment #11)
> I think we should use this for non-imported tests instead of using
> DumpJSConsoleLogInStdErr expectation in TestExpectations.

Filed Bug 194586.
Comment 15 youenn fablet 2019-02-14 08:52:38 PST
> Tests like like imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin.any.html are templates generated by the WPT server.

If we decide to continue with these templated .any.html, we could actually modify them to include <!-- webkit-test-runner --> comments, as I guess the test runner is reading the file and not the HTTP resource.
We would then need to instruct the importer to preserve any of these comments.
Comment 16 Fujii Hironori 2019-02-15 01:40:38 PST
a previous discussion:

[webkit-dev] WPT tests and runtime-enabled features
https://lists.webkit.org/pipermail/webkit-dev/2017-June/029165.html
Comment 17 Fujii Hironori 2019-02-17 22:27:54 PST
(In reply to youenn fablet from comment #15)
> > Tests like like imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin.any.html are templates generated by the WPT server.
> 
> If we decide to continue with these templated .any.html, we could actually
> modify them to include <!-- webkit-test-runner --> comments, as I guess the
> test runner is reading the file and not the HTTP resource.
> We would then need to instruct the importer to preserve any of these
> comments.

youenn, do you prefer this approach? I think it is easier to use a option file for each test, which is placed close to the test, as you mentionsed in comment 6.
E.g. imported/w3c/web-platform-tests/fetch/api/basic/mode-same-origin.any-option.txt
Comment 18 Fujii Hironori 2019-12-10 18:03:05 PST
As Youenn mentioned in Bug 204793 Comment 5, there is no consensus on removing all DumpJSConsoleLogInStdErr expectation at the moment yet.
I'm going to fix the original issue of formatting DumpJSConsoleLogInStdErr (comment 0).
Comment 19 Fujii Hironori 2019-12-10 18:07:46 PST
Created attachment 385333 [details]
Patch
Comment 20 Fujii Hironori 2019-12-11 17:56:35 PST
Youenn, can I ask you review?
Comment 21 Fujii Hironori 2019-12-12 00:57:24 PST
Thank you!
I will land it unless anyone objects.
Comment 22 Fujii Hironori 2019-12-12 17:51:39 PST
Comment on attachment 385333 [details]
Patch

Clearing flags on attachment: 385333

Committed r253459: <https://trac.webkit.org/changeset/253459>
Comment 23 Fujii Hironori 2019-12-12 17:51:43 PST
All reviewed patches have been landed.  Closing bug.
Comment 24 Radar WebKit Bug Importer 2019-12-12 17:52:30 PST
<rdar://problem/57898667>