Skip to content

Commit

Permalink
Fail on exist violations (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
blablatdinov authored May 28, 2024
1 parent 08a013b commit 130e45e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
14 changes: 7 additions & 7 deletions ondivi/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ def main() -> None:
]),
)
args = parser.parse_args()
violations = sys.stdin.read().strip().splitlines()
sys.stdout.write('\n'.join(
controller(
Repo('.').git.diff('--unified=0', args.baseline),
violations,
),
))
violations = controller(
Repo('.').git.diff('--unified=0', args.baseline),
sys.stdin.read().strip().splitlines(),
)
sys.stdout.write('\n'.join(violations))
sys.stdout.write('\n')
if violations:
sys.exit(1)


if __name__ == '__main__':
Expand Down
20 changes: 12 additions & 8 deletions tests/it/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,10 @@ def test_gitpython_versions(version: str) -> None:
).stdout,
stdout=subprocess.PIPE,
check=False,
).stdout.decode('utf-8').strip()
)

assert got == 'file.py:4:80: E501 line too long (119 > 79 characters)'
assert got.stdout.decode('utf-8').strip() == 'file.py:4:80: E501 line too long (119 > 79 characters)'
assert got.returncode == 1


@pytest.mark.usefixtures('_test_repo')
Expand All @@ -79,9 +80,10 @@ def test() -> None:
).stdout,
stdout=subprocess.PIPE,
check=False,
).stdout.decode('utf-8').strip()
)

assert got == 'file.py:4:80: E501 line too long (119 > 79 characters)'
assert got.stdout.decode('utf-8').strip() == 'file.py:4:80: E501 line too long (119 > 79 characters)'
assert got.returncode == 1


@pytest.mark.usefixtures('_test_repo')
Expand All @@ -95,9 +97,10 @@ def test_baseline_default() -> None:
).stdout,
stdout=subprocess.PIPE,
check=False,
).stdout.decode('utf-8').strip()
)

assert got == 'file.py:4:80: E501 line too long (119 > 79 characters)'
assert got.stdout.decode('utf-8').strip() == 'file.py:4:80: E501 line too long (119 > 79 characters)'
assert got.returncode == 1


@pytest.mark.usefixtures('_test_repo')
Expand All @@ -111,12 +114,13 @@ def test_ruff() -> None:
).stdout,
stdout=subprocess.PIPE,
check=False,
).stdout.decode('utf-8').strip()
)

assert got == '\n'.join([
assert got.stdout.decode('utf-8').strip() == '\n'.join([
'file.py:4:5: T201 `print` found',
'file.py:4:11: Q000 [*] Single quotes found but double quotes preferred',
'file.py:4:89: E501 Line too long (119 > 88)',
'Found 13 errors.',
'[*] 4 fixable with the `--fix` option (4 hidden fixes can be enabled with the `--unsafe-fixes` option).',
])
assert got.returncode == 1

0 comments on commit 130e45e

Please sign in to comment.