Skip to content

[quality] Unit tests needed for scripts/gen-filemap.py parsing logic #769

Description

@kubestellar-hive

Finding

scripts/gen-filemap.py (193 lines) contains several pure-logic functions with zero test coverage:

  • strip_ansi() — ANSI escape removal (regex-based)
  • guess_interval() — element-to-cadence mapping via substring matching
  • list_elements() — BST output parsing/filtering
  • list_all_contents() — tab-indented artifact listing parser (complex state machine)
  • main() — argparse, filemap assembly, manifest TSV generation

These functions are the backbone of Dakota's OCI layer mapping for chunkah. A bug here silently produces incorrect filemaps, which could cause broken image updates.

The parsing logic (especially list_all_contents) is highly unit-testable by mocking subprocess.run output — no BuildStream installation needed.

Recommendation

  1. Add tests/ directory with pytest-based unit tests
  2. Test strip_ansi(), guess_interval() with edge cases
  3. Test list_all_contents() parser with sample BST output (fixture-based)
  4. Add a CI workflow to run tests on PR/push
  5. Target ≥80% coverage for the parsing functions

Priority

  • Impact: high (incorrect filemap → broken image updates)
  • Effort: low (pure logic, no external deps needed for testing)

Filed by quality agent (hold-gated mode)

Dakota · issue pipeline

  ▶  triage     needs kind/ + area/ then /approve
  ·  discussing —
  ·  queued     —
  ·  claimed    —
  ·  done       —

area: —   priority:
maintainer: set kind/ + area/ labels, then comment /approve
reporter: answer questions; add repro steps if a bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    1-triageNew work awaiting human triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions