From e6b5c4592786c34e82591c0a012a100af3800557 Mon Sep 17 00:00:00 2001 From: "jamie.gilbert" Date: Sun, 27 Oct 2019 12:07:39 -0700 Subject: [PATCH 1/3] added bad exit codes for test command --- gsmodutils/cli.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gsmodutils/cli.py b/gsmodutils/cli.py index b63234f..7048551 100644 --- a/gsmodutils/cli.py +++ b/gsmodutils/cli.py @@ -115,8 +115,8 @@ def test(project_path, test_id, skip_default, verbose, log_path): click.echo('Running tests: ') tester.progress_tests(skip_default=skip_default) click.echo() - ts = 0 - te = 0 + test_successes = 0 + test_errors = 0 for tf, log in tester.log.items(): @@ -127,8 +127,8 @@ def test(project_path, test_id, skip_default, verbose, log_path): click.echo("Test file {}:".format(tf)) indicator = "Test file" lc = log.log_count - ts += lc[0] - te += lc[1] + test_successes += lc[0] + test_errors += lc[1] click.echo("Counted {} test assertions with {} failures".format(*lc)) # Output base test file if not log.is_success: @@ -147,8 +147,8 @@ def test(project_path, test_id, skip_default, verbose, log_path): click.echo( click.style(barstr + ' End standard output ' + barstr, fg='black', bg='white') ) - percent = round(((ts - te) / ts) * 100, 3) - click.echo('Ran {} test assertions with a total of {} errors ({}% success)'.format(ts, te, percent)) + percent = round(((test_successes - test_errors) / test_successes) * 100, 3) + click.echo('Ran {} test assertions with a total of {} errors ({}% success)'.format(test_successes, test_errors, percent)) # Display errors for tf, e in tester.load_errors: @@ -175,6 +175,9 @@ def test(project_path, test_id, skip_default, verbose, log_path): json.dump(tester.to_dict(), lf, indent=4) click.echo('log file written to {}'.format(log_path)) + if test_errors > 0: + exit(-1) + @click.command() @click.argument('project_path', type=click.Path(writable=True)) From f4aa4113eb4f4a785b46a3dd3bde1b8ecf4df187 Mon Sep 17 00:00:00 2001 From: "jamie.gilbert" Date: Sun, 27 Oct 2019 12:52:28 -0700 Subject: [PATCH 2/3] modified tests --- tests/test_tests.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_tests.py b/tests/test_tests.py index 6e8e584..eda744f 100644 --- a/tests/test_tests.py +++ b/tests/test_tests.py @@ -75,12 +75,12 @@ def test_json_tests(): runner = CliRunner() result = runner.invoke(gsmodutils.cli.test, ['--project_path', fp.path, '--verbose']) - assert result.exit_code == 0 + assert result.exit_code == -1 result = runner.invoke(gsmodutils.cli.test, ['--project_path', fp.path, '--verbose', '--test_id', 'test_x.json']) - assert result.exit_code == 0 + assert result.exit_code == -1 def test_py_tests(): @@ -154,17 +154,17 @@ def test_model(model, project, log): runner = CliRunner() lpath = os.path.join(fp.path, 'lp.json') result = runner.invoke(gsmodutils.cli.test, ['--project_path', fp.path, '--verbose', '--log_path', lpath]) - assert result.exit_code == 0 + assert result.exit_code == -1 result = runner.invoke(gsmodutils.cli.test, ['--project_path', fp.path, '--verbose', '--test_id', test_codep]) - assert result.exit_code == 0 + assert result.exit_code == -1 result = runner.invoke(gsmodutils.cli.test, ['--project_path', fp.path, '--verbose', '--test_id', '{}::test_func'.format(test_codep)]) - assert result.exit_code == 0 + assert result.exit_code == -1 result = runner.invoke(gsmodutils.cli.test, ['--project_path', fp.path, '--verbose', '--test_id', 'test_syn_err.py']) From 5043bda8a6586f1365eea5206a046c625aa3cfb0 Mon Sep 17 00:00:00 2001 From: "jamie.gilbert" Date: Sun, 27 Oct 2019 13:45:28 -0700 Subject: [PATCH 3/3] modified test codes --- tests/test_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_tests.py b/tests/test_tests.py index eda744f..6fd0d13 100644 --- a/tests/test_tests.py +++ b/tests/test_tests.py @@ -80,7 +80,7 @@ def test_json_tests(): result = runner.invoke(gsmodutils.cli.test, ['--project_path', fp.path, '--verbose', '--test_id', 'test_x.json']) - assert result.exit_code == -1 + assert result.exit_code == 0 def test_py_tests(): @@ -159,7 +159,7 @@ def test_model(model, project, log): result = runner.invoke(gsmodutils.cli.test, ['--project_path', fp.path, '--verbose', '--test_id', test_codep]) - assert result.exit_code == -1 + assert result.exit_code == 0 result = runner.invoke(gsmodutils.cli.test, ['--project_path', fp.path, '--verbose', '--test_id', '{}::test_func'.format(test_codep)])