Skip to content

Commit

Permalink
ksconf sort: fix output glitch & glob unit test
Browse files Browse the repository at this point in the history
- Re-enable sort unittest for glob expansion for #59.  Support for this feature
  was added in v0.7.7 and the test should have been reintroduced at that time.
- Fix confusing output message.  Both "Error trying to process file" and
  "Replaced file" messages were incorrectly shown at the same time.
  • Loading branch information
lowell80 committed Jan 26, 2023
1 parent 8d4176e commit eb208cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 6 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ More changes:
Use ``{{layers_list}}`` to capture what unique layer names made their way into a tarball, and
use ``{{layers_hash}}`` when that list get too long to be manageable.

Bug fixes:

* Fixed ``sort`` bug where the user was incorrectly told that a file with errors was unexpectedly also successfully replaced.
The contradictory output messages have been cleaned up.
For clarity, this only occurred for inline replacement mode, and was purely an output issue, not a file handling problem.


Ksconf 0.9
----------
Expand Down
1 change: 1 addition & 0 deletions ksconf/commands/sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def run(self, args):
self.stderr.write("Error trying to process file {0}. "
"Error: {1}\n".format(conf, e))
failure = True
continue
if smart_rc == SMART_NOCHANGE:
if not args.quiet:
self.stderr.write("Nothing to update. "
Expand Down
7 changes: 2 additions & 5 deletions tests/test_cli_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,13 @@ def test_sort_inplace_returncodes(self):
self.assertEqual(ko.returncode, EXIT_CODE_SUCCESS)
self.assertRegex(ko.stderr, "^Nothing to update")

r''' # Leaving this enabled makes too much noise...
@unittest.expectedFailure
def test_sort_glob(self):
# Not yet implemented. Currently relying on the shell to do this.
# Implemented in 0.7.7 for Windows. Don't rely on shell for expansion
glob_pattern = self.twd.get_path("*.conf")
with ksconf_cli:
ko = ksconf_cli("sort", "-i", glob_pattern)
self.assertEqual(ko.returncode, EXIT_CODE_BAD_CONF_FILE)
self.assertRegex(ko.stderr, r"badfile\.conf")
'''
self.assertRegex(ko.stderr, r"(?i)error[^\r\n]+badfile\.conf")

def test_bad_file(self):
with ksconf_cli:
Expand Down

0 comments on commit eb208cf

Please sign in to comment.