From 4e98c266b77d0629db2e313ab527b5180b16eaa9 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 4 Jul 2014 20:43:38 +0200 Subject: [PATCH] testconfig: Check the result of running the individual tests Currently the tests might find issues with the documentation but the exit code is still 0. This attemps to make the test_config check the result of each test and then return if an error has occurred. This should propagate all the way into a sys.exit() call. --- osmopy/osmotestconfig.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/osmopy/osmotestconfig.py b/osmopy/osmotestconfig.py index f9ebde0..8f9746d 100644 --- a/osmopy/osmotestconfig.py +++ b/osmopy/osmotestconfig.py @@ -27,12 +27,18 @@ import osmopy.osmoutil as osmoutil # Return true iff all the tests for the given config pass def test_config(app_desc, config, tmpdir, verbose=True): try: - test_config_atest(app_desc, config, verify_doc, verbose) + err = 0 + if test_config_atest(app_desc, config, verify_doc, verbose) > 0: + err += 1 newconfig = copy_config(tmpdir, config) - test_config_atest(app_desc, newconfig, write_config, verbose) - test_config_atest(app_desc, newconfig, token_vty_command, verbose) - return 0 + if test_config_atest(app_desc, newconfig, write_config, verbose) > 0: + err += 1 + + if test_config_atest(app_desc, newconfig, token_vty_command, verbose) > 0: + err += 1 + + return err # If there's a socket error, skip the rest of the tests for this config except IOError: @@ -93,7 +99,7 @@ def write_config(vty): # The only purpose of this function is to verify a working vty def token_vty_command(vty): vty.command("help") - return True + return 0 # This may warn about the same doc missing multiple times, by design