mbox series

[wic,0/2] tests/unit/test_ksparser_parse: parse the .wks file, fix a diskid crash

Message ID 20260717183507.3539287-1-twoerner@gmail.com
Headers show
Series tests/unit/test_ksparser_parse: parse the .wks file, fix a diskid crash | expand

Message

Trevor Woerner July 17, 2026, 6:35 p.m. UTC
This continues the standalone unit-test work, moving up from ksparser's
argparse types to the KickStart parser that drives a whole .wks file.
It keeps the shape the suite settled on: the source fix is its own
standalone commit, and the green test module lands last, so the suite
passes at every commit.

The fix: a bootloader line with --ptable msdos and a non-integer
--diskid builds its error message with "... % self.ptable". self is the
KickStart instance, which has no ptable attribute, so the interpolation
raises AttributeError before the intended KickStartError. The user gets
an opaque traceback instead of a described error. Interpolate the
offending value instead (matching the gpt branch just below), and fix
the "--ptbale" typo in the same message.

The test module adds end-to-end coverage for KickStart(): happy-path
part/bootloader lines, degenerate files (empty, comment-only, CRLF,
unknown directive), mutually-exclusive and invalid option combinations,
multiple-bootloader rejection, diskid parsing for both ptables, and
include handling. get_bitbake_var() is neutralised so the parser runs
with no BitBake and no host tools. Backing the fix out turns the two
msdos --diskid cases red.

Trevor Woerner (2):
  ksparser: fix crash on an invalid msdos --diskid
  tests/unit/test_ksparser_parse: cover the .wks KickStart parser

 src/wic/ksparser.py               |   4 +-
 tests/unit/test_ksparser_parse.py | 217 ++++++++++++++++++++++++++++++
 2 files changed, 219 insertions(+), 2 deletions(-)
 create mode 100644 tests/unit/test_ksparser_parse.py