#!/usr/bin/env bash
# Local smoke test: build + run rcpufetch inside a real Linux container via podman.
#
# What this can and can't do, and why:
# - Native-arch Linux containers work for real (e.g. linux/arm64 on an Apple Silicon
#   podman machine): this actually builds and executes the binary on a different kernel
#   than the host macOS one, which is a genuine test.
# - Windows and FreeBSD/OpenBSD CANNOT run "in Docker/Podman" on this host at all --
#   containers share the host kernel, and Windows/BSD need their own kernel. That's not
#   a config problem, it's what a container is. Real coverage for those lives in CI
#   (.github/workflows/ci.yml): windows-latest is a real Windows VM, and
#   vmactions/freebsd-vm + vmactions/openbsd-vm boot real BSD VMs on the runner.
# - Emulated-arch Linux containers (amd64/ppc64le/riscv64 via qemu-user binfmt) were
#   tried here and are unreliable on podman-machine's applehv provider in this
#   environment (binfmt_misc registers fine but exec still fails with "Exec format
#   error"). GitHub Actions' ubuntu-latest runners do this reliably via `cross`
#   (see the cross-linux job in CI) -- that's the trustworthy place for it, not here.
set -euo pipefail
cd "$(dirname "$0")/.."

echo "== native-arch container build+run =="
podman run --rm \
  -v "$PWD":/src:Z -w /src \
  docker.io/library/rust:slim \
  bash -c '
    set -e
    cargo build --release --quiet
    ./target/release/rcpufetch --no-logo --style legacy
    ./target/release/rcpufetch --version
    cargo test --release --quiet
  '
