Skip to content

Commit

Permalink
exit out with errcode if tested mechanisms fail or are missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Helveg committed Dec 12, 2023
1 parent 47cb53b commit a793b71
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ jobs:
run: mpiexec -n 2 coverage run -p -m unittest -v
- name: Test local package
run: |
glia pkg add ./tests/data/mods/Na.mod --local
glia pkg add ./tests/data/mods/Na.mod --local --name Na
glia compile
glia test Na
- name: Upload coverage reports
run: bash <(curl -s https://codecov.io/bash)
4 changes: 4 additions & 0 deletions glia/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def test(mechanisms, verbose=False):
mechanisms = _manager.resolver.index.keys()
successes = 0
tests = len(mechanisms)
ecode = 0
for mechanism in mechanisms:
mstr = "[OK]"
estr = ""
Expand All @@ -111,8 +112,10 @@ def test(mechanisms, verbose=False):
except LibraryError as e:
mstr = "[ERROR]"
estr = str(e)
ecode = 1
except UnknownAssetError as _:
mstr = "[?]"
ecode = 1
except TooManyMatchesError as e:
mstr = "[MULTI]"
estr = str(e)
Expand All @@ -126,6 +129,7 @@ def test(mechanisms, verbose=False):
click.echo(" -- " + estr)
if _mpi.main_node:
click.echo(f"Tests finished: {successes} out of {tests} passed")
exit(ecode)


@glia.command(help="Build an Arbor catalogue")
Expand Down
10 changes: 10 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ def test_show_unknown_pkg(self):
self.assertIn('Unknown PACKAGE "doesntexist"', result.output)
self.assertEqual(2, result.exit_code)

@_shared.skipUnlessTestMods
def test_test(self):
result = run_cli_command(["test", "Na"])

@_shared.skipUnlessTestMods
def test_test_unknown(self):
result = run_cli_command(["test", "unknown"], xfail=True)
self.assertIn("[?] unknown", result.output)
self.assertEqual(1, result.exit_code)

def test_cache(self):
result = run_cli_command(["cache"])
self.assertIn(
Expand Down

0 comments on commit a793b71

Please sign in to comment.