Closed Bug 1278466 Opened 4 years ago Closed 4 years ago

mozunit raises "IndexError: list index out of range" instead of showing actual error

Categories

(Firefox Build System :: General, defect)

defect
Not set

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1274611

People

(Reporter: glandium, Assigned: glandium)

References

Details

Attachments

(1 file)

In some cases, test fail in a way where printFail doesn't have a message on its own, but there is an exception to be printed out. In that case, after bug 1272315 we fail before displaying the exception with the following trace:

 22:40:45     INFO -   File "/tools/python/lib/python2.7/unittest/case.py", line 351, in run
 22:40:45     INFO -     result.addError(self, sys.exc_info())
 22:40:45     INFO -   File "/builds/slave/try-m64-0000000000000000000000/build/src/config/mozunit.py", line 64, in addError
 22:40:45     INFO -     self.printFail(test, err)
 22:40:45     INFO -   File "/builds/slave/try-m64-0000000000000000000000/build/src/config/mozunit.py", line 76, in printFail
22:40:45 INFO - message = value.message.splitlines()[0]
Duplicate of this bug: 1278496
''.splitlines() returns [], not ['']. So when the message is empty, we
currently fail with IndexError when trying to get the first line in the
message.

Review commit: https://reviewboard.mozilla.org/r/58192/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/58192/
Attachment #8760687 - Flags: review?(gps)
It would be nice to get the contents of "value" in the error log when value.message contains nothing. eg:
    if value.message:
        message = value.message.splitlines()[0]
    else:
        message = value

produces output like this:
09:26:49  WARNING - TEST-UNEXPECTED-FAIL | x:/Task_1465288437/build/src/python/mozbuild/mozbuild/test/test_base.py | TestMozbuildObject.test_config_guess, line 285: [Error 193] %1 is not a valid Win32 application

which is a little more useful than not populating "message".
for extra points, getting the value of %1 into the message would probably save a lot of debugging time.
Comment on attachment 8760687 [details]
Bug 1278466 - mozunit: Avoid IndexError in printFail when the message is empty.

https://reviewboard.mozilla.org/r/58192/#review55122
Attachment #8760687 - Flags: review?(gps) → review+
(In reply to Rob Thijssen (:grenade - GMT) from comment #3)
> It would be nice to get the contents of "value" in the error log when
> value.message contains nothing. eg:
>     if value.message:
>         message = value.message.splitlines()[0]
>     else:
>         message = value
> 
> produces output like this:
> 09:26:49  WARNING - TEST-UNEXPECTED-FAIL |
> x:/Task_1465288437/build/src/python/mozbuild/mozbuild/test/test_base.py |
> TestMozbuildObject.test_config_guess, line 285: [Error 193] %1 is not a
> valid Win32 application
> 
> which is a little more useful than not populating "message".
> for extra points, getting the value of %1 into the message would probably
> save a lot of debugging time.

The %1 comes from Windows itself. If you want WindowsError to be better handled, that needs to be done in the code, not in mozunit. The former would make things better everywhere, including at runtime, while the latter would only make things better when running unit tests.
Interesting, bug 1274611, that landed a few hours ago (also reviewed by gps), does the same as the patch attached here... except it prints "NO MESSAGE" when value.message is empty.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1274611
I wish it had printed the contents of value. eg:
message = value.message.splitlines()[0] if value.message else value
I guess that might have introduced other problems.
Feel free to change the message. I didn't give that much thought to the review in the other bug.
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.