Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 Coverage report on new empty project fails hiding stderr of subproccess #222

Open
ckunki opened this issue Jul 15, 2024 · 1 comment
Labels
bug Unwanted / harmful behavior

Comments

@ckunki
Copy link
Contributor

ckunki commented Jul 15, 2024

File exasol/toolbox/metrics.py in method total_coverage() calls subprocess.run():

        run(
            ["coverage", "json", f"--data-file={file}", "-o", f"{report}"],
            capture_output=True,
            check=True,
        )

A sample CI build displays the following error message.

subprocess.CalledProcessError: Command '['coverage', 'json', 
'--data-file=.coverage', 
'-o', '/tmp/tmpd9c4d11b/coverage.json']' 
returned non-zero exit status 2.
nox > Session report failed.

The current ticket proposes to

  • surround the call by try/catch and
  • When catching CalledProcessError then report stdout and stderr of the subprocess
  • re-raise the exception then again

Additionally

I was able to make coverage report terminate successfully by

  • adding a function to __init__.py, e.g. (see below)
  • importing the function into the test and verifying its value in the test:

File __init__.py:

def sample_function():
    return True

file test/unit/unit_smoke_test.py:

import {{ cookiecutter.import_package }}

def test_unit_smoke_test():
    assert {{cookiecutter.package_name}}.sample_function() 
@ckunki ckunki added the bug Unwanted / harmful behavior label Jul 15, 2024
@Nicoretti
Copy link
Member

Importing the pre-existing version constant(s) would likely yield a more sensible test.

For example, a unit test that verifies the version in version.py is in sync with the version in pyproject.toml could simultaneously address two issues:

  1. The explicit version check workflow step could be eliminated.
  2. Some code from the module in question would be tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unwanted / harmful behavior
Projects
None yet
Development

No branches or pull requests

2 participants