Add bats-core unit tests
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 54/100
Línea de trabajo
Start with src/scripts/lib/*.sh to understand the listed functions, then review .github/workflows/test-runner.yaml and the existing shell lint configuration. Add isolated Bats tests under tests/ using sandboxed environment variables and stub binaries; run them with bats tests/ and the existing lint checks. Done means the specified library targets have unit coverage, a fast CI job runs it, and the README explains local testing.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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. No fast feedback loop exists for lib logic.
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(sandbox/stub loader),tests/stubs/(fake binaries),tests/fixtures/(package lists, dotfiles trees, manifest lines).
2. Unit-test targets (source lib, call in isolation)
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, assert copy idempotency, backup-then-symlink of pre-existing~/.config/<app>.src/scripts/lib/package-install.sh—append_packages_from_file,install_pacman_packages_from_file(s),install_collected_*,install_aur_packages*: stubpacmanonPATH, fixture lists, assert invocation args and continuation-on-failure.src/scripts/lib/aur-repo-add.sh/aur-repos.sh—add_arch_repo_if_missing,setup_repo_from_manifest_line,add_pacman_repos_parallel: stubpacman/git; assert idempotency (no duplicate repo entries).src/scripts/lib/run.sh/env.sh—ensure_temp_dir,run_script:TEMP_DIRdefaulting, best-effort (|| true) exit tolerance.src/scripts/lib/parallel.sh—parallel_run_best_effort,parallel_wait_pids,parallel_wait_pids_best_effort: pid log bookkeeping, failure aggregation.src/scripts/lib/zsh-login.sh(zsh_login_safe,ensure_zshrc_login_safe),git-submodules.sh(ensure_submodules_syncedwith a sandbox git repo),gnome-session.sh(gnome_session_activewith a fakedbus-send/gnome-shell).
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/**) — guarded one-liners already exercised by container CI.
4. CI
- Add a fast
unit-testsjob (ubuntu-latest, no docker) to.github/workflows/test-runner.yamlbefore the container jobs: checkout → setup bats →bats tests/. Usebats-core/bats-actionpinned to the full-length commit SHA of its latest release (repo pinning convention), passingBATS_LIB_PATHfrom itslib-pathoutput. - Extend
lint:shell-style globs sotests/**.bats/helpers are covered by the existing shellcheck/shfmt quality gate.
5. Docs
- README "Testing" section: local bats install +
bats tests/; note unit vs. container-integration split.
Out of scope
Leaf script side effects, container integration jobs, scripts/validate*.sh gates.
- Lenguaje dominante
- Shell
- Estrellas
- 1
- Forks
- 0
- Merge medio
- 5 h 34 min
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Issues similares
-
Dificultad 2/5 Menos de una hora Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
posthog
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
DobermanCore/Doberman-Core#827 ·
Los mantenedores suelen responder en 1 día
-
category:enhancement status:needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
nushell/nushell#19546 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
release.yml fetches the GitHub CLI keyring with a bare curl, the one workflow download with no retryAbiertobug ci phase:10 priority:p3
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
jimmy058910/jmo-security-repo#1629 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
achisolomon/software-factory#182 ·