osmith has submitted this change. ( https://gerrit.osmocom.org/c/python/osmo-python-tests/+/36935?usp=email )
Change subject: scripts/osmotestconfig: fail with trace on 1st err ......................................................................
scripts/osmotestconfig: fail with trace on 1st err
Make it easier to figure out why osmotestconfig failed, by failing on the first error instead of running multiple tests and displaying a failed error count at the end. Raise an error on failure, so we get a python trace.
Related: OS#6456 Change-Id: I6a243a2474fbfce63aea8e4418be2f4613808270 --- M scripts/osmotestconfig.py 1 file changed, 25 insertions(+), 24 deletions(-)
Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve
diff --git a/scripts/osmotestconfig.py b/scripts/osmotestconfig.py index a62edd7..8840741 100755 --- a/scripts/osmotestconfig.py +++ b/scripts/osmotestconfig.py @@ -24,25 +24,17 @@ import osmopy.osmoutil as osmoutil
-# Return true iff all the tests for the given config pass +# Run all tests for a given config, raise error on failure def test_config(app_desc, config, tmpdir, verbose=True): - try: - err = 0 - if test_config_atest(app_desc, config, verify_doc, verbose)[0] > 0: - err += 1 + if test_config_atest(app_desc, config, verify_doc, verbose)[0] > 0: + raise RuntimeError(f"{config}: verify_doc() failed")
- newconfig = copy_config(tmpdir, config) - if test_config_atest(app_desc, newconfig, write_config, verbose) > 0: - err += 1 + newconfig = copy_config(tmpdir, config) + if test_config_atest(app_desc, newconfig, write_config, verbose) > 0: + raise RuntimeError(f"{config}: write_config() failed")
- 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: - return 1 + if test_config_atest(app_desc, newconfig, token_vty_command, verbose) > 0: + raise RuntimeError(f"{config}: token_vty_command() failed")
def test_config_atest(app_desc, config, run_test, verbose=True): @@ -159,7 +151,6 @@ def test_all_apps(apps, app_configs, tmpdir="writtenconfig", verbose=True, confpath=".", ignore_configs=[]): check_configs_tested("doc/examples/", app_configs, ignore_configs) - errors = 0 for app in apps: if not app_exists(app): print("Skipping app %s (not found)" % app[1], file=sys.stderr) @@ -168,14 +159,9 @@ configs = app_configs[app[3]] for config in configs: config = os.path.join(confpath, config) - errors += test_config(app, config, tmpdir, verbose) + test_config(app, config, tmpdir, verbose)
- if not errors: - remove_tmpdir(tmpdir) - - if errors: - print("ERRORS: %d" % errors, file=sys.stderr) - return errors + remove_tmpdir(tmpdir)
if __name__ == '__main__':