Last Comment Bug 787116 - Marionette's printLogs should write to stderr instead of stdout
: Marionette's printLogs should write to stderr instead of stdout
Status: RESOLVED FIXED
[mentor=mdas][lang=py][good first bug]
:
Product: Testing
Classification: Components
Component: Marionette (show other bugs)
: unspecified
: All All
: -- normal (vote)
: mozilla18
Assigned To: Hao Gao (:hao)
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-30 09:49 PDT by Jonathan Griffin (:jgriffin)
Modified: 2012-09-07 10:05 PDT (History)
3 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
a patch (1.20 KB, patch)
2012-09-06 14:34 PDT, Hao Gao (:hao)
jgriffin: review+
Details | Diff | Splinter Review

Description Jonathan Griffin (:jgriffin) 2012-08-30 09:49:06 PDT
Marionette uses Python's unittest runner to run tests.  TextTestRunner outputs test results to stderr, instead of stdout, to avoid the buffering that takes places with stdout. 

Marionette's printLogs function (http://mxr.mozilla.org/mozilla-central/source/testing/marionette/client/marionette/runtests.py#65), on the other hand, just uses print, which goes to stdout.  This does get buffered, and the result is, when running a sequence of tests, that the log info does not get printed immediately after a test, as is desired, but sometime later, when the stdout buffer gets flushed.

To fix this, we should have printLogs output to MarionetteTextTestRunner.stream, which by default is sys.stderr.
Comment 1 Hao Gao (:hao) 2012-09-05 17:01:38 PDT
If I made some changes to the code, how can I verify the result? Run the runtests.py?
Comment 2 Jonathan Griffin (:jgriffin) 2012-09-05 17:10:37 PDT
(In reply to Hao Gao from comment #1)
> If I made some changes to the code, how can I verify the result? Run the
> runtests.py?

Yes, you can run it with desktop Firefox using a command-line like this:

python runtests.py --address localhost:2828 --binary /path/to/firefox --type browser tests/unit-tests.ini
Comment 3 Jonathan Griffin (:jgriffin) 2012-09-05 17:11:22 PDT
I should add that in order to get a Firefox build that has Marionette enabled, you should download a debug build from e.g., http://stage.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux-debug/ (or other, depending on your platform).
Comment 4 Hao Gao (:hao) 2012-09-06 14:34:38 PDT
Created attachment 659003 [details] [diff] [review]
a patch

Please review it.
Comment 5 Jonathan Griffin (:jgriffin) 2012-09-07 10:03:06 PDT
Comment on attachment 659003 [details] [diff] [review]
a patch

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

Looks great, thanks for contributing a patch!
Comment 6 Jonathan Griffin (:jgriffin) 2012-09-07 10:05:50 PDT
https://hg.mozilla.org/mozilla-central/rev/00a552f644a2

Note You need to log in before you can comment on or make changes to this bug.