Skip to content

Commit ee2ec74

Browse files
authored
Merge pull request #79 from jayvdb/more-tests
Add more tests
2 parents 8deb25f + c3b19ad commit ee2ec74

File tree

6 files changed

+493
-11
lines changed

6 files changed

+493
-11
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ jobs:
3535
pip install -e .
3636
- name: Install pytest
3737
run: |
38-
mamba install -c conda-forge black pyflakes pytest
38+
mamba install -c conda-forge black pyflakes pytest-cov
3939
- name: Test with pytest
4040
run: |
41-
pytest
41+
pytest --cov=jgo --cov-report=term-missing --cov-fail-under=90
4242
- name: Lint with pyflakes and black
4343
shell: bash
4444
run: |

jgo/jgo.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ def _jgo_main(argv=sys.argv[1:], stdout=None, stderr=None):
398398
completed_process.check_returncode()
399399

400400
except HelpRequested:
401-
pass
402401
parser.print_help()
403402

404403
except NoEndpointProvided:
@@ -508,7 +507,10 @@ def workspace_dir_from_coordinates(coordinates, cache_dir):
508507
return workspace
509508

510509

511-
def workspace_dir_from_endpoint_strings(endpoint_strings, cache_dir, shortcuts={}):
510+
def workspace_dir_from_endpoint_strings(
511+
endpoint_strings, cache_dir, shortcuts={}
512+
): # pragma: no cover
513+
"""Unused"""
512514
if isinstance(endpoint_strings, str):
513515
return workspace_dir_from_endpoint_strings(
514516
split_endpoint_string(endpoint_strings)
@@ -769,7 +771,20 @@ def run(parser, argv=sys.argv[1:], stdout=None, stderr=None):
769771
verbose=args.verbose,
770772
link_type=link_type,
771773
)
774+
return _run(
775+
workspace,
776+
primary_endpoint,
777+
jvm_args,
778+
program_args,
779+
args.additional_jars,
780+
stdout,
781+
stderr,
782+
)
783+
772784

785+
def _run(
786+
workspace, primary_endpoint, jvm_args, program_args, additional_jars, stdout, stderr
787+
):
773788
main_class_file = (
774789
os.path.join(workspace, primary_endpoint.main_class)
775790
if primary_endpoint.main_class
@@ -783,7 +798,7 @@ def run(parser, argv=sys.argv[1:], stdout=None, stderr=None):
783798
jvm_args,
784799
main_class,
785800
*program_args,
786-
additional_jars=args.additional_jars,
801+
additional_jars=additional_jars,
787802
stdout=stdout,
788803
stderr=stderr,
789804
check=False,
@@ -826,7 +841,7 @@ def run(parser, argv=sys.argv[1:], stdout=None, stderr=None):
826841
jvm_args,
827842
main_class,
828843
*program_args,
829-
additional_jars=args.additional_jars,
844+
additional_jars=additional_jars,
830845
stdout=stdout,
831846
stderr=stderr,
832847
check=False,

jgo/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def add_jvm_args_as_necessary(argv, gc_option="-XX:+UseConcMarkSweepGC"):
1010
Extend existing ``argv`` with reasonable default values for garbage collection and max heap size.
1111
If ``-Xmx`` is not specified in ``argv``, set max heap size to half the system's memory.
1212
13-
:param argv: arugment vector
13+
:param argv: argument vector
1414
:param gc_option: Use this garbage collector settings, if any.
1515
:return: ``argv`` with
1616
"""
@@ -60,7 +60,7 @@ def main_from_endpoint(
6060
:param primary_endpoint: The primary endpoint of the Java program you want to run.
6161
:param repositories: Any maven repository that holds the required jars. Defaults to {'scijava.public': maven_scijava_repository()}.
6262
:param primary_endpoint_version: Will be appended to ``primary_endpoint`` if it does not evaluate to ``False``
63-
:param primary_endpoint_main_class: Will be appended to ``primary_endpoitn`` if it does not evaluate to ``False``.
63+
:param primary_endpoint_main_class: Will be appended to ``primary_endpoint`` if it does not evaluate to ``False``.
6464
:param secondary_endpoints: Any other endpoints that should be added.
6565
:return: ``None``
6666
"""

tests/test_parsington.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ def run_parsington(cache_dir, link_type, parsington_args):
2222
parser = jgo.jgo.jgo_parser()
2323
argv = (IGNORE_JGORC, LINK_TYPE, link_type, PARSINGTON_ENDPOINT) + parsington_args
2424
os.environ[jgo.jgo.jgo_cache_dir_environment_variable()] = cache_dir
25-
return jgo.jgo.run(parser=parser, argv=argv, stdout=subprocess.PIPE)
25+
try:
26+
rv = jgo.jgo.run(parser=parser, argv=argv, stdout=subprocess.PIPE)
27+
finally:
28+
del os.environ[jgo.jgo.jgo_cache_dir_environment_variable()]
29+
return rv
2630

2731

2832
def resolve_parsington(cache_dir, link_type, m2_repo):

0 commit comments

Comments
 (0)