Skip to content

Commit

Permalink
fix: ensure all excluded paths are included
Browse files Browse the repository at this point in the history
Ensure all the excluded paths provided in the configuration and/or via
the CLI are passed to the runner.

Fixes #230

Signed-off-by: Roald Nefs <info@roaldnefs.com>
  • Loading branch information
roaldnefs committed Jan 19, 2021
1 parent ab17ad9 commit a35734e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
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)
)

0 comments on commit a35734e

Please sign in to comment.