Skip to content

test: add coverage for source pipeline (sources.py) #1098

@mnadzam

Description

@mnadzam

src/fromager/sources.py has 44% unit test coverage. This module is the backbone of fromager's source acquisition and preparation pipeline -- every package processed flows through these functions.

Functions that already have dedicated unit tests:

  • resolve_source(), patch_source(), validate_sdist_filename(), scan_compiled_extensions(), _download_source_check() (partial), default_download_source(), prepare_new_source()

Scope -- Untested Functions

Function Lines Role
get_source_type() 45 Classifies source as SDIST/GIT/OVERRIDE
download_source() 60 Main download dispatcher (mocked in other tests but never directly tested)
get_source_provider() 126 Creates resolver provider from package settings and overrides
download_git_source() 235 Git clone with ref/tag/submodule handling
download_url() 305 HTTP download with retry and temp file handling
_takes_arg() 391 Checks if a callable accepts a given argument name
unpack_source() 396 Tarball/zip extraction and directory normalization
write_build_meta() 488 Build metadata serialization
read_build_meta() 508 Build metadata deserialization
prepare_source() 516 Source preparation dispatcher (mocked in other tests but never directly tested)
default_prepare_source() 568 Default source preparation with compiled-extension scan
build_sdist() 628 SDist build dispatcher
default_build_sdist() 692 Default sdist build
pep517_build_sdist() 732 PEP 517 sdist building
ensure_pkg_info() 765 PKG-INFO stub creation

Acceptance Criteria

  • get_source_type() -- test dispatch for sdist URLs, git URLs, and override settings
  • download_source() -- test git URL parsing (url@ref format) and dispatch paths
  • unpack_source() -- test extraction success, directory renaming, and invalid archive error handling
  • write_build_meta() / read_build_meta() -- test round-trip serialization
  • prepare_source() -- test plugin return handling (Path vs tuple)
  • ensure_pkg_info() -- test stub creation when PKG-INFO is missing
  • build_sdist() -- test validation logic with mocked build environment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions