tests.test_binary module

Tests for repomatic.release.binary: the build roster and its asset names.

tests.test_binary.SHT_STRTAB = 3

ELF section type of a string table.

tests.test_binary.make_elf(machine, versions=(), *, wide=True, big_endian=False)[source]

Craft a minimal ELF file, requiring versions of libc when given.

Without versions the file holds a bare header and no section table. With them it carries a .dynstr string table and a .gnu.version_r section naming each one under a single libc.so.6 requirement, the way the linker writes them. wide picks ELF64 over ELF32, and big_endian the byte order, as the identification bytes declare them.

Return type:

bytes

tests.test_binary.pack_macho_version(version)[source]

Pack a major.minor string into a Mach-O version integer.

Return type:

int

tests.test_binary.make_macho(cpu_type, min_os='11.0')[source]

Craft a minimal 64-bit Mach-O header with one LC_BUILD_VERSION command.

Return type:

bytes

tests.test_binary.make_fat(slices)[source]

Wrap Mach-O slices into a universal (fat) container.

Return type:

bytes

tests.test_binary.make_pe(machine)[source]

Craft a minimal PE header exposing only the COFF machine type.

Return type:

bytes

tests.test_binary.macho_cpu_type(arch)[source]

The Mach-O cputype for an architecture, read for the byte builders.

MACHINE_IDS spans every format. These two accessors name the format for the helpers below, which write real header bytes.

Return type:

int

tests.test_binary.pe_machine_id(arch)[source]

The PE COFF Machine value for an architecture.

Return type:

int

tests.test_binary.test_all_targets_present(target)[source]

All expected targets are in the mapping.

tests.test_binary.test_pack_binary_assets(tmp_path)[source]

Aliases are byte-identical copies; Python distributions are skipped.

tests.test_binary.test_binary_format_detection(tmp_path, payload, expected)[source]

Executable formats are recognized from their magic bytes.

tests.test_binary.ASSET_ARCH_LABELS = {Architecture(id='aarch64', name='ARM64 (AArch64)'): 'arm64', Architecture(id='x86_64', name='x86-64 (AMD64)'): 'x64'}

Short architecture spellings frozen into the published release-asset names.

BuildTarget.arch carries the canonical extra-platforms id (aarch64, x86_64), while every published download URL says arm64 or x64. This maps one onto the other, so a target key and its fields cannot drift apart.

tests.test_binary.test_nuitka_targets(target_id, build_target)[source]
Return type:

None

tests.test_binary.test_matrix_entry_is_json_safe(target_id, build_target)[source]

No extra-platforms trait may leak into the GitHub matrix.

build_targets and nuitka_matrix are serialized into the metadata JSON the release workflow reads, so an Architecture object reaching one of those dicts breaks the whole release lane at metadata time.

Return type:

None

tests.test_binary.test_enforced_floor_follows_binary_format(target_id, build_target)[source]

Only ELF and Mach-O record a floor a scan can measure.

A PE carries a nominal version header, so its declared floor stays documentation and verify_binary_floor has nothing to enforce. The format’s floor_label is what says which of the two a target is in.

Return type:

None

tests.test_binary.test_macos_compiles_without_ccache_at_its_floor(target_id, build_target)[source]

macOS turns ccache off, keeps no cache, and pins its deployment target.

Every other target adds no option and no variable, and keeps its cache.

Return type:

None

tests.test_binary.test_current_build_target(monkeypatch, platform, architecture, expected)[source]

The machine’s platform and architecture pick its target.

tests.test_binary.test_nuitka_enabled_default()[source]

Test that nuitka.enabled config defaults to True.

tests.test_binary.test_nuitka_disabled_skips_matrix(tmp_path, monkeypatch)[source]

nuitka_matrix is None when nuitka is disabled in pyproject.toml.