Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvdb committed Jul 31, 2022
1 parent 26920e8 commit 928a6f2
Show file tree
Hide file tree
Showing 6 changed files with 478 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ jobs:
pip install -e .
- name: Install pytest
run: |
mamba install -c conda-forge black pyflakes pytest
mamba install -c conda-forge black pyflakes pytest-cov
- name: Test with pytest
run: |
pytest
pytest --cov=jgo --cov-report=term-missing --cov-fail-under=90
- name: Lint with pyflakes and black
shell: bash
run: |
Expand Down
11 changes: 7 additions & 4 deletions jgo/jgo.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ def _jgo_main(argv=sys.argv[1:], stdout=None, stderr=None):
completed_process.check_returncode()

except HelpRequested:
pass
parser.print_help()

except NoEndpointProvided:
Expand Down Expand Up @@ -508,7 +507,8 @@ def workspace_dir_from_coordinates(coordinates, cache_dir):
return workspace


def workspace_dir_from_endpoint_strings(endpoint_strings, cache_dir, shortcuts={}):
def workspace_dir_from_endpoint_strings(endpoint_strings, cache_dir, shortcuts={}): # pragma: no cover
"""Unused"""
if isinstance(endpoint_strings, str):
return workspace_dir_from_endpoint_strings(
split_endpoint_string(endpoint_strings)
Expand Down Expand Up @@ -769,7 +769,10 @@ def run(parser, argv=sys.argv[1:], stdout=None, stderr=None):
verbose=args.verbose,
link_type=link_type,
)
return _run(workspace, primary_endpoint, jvm_args, program_args, args.additional_jars, stdout, stderr)


def _run(workspace, primary_endpoint, jvm_args, program_args, additional_jars, stdout, stderr):
main_class_file = (
os.path.join(workspace, primary_endpoint.main_class)
if primary_endpoint.main_class
Expand All @@ -783,7 +786,7 @@ def run(parser, argv=sys.argv[1:], stdout=None, stderr=None):
jvm_args,
main_class,
*program_args,
additional_jars=args.additional_jars,
additional_jars=additional_jars,
stdout=stdout,
stderr=stderr,
check=False,
Expand Down Expand Up @@ -826,7 +829,7 @@ def run(parser, argv=sys.argv[1:], stdout=None, stderr=None):
jvm_args,
main_class,
*program_args,
additional_jars=args.additional_jars,
additional_jars=additional_jars,
stdout=stdout,
stderr=stderr,
check=False,
Expand Down
4 changes: 2 additions & 2 deletions jgo/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def add_jvm_args_as_necessary(argv, gc_option="-XX:+UseConcMarkSweepGC"):
Extend existing ``argv`` with reasonable default values for garbage collection and max heap size.
If ``-Xmx`` is not specified in ``argv``, set max heap size to half the system's memory.
:param argv: arugment vector
:param argv: argument vector
:param gc_option: Use this garbage collector settings, if any.
:return: ``argv`` with
"""
Expand Down Expand Up @@ -60,7 +60,7 @@ def main_from_endpoint(
:param primary_endpoint: The primary endpoint of the Java program you want to run.
:param repositories: Any maven repository that holds the required jars. Defaults to {'scijava.public': maven_scijava_repository()}.
:param primary_endpoint_version: Will be appended to ``primary_endpoint`` if it does not evaluate to ``False``
:param primary_endpoint_main_class: Will be appended to ``primary_endpoitn`` if it does not evaluate to ``False``.
:param primary_endpoint_main_class: Will be appended to ``primary_endpoint`` if it does not evaluate to ``False``.
:param secondary_endpoints: Any other endpoints that should be added.
:return: ``None``
"""
Expand Down
6 changes: 5 additions & 1 deletion tests/test_parsington.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ def run_parsington(cache_dir, link_type, parsington_args):
parser = jgo.jgo.jgo_parser()
argv = (IGNORE_JGORC, LINK_TYPE, link_type, PARSINGTON_ENDPOINT) + parsington_args
os.environ[jgo.jgo.jgo_cache_dir_environment_variable()] = cache_dir
return jgo.jgo.run(parser=parser, argv=argv, stdout=subprocess.PIPE)
try:
rv = jgo.jgo.run(parser=parser, argv=argv, stdout=subprocess.PIPE)
finally:
del os.environ[jgo.jgo.jgo_cache_dir_environment_variable()]
return rv


def resolve_parsington(cache_dir, link_type, m2_repo):
Expand Down
Loading

0 comments on commit 928a6f2

Please sign in to comment.