Add bats-core unit tests
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Start by reading the reusable functions in src/scripts/lib/*.sh and the existing jobs in .github/workflows/test-runner.yaml; inspect scripts/check-shellcheck.sh for the current target set. Add isolated Bats tests under tests/ with sandboxed setup and stub binaries, then add the unit test CI job and update the quality globs and README Testing section. Done means the specified library functions and shellcheck target selection have tests, bats tests/ runs locally and in CI, and the docs explain the unit and container integration split.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Context
~80 bash scripts with zero unit tests. src/scripts/lib/*.sh define sourced, reusable functions — ideal unit targets — but the only automated coverage is slow, container-based integration (test-runner.yaml cli/config/full/master jobs) plus post-run scripts/validate*.sh gates.
Spec
1. Tooling
- Install bats-core locally (release tarball) plus
bats-support/bats-assert/bats-file. - Layout:
tests/lib/<name>.batsmirroringsrc/scripts/lib/,tests/helpers/setup.bash,tests/stubs/(fake binaries),tests/fixtures/.
2. Unit-test targets (source lib, call in isolation)
src/scripts/lib/dnf-repo-add.sh—import_rpm_key_if_missing,install_repo_file_from_url,setup_copr_repo,setup_rpmfusion_free_repo,setup_docker_repo,setup_brave_repo,setup_nodesource_repo,setup_repo_from_manifest_line: stubrpmkeys/dnf/curl; assert repo-file and keyring outcomes and idempotency.src/scripts/lib/dnf-repos.sh—enable_copr_if_available: stubdnf copr enable.src/scripts/lib/dnf-packages.sh—append_packages_from_file,install_dnf_packages_individually,install_dnf_packages_from_file(s),install_collected_*: stubdnf; fixture lists; assert args and best-effort continuation.src/scripts/lib/dnf-maintain.sh—dnf_maintain_update,dnf_maintain_upgrade,dnf_maintain_cleanup: stubdnf; assert subcommand order.src/scripts/lib/flatpak-install.sh—install_flatpak_if_missing,install_flatpaks_from_file: stubflatpak; assert flathub remote args.src/scripts/lib/dotfiles-install.sh—expand_home_path,copy_dotfile_file,link_dotfiles_xdg_config_dirs,install_dotfiles_from_manifest: sandboxHOME/XDG_CONFIG_HOME.src/scripts/lib/run.sh,parallel.sh,zsh-login.sh,git-submodules.sh,gnome-session.sh— same pattern.scripts/check-shellcheck.sh— assert intended target set (fixture clean/dirty script).
3. Approach
setup()per test:mktemp -dsandbox; exportHOME,TEMP_DIR,PROJECT_ROOTinto it; prependtests/stubs/toPATH. No network, no real system mutation.- Exclude leaf installers (
src/scripts/install/**, incl.flatpaks.sh,bruno.sh,zoom.sh, …) — already exercised by container CI.
4. CI
- Add a fast
unit-testsjob (ubuntu-latest, no docker) to.github/workflows/test-runner.yaml: checkout → setup bats →bats tests/. Usebats-core/bats-actionpinned to the full-length commit SHA of its latest release (repo pinning convention), using itslib-pathoutput asBATS_LIB_PATH. - Extend shellcheck/shfmt globs so
tests/**is covered by the existing quality gate.
5. Docs
- README "Testing" section: local bats install +
bats tests/; unit vs. container-integration split.
Out of scope
Leaf script side effects, container integration jobs, scripts/validate*.sh gates.
- Lingua principale
- Shell
- Stelle
- 1
- Fork
- 0
- Merge medio
- 1h 7m
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di garretpatten/fedora-setup-scripts
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
Tutte le issue di garretpatten/fedora-setup-scripts
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
CloverCraftSMP/Season4#46 ·
-
ライブラリを追加Apertapriority middle
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
KATO-Hiro/AtCoderClans#13015 ·
I maintainer di solito rispondono entro 1 giorno
-
The action installs only the amd64 cloudflared package, so Arm runners failForse già presa @bfs2021 l’ha presa oggi. Apertaarea: install arm64 bash bug ci cloudflared compatibility developer-experience difficulty: easy documentation enhancement github-actions good first issue help wanted priority: P3 runners shell tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
flisk-sh/live-preview#2 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
area: install-setup needs-info question
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno