Patchwork [1,of,2] tests: make run-tests fail early if no channel is found

login
register
mail settings
Submitter Augie Fackler
Date May 31, 2017, 1:12 a.m.
Message ID <361bf17d190dbd3410be.1496193150@imladris.local>
Download mbox | patch
Permalink /patch/21085/
State Accepted
Headers show

Comments

Augie Fackler - May 31, 2017, 1:12 a.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1496191620 14400
#      Tue May 30 20:47:00 2017 -0400
# Node ID 361bf17d190dbd3410be4b7fd8ff4d27ddb48739
# Parent  9a0a243342b8a2c4d1f75215615785785844f0cb
tests: make run-tests fail early if no channel is found

I hit a weird corner case in run-tests where a test that caused an
exception to be raised was breaking everything with an unbound
variable error a few lines down because channel was never getting set
in this for loop. By adding an `else` clause to this for loop, we can
explode right away if we can't find a channel and give the developer a
better chance at figuring out what's going on.
Yuya Nishihara - June 1, 2017, 2:57 p.m.
On Tue, 30 May 2017 21:12:30 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1496191620 14400
> #      Tue May 30 20:47:00 2017 -0400
> # Node ID 361bf17d190dbd3410be4b7fd8ff4d27ddb48739
> # Parent  9a0a243342b8a2c4d1f75215615785785844f0cb
> tests: make run-tests fail early if no channel is found

Looks good. Queued, thanks.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1767,6 +1767,8 @@  class TestSuite(unittest.TestSuite):
                 if not v:
                     channel = n
                     break
+            else:
+                raise ValueError('Could not find output channel')
             channels[channel] = "=" + test.name[5:].split(".")[0]
             try:
                 test(result)