From 017e2a93583cc9acbe0702322f460d30c8a344c8 Mon Sep 17 00:00:00 2001 From: Lucas Meneghel Rodrigues Date: Wed, 11 Jun 2014 01:54:06 -0300 Subject: [PATCH] docs: Update Output Plugins documentation Some brief documentation on the JSON output plugin and multiple output plugins. Signed-off-by: Lucas Meneghel Rodrigues --- docs/source/OutputPlugins.rst | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/docs/source/OutputPlugins.rst b/docs/source/OutputPlugins.rst index 6a643b88..d71ac166 100644 --- a/docs/source/OutputPlugins.rst +++ b/docs/source/OutputPlugins.rst @@ -62,6 +62,42 @@ simply use:: +Machine readable output - json +------------------------------ + +`JSON `__ is a widely used data exchange format. The +json avocado plugin outputs job information, similarly to the xunit output +plugin:: + + $ scripts/avocado --json run "sleeptest failtest synctest" + {"tests": [{"test": "sleeptest.1", "url": "sleeptest", "status": "PASS", "time": 1.4282619953155518}, {"test": "failtest.1", "url": "failtest", "status": "FAIL", "time": 0.34017300605773926}, {"test": "synctest.1", "url": "synctest", "status": "PASS", "time": 2.109131097793579}], "errors": 0, "skip": 0, "time": 3.87756609916687, "debuglog": "/home/lmr/avocado/logs/run-2014-06-11-01.35.15/debug.log", "pass": 2, "failures": 1, "total": 3} + +Multiple output plugins +----------------------- + +You can enable multiple output plugins at once, as long as only one of them +uses the standard output. For example, it is fine to use the xunit plugin on +stdout and the JSON plugin to output to a file:: + + $ scripts/avocado --xunit --json --json-output /tmp/result.json run "sleeptest synctest" + + + + + + + $ cat /tmp/result.json + {"tests": [{"test": "sleeptest.1", "url": "sleeptest", "status": "PASS", "time": 1.345332145690918}, {"test": "synctest.1", "url": "synctest", "status": "PASS", "time": 1.8685932159423828}], "errors": 0, "skip": 0, "time": 3.213925361633301, "debuglog": "/home/lmr/avocado/logs/run-2014-06-11-01.49.35/debug.log", "pass": 2, "failures": 0, "total": 2} + +But you won't be able to do the same without the --json-output flag passed to +the program:: + + $ scripts/avocado --xunit --json run "sleeptest synctest" + Avocado could not set --json and --xunit both to output to stdout. + Please set the output flag of one of them to a file to avoid conflicts. + +That's basically the only rule you need to follow. + Implementing other output formats --------------------------------- -- GitLab