Skip to content

Commit

Permalink
Adds --exit-0 flag to exit with code 0 even with failed tests but not…
Browse files Browse the repository at this point in the history
… when a fatal error occured
  • Loading branch information
kraigher committed Jun 11, 2015
1 parent 04d4d77 commit e70dd3a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ optional arguments:
Output path for compilation and simulation artifacts
-x XUNIT_XML, --xunit-xml XUNIT_XML
Xunit test report .xml file
--exit-0 Exit with code 0 even if a test failed. Still exits
with code 1 on fatal errors such as compilation
failure
-v, --verbose Print test output immediately and not only when
failure
--no-color Do not color output
Expand Down
8 changes: 8 additions & 0 deletions vunit/test/acceptance/test_artificial.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ def check(self, run_file, args=None, persistent_sim=True, clean=True, exit_code=
env=new_env)
self.assertEqual(retcode, exit_code)

def test_exit_0_flag(self):
self.check(self.artificial_run,
exit_code=1,
args=["lib.tb_fail"])
self.check(self.artificial_run,
exit_code=0,
args=["--exit-0", "lib.tb_fail"])


EXPECTED_REPORT = (
("passed", "lib.tb_pass"),
Expand Down
9 changes: 6 additions & 3 deletions vunit/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def test_filter(name):
elaborate_only=args.elaborate,
compile_builtins=compile_builtins,
simulator_factory=SimulatorFactory(args),
num_threads=args.num_threads)
num_threads=args.num_threads,
exit_0=args.exit_0)

def __init__(self, # pylint: disable=too-many-locals, too-many-arguments
output_path,
Expand All @@ -97,7 +98,8 @@ def __init__(self, # pylint: disable=too-many-locals, too-many-arguments
elaborate_only=False,
vhdl_standard='2008',
compile_builtins=True,
num_threads=1):
num_threads=1,
exit_0=False):

self._configure_logging(log_level)

Expand Down Expand Up @@ -129,6 +131,7 @@ def __init__(self, # pylint: disable=too-many-locals, too-many-arguments
self._project = None
self._create_project()
self._num_threads = num_threads
self._exit_0 = exit_0

if compile_builtins:
self.add_builtins(library_name="vunit_lib")
Expand Down Expand Up @@ -307,7 +310,7 @@ def main(self):
traceback.print_exc()
exit(1)

if not all_ok:
if (not all_ok) and (not self._exit_0):
exit(1)

exit(0)
Expand Down
6 changes: 6 additions & 0 deletions vunit/vunit_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def create_argument_parser(description=None):
default=None,
help='Xunit test report .xml file')

parser.add_argument('--exit-0',
default=False,
action="store_true",
help=('Exit with code 0 even if a test failed. '
'Still exits with code 1 on fatal errors such as compilation failure'))

parser.add_argument('-v', '--verbose', action="store_true",
default=False,
help='Print test output immediately and not only when failure')
Expand Down

0 comments on commit e70dd3a

Please sign in to comment.