All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] test/py: ensure a log section exists for skipped tests
@ 2016-10-17 23:25 Stephen Warren
  2016-10-19 20:13 ` [U-Boot] " Tom Rini
  2016-10-24  1:40 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Stephen Warren @ 2016-10-17 23:25 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

In pytest 3, runtestprotocol() may not call pytest_runtest_setup() if
the test is skipped. That call is required to create a section for the
test in the log file. If this is skipped, the call to log.end_section()
at the tail of pytest_runtest_protocol() will throw an exception. This
patch ensures that a log section always exists, both to avoid the
exception and to ensure that a consistently structured log file is
always created.

Cc: Stefan Br?ns <stefan.bruens@rwth-aachen.de>
Reported-by: Stefan Br?ns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 test/py/conftest.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/test/py/conftest.py b/test/py/conftest.py
index 5b3a92316bbf..1f15e3e33dcf 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -431,6 +431,9 @@ def setup_buildconfigspec(item):
         if not ubconfig.buildconfig.get('config_' + option.lower(), None):
             pytest.skip('.config feature not enabled')
 
+def start_test_section(item):
+    anchors[item.name] = log.start_section(item.name)
+
 def pytest_runtest_setup(item):
     """pytest hook: Configure (set up) a test item.
 
@@ -444,7 +447,7 @@ def pytest_runtest_setup(item):
         Nothing.
     """
 
-    anchors[item.name] = log.start_section(item.name)
+    start_test_section(item)
     setup_boardspec(item)
     setup_buildconfigspec(item)
 
@@ -464,6 +467,14 @@ def pytest_runtest_protocol(item, nextitem):
 
     reports = runtestprotocol(item, nextitem=nextitem)
 
+    # In pytest 3, runtestprotocol() may not call pytest_runtest_setup() if
+    # the test is skipped. That call is required to create the test's section
+    # in the log file. The call to log.end_section() requires that the log
+    # contain a section for this test. Create a section for the test if it
+    # doesn't already exist.
+    if not item.name in anchors:
+        start_test_section(item)
+
     failure_cleanup = False
     test_list = tests_passed
     msg = 'OK'
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] test/py: ensure a log section exists for skipped tests
  2016-10-17 23:25 [U-Boot] [PATCH] test/py: ensure a log section exists for skipped tests Stephen Warren
@ 2016-10-19 20:13 ` Tom Rini
  2016-10-24  1:40 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2016-10-19 20:13 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 17, 2016 at 05:25:52PM -0600, Stephen Warren wrote:

> From: Stephen Warren <swarren@nvidia.com>
> 
> In pytest 3, runtestprotocol() may not call pytest_runtest_setup() if
> the test is skipped. That call is required to create a section for the
> test in the log file. If this is skipped, the call to log.end_section()
> at the tail of pytest_runtest_protocol() will throw an exception. This
> patch ensures that a log section always exists, both to avoid the
> exception and to ensure that a consistently structured log file is
> always created.
> 
> Cc: Stefan Br?ns <stefan.bruens@rwth-aachen.de>
> Reported-by: Stefan Br?ns <stefan.bruens@rwth-aachen.de>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>

travis-ci will give a failing setup without this patch and I can confirm
it's better with this now.

Tested-by: Tom Rini <trini@konsulko.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161019/91ca25e1/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] test/py: ensure a log section exists for skipped tests
  2016-10-17 23:25 [U-Boot] [PATCH] test/py: ensure a log section exists for skipped tests Stephen Warren
  2016-10-19 20:13 ` [U-Boot] " Tom Rini
@ 2016-10-24  1:40 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2016-10-24  1:40 UTC (permalink / raw)
  To: u-boot

On Mon, Oct 17, 2016 at 05:25:52PM -0600, Stephen Warren wrote:

> From: Stephen Warren <swarren@nvidia.com>
> 
> In pytest 3, runtestprotocol() may not call pytest_runtest_setup() if
> the test is skipped. That call is required to create a section for the
> test in the log file. If this is skipped, the call to log.end_section()
> at the tail of pytest_runtest_protocol() will throw an exception. This
> patch ensures that a log section always exists, both to avoid the
> exception and to ensure that a consistently structured log file is
> always created.
> 
> Cc: Stefan Br?ns <stefan.bruens@rwth-aachen.de>
> Reported-by: Stefan Br?ns <stefan.bruens@rwth-aachen.de>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> Tested-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161023/0e9619a0/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-24  1:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-17 23:25 [U-Boot] [PATCH] test/py: ensure a log section exists for skipped tests Stephen Warren
2016-10-19 20:13 ` [U-Boot] " Tom Rini
2016-10-24  1:40 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.