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

fix: ensure all excluded paths are included #231

Merged
merged 1 commit into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
All notable changes in **salt-lint** are documented below.

## [Unreleased]
### Fixed
- Ensure all excluded paths from both the CLI and configuration are passed to the runner ([#231](https://github.com/warpnet/salt-lint/pull/231)).

## [0.5.0] (2021-01-17)
### Added
- Rule 213 to recommend using cmd.run together with onchanges ([#207](https://github.com/warpnet/salt-lint/pull/207)).
Expand Down
3 changes: 2 additions & 1 deletion saltlint/linter/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def _update_exclude_paths(self, exclude_paths):
# These will be (potentially) relative paths
paths = [path.strip() for path in exclude_paths]
self.exclude_paths = paths + [os.path.abspath(path) for path in paths]
self.exclude_paths = []
else:
self.exclude_paths = []

def is_excluded(self, file_path):
# Any will short-circuit as soon as something returns True, but will
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import unittest

from saltlint.cli import run
from saltlint.config import Configuration
from saltlint.linter.runner import Runner


class TestRunner(unittest.TestCase):

Expand All @@ -18,3 +21,16 @@ def test_runner_without_matches(self):
# expected.
args = ['tests/test-extension-success.sls']
self.assertEqual(run(args), 0)

def test_runner_exclude_paths(self):
"""
Check if all the excluded paths from the configuration are passed to
the runner.
"""
exclude_paths = ['first.sls', 'second.sls']
config = Configuration(dict(exclude_paths=exclude_paths))
runner = Runner([], 'init.sls', config)

self.assertTrue(
any(path in runner.exclude_paths for path in exclude_paths)
)