Closed Bug 911132 Opened 11 years ago Closed 11 years ago

UnicodeDecodeError in runxpcshelltests.py running toolkit/mozapps/extensions/test/xpcshell/test_plugins.js

Categories

(Testing :: XPCShell Harness, defect)

All
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla26

People

(Reporter: gfritzsche, Assigned: mihneadb)

Details

Attachments

(1 file, 2 obsolete files)

> ./mach xpcshell-tests toolkit/mozapps/extensions/test/xpcshell/test_plugins.js
[...]
> UnicodeDecodeError: 'ascii' codec can't decode byte 0x87 in position 256: ordinal not in range(128)

>  File "[...]/testing/xpcshell/mach_commands.py", line 235, in run_xpcshell_test
>    return xpcshell.run_test(**params)
>  File "[...]/testing/xpcshell/mach_commands.py", line 105, in run_test
>    return self._run_xpcshell_harness(**args)
>  File "[...]/testing/xpcshell/mach_commands.py", line 188, in _run_xpcshell_harness
>    result = xpcshell.runTests(**filtered_args)
>  File "[...]/testing/xpcshell/runxpcshelltests.py", line 1338, in runTests
>    raise test.exception

That is: http://hg.mozilla.org/mozilla-central/annotate/c7459bc8e449/testing/xpcshell/runxpcshelltests.py#l1338

CCs for the two common user names around this in blame.
Chris, could it be some unicode encoding problem from the logging layer?
forgot to flag needinfo
Flags: needinfo?(chmanchester)
The xpcshell process is emitting output that isn't UTF-8 and this is confusing Python. This is mainly the fault of some tests printing "binary" because they don't know better. I thought there was a bug (that I had filed) regarding intercepting output in head.js and ensuring valid UTF-8 (by either encoding to hex or replacing invalid characters with the standard UTF-8 replacement character).
Here's the whole stacktrace. https://pastebin.mozilla.org/2942211
We'll just output '?' for invalid bytes in the string output.
Attachment #798009 - Flags: review?(gps)
Assignee: nobody → mihneadb
Status: NEW → ASSIGNED
Flags: needinfo?(chmanchester)
Comment on attachment 798009 [details] [diff] [review]
Replace invalid bytes in xpcshell binary string output

Review of attachment 798009 [details] [diff] [review]:
-----------------------------------------------------------------

This is good. We should also consider emitting a warning when a test outputs non-UTF-8 because I think we should consider that a misbehaving test.
Attachment #798009 - Flags: review?(gps) → review+
Should we do that in the same bug? How would we check? Try and catch UnicodeDecodeError?
try:
  line = line.decode('utf-8')
except UnicodeDecodeError:
  # emit warning
  line = line.decode('utf-8', 'replace')
Ok, agreed. Sould we do it in this bug?
Why not!
Attachment #798009 - Attachment is obsolete: true
Comment on attachment 798043 [details] [diff] [review]
Replace invalid bytes in xpcshell binary string output

Review of attachment 798043 [details] [diff] [review]:
-----------------------------------------------------------------

::: testing/xpcshell/runxpcshelltests.py
@@ +485,5 @@
>                  for line in part.splitlines():
> +                    try:
> +                        line = line.decode('utf-8')
> +                    except UnicodeDecodeError:
> +                        self.log.info("TEST-INFO | Detected binary output.")

non-UTF-8 is not necessary binary - it's just not UTF-8!

Please print an actionable error message. e.g.

Detected non UTF-8 output from test XXX. Please modify the test to only print UTF-8.
Attachment #798043 - Flags: review?(gps) → review+
Attachment #798043 - Attachment is obsolete: true
Comment on attachment 798049 [details] [diff] [review]
Replace invalid bytes in xpcshell binary string output

r=gps
Attachment #798049 - Flags: review+
try run looks good
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/da107dff7a83
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla26
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: