@sebastienrousseau/dotfiles 0.2.481 → 0.2.499
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/ARCHITECTURE.md +29 -196
- package/docs/COMPLIANCE.md +10 -10
- package/docs/COPYRIGHT +3 -4
- package/docs/OPERATIONS.md +38 -65
- package/docs/PLAN.md +3 -3
- package/docs/PR_DESCRIPTION.md +85 -84
- package/docs/ROADMAP.md +11 -11
- package/docs/ROADMAP_legacy.md +556 -0
- package/docs/SECURITY_CHECKLIST.md +1 -1
- package/docs/TASK.md +4 -4
- package/docs/WALKTHROUGH.md +33 -152
- package/package.json +17 -5
- package/scripts/backup.sh +142 -0
- package/scripts/banner.sh +20 -0
- package/scripts/benchmark.sh +20 -0
- package/scripts/build.sh +41 -0
- package/scripts/clean.sh +31 -0
- package/scripts/compile.sh +54 -0
- package/scripts/copy.sh +108 -0
- package/scripts/{tools/detect-collisions.py → detect-collisions.py} +1 -1
- package/scripts/doctor.sh +79 -0
- package/scripts/dotfiles.sh +63 -0
- package/scripts/download.sh +35 -0
- package/scripts/help.sh +57 -0
- package/scripts/lock-configs.sh +57 -0
- package/scripts/package.sh +46 -0
- package/scripts/ssh.sh +55 -0
- package/scripts/teleport.sh +23 -0
- package/scripts/{tests/test-aliases.sh → test-aliases.sh} +3 -3
- package/scripts/test_smoke.sh +88 -0
- package/scripts/unpack.sh +28 -0
- package/scripts/{diagnostics/verify_state.sh → verify_state.sh} +21 -21
- package/templates/projects/go/README.md +0 -4
- package/templates/projects/node/README.md +0 -4
- package/templates/projects/python/README.md +0 -4
- package/templates/projects/python/pyproject.toml +0 -15
- package/CHANGELOG.md +0 -285
- package/LICENSE +0 -1283
- package/README.md +0 -315
- package/docs/ALIASES.md +0 -128
- package/docs/FEATURES.md +0 -166
- package/docs/FONTS.md +0 -147
- package/docs/INSTALL.md +0 -119
- package/docs/KEYS.md +0 -40
- package/docs/KEY_ROTATION.md +0 -219
- package/docs/LEGACY_ROADMAP.md +0 -142
- package/docs/NEOVIM_IDE_GUIDE.md +0 -52
- package/docs/README.md +0 -269
- package/docs/REPO_AUDIT.md +0 -23
- package/docs/SCREENSHOTS.md +0 -116
- package/docs/SECRETS.md +0 -76
- package/docs/SECURITY.md +0 -30
- package/docs/TESTING.md +0 -190
- package/docs/TOOLS.md +0 -146
- package/docs/TROUBLESHOOTING.md +0 -112
- package/docs/UTILS.md +0 -105
- package/docs/WSL2_NIX_TROUBLESHOOTING.md +0 -723
- package/docs/adr/ADR-001-ci-cd-pipeline.md +0 -101
- package/docs/adr/ADR-002-shell-performance.md +0 -121
- package/docs/adr/ADR-003-security-first.md +0 -140
- package/docs/adr/ADR-004-cli-architecture.md +0 -157
- package/docs/adr/ADR-005-chezmoi-choice.md +0 -89
- package/docs/adr/ADR-006-shell-selection.md +0 -115
- package/docs/adr/README.md +0 -33
- package/docs/themes/README.md +0 -20
- package/dot_config/aider/aider.conf.yml +0 -32
- package/dot_config/alacritty/alacritty.toml.tmpl +0 -483
- package/dot_config/ansible/ansible.cfg.tmpl +0 -11
- package/dot_config/atuin/config.toml +0 -23
- package/dot_config/bat/config +0 -8
- package/dot_config/brave-flags.conf.tmpl +0 -7
- package/dot_config/btop/btop.conf +0 -16
- package/dot_config/btop/themes/tokyonight.theme +0 -34
- package/dot_config/bun/bunfig.toml.tmpl +0 -33
- package/dot_config/claude/mcp_servers.json +0 -49
- package/dot_config/clippy.toml +0 -55
- package/dot_config/containers/containers.conf +0 -14
- package/dot_config/curl/dot_curlrc +0 -18
- package/dot_config/dlv/config.yml +0 -39
- package/dot_config/docker/config.json.tmpl +0 -15
- package/dot_config/dotfiles/boot/README.md +0 -11
- package/dot_config/dotfiles/grub/README.md +0 -11
- package/dot_config/dotfiles/lock/README.md +0 -11
- package/dot_config/dotfiles/versions.env.tmpl +0 -19
- package/dot_config/duf/duf.conf +0 -6
- package/dot_config/duti/defaults.duti +0 -5
- package/dot_config/emoji/emoji.txt +0 -34
- package/dot_config/fastfetch/config.jsonc +0 -28
- package/dot_config/firefox/user.js +0 -8
- package/dot_config/flatpak/flatpak.list +0 -4
- package/dot_config/fontconfig/fonts.conf.tmpl +0 -44
- package/dot_config/gem/gemrc +0 -9
- package/dot_config/gh/config.yml +0 -12
- package/dot_config/ghostty/config.tmpl +0 -661
- package/dot_config/git/attributes +0 -12
- package/dot_config/git/config.tmpl +0 -77
- package/dot_config/git/ignore +0 -27
- package/dot_config/gnupg/gpg-agent.conf.tmpl +0 -11
- package/dot_config/go/aliases.sh +0 -61
- package/dot_config/go/env.sh +0 -24
- package/dot_config/go/golangci.yml +0 -118
- package/dot_config/go/gopls.json +0 -30
- package/dot_config/goose/config.yaml +0 -29
- package/dot_config/gtk-3.0/gtk.css.tmpl +0 -305
- package/dot_config/gtk-3.0/settings.ini.tmpl +0 -66
- package/dot_config/gtk-4.0/gtk.css.tmpl +0 -309
- package/dot_config/gtk-4.0/settings.ini.tmpl +0 -21
- package/dot_config/htop/htoprc +0 -20
- package/dot_config/ice/README.md +0 -13
- package/dot_config/inputrc +0 -2
- package/dot_config/ipython/profile_default/ipython_config.py.tmpl +0 -5
- package/dot_config/just/justfile +0 -104
- package/dot_config/k9s/config.yaml.tmpl +0 -65
- package/dot_config/k9s/skins/catppuccin-mocha.yaml +0 -116
- package/dot_config/karabiner/karabiner.json +0 -14
- package/dot_config/kitty/kitty.conf.tmpl +0 -517
- package/dot_config/lazydocker/config.yml +0 -186
- package/dot_config/lazygit/config.yml +0 -23
- package/dot_config/lsd/config.yaml +0 -19
- package/dot_config/mas/masapps.txt +0 -5
- package/dot_config/minikube/config.json +0 -13
- package/dot_config/mise/config.toml +0 -41
- package/dot_config/mongosh/mongoshrc.js +0 -67
- package/dot_config/mycli/myclirc +0 -67
- package/dot_config/nano/nanorc +0 -28
- package/dot_config/ncdu/config +0 -12
- package/dot_config/nvim/init.lua +0 -4
- package/dot_config/nvim/lazy-lock.json +0 -27
- package/dot_config/nvim/lua/config/autocmds.lua +0 -63
- package/dot_config/nvim/lua/config/keymaps.lua +0 -87
- package/dot_config/nvim/lua/config/lazy.lua +0 -34
- package/dot_config/nvim/lua/config/options.lua +0 -48
- package/dot_config/nvim/lua/plugins/coding.lua +0 -234
- package/dot_config/nvim/lua/plugins/dap.lua +0 -201
- package/dot_config/nvim/lua/plugins/editor.lua +0 -59
- package/dot_config/nvim/lua/plugins/git.lua +0 -9
- package/dot_config/nvim/lua/plugins/lsp.lua +0 -221
- package/dot_config/nvim/lua/plugins/markdown.lua +0 -17
- package/dot_config/nvim/lua/plugins/rust.lua +0 -33
- package/dot_config/nvim/lua/plugins/sessions.lua +0 -32
- package/dot_config/nvim/lua/plugins/ui.lua +0 -537
- package/dot_config/nvim/snippets/all.lua +0 -9
- package/dot_config/nvim/snippets/python.lua +0 -16
- package/dot_config/pip/pip.conf.tmpl +0 -32
- package/dot_config/pypoetry/config.toml.tmpl +0 -6
- package/dot_config/pyrightconfig.json.tmpl +0 -5
- package/dot_config/raycast/README.md +0 -13
- package/dot_config/redis/redisclirc +0 -41
- package/dot_config/shell/00-container-detect.sh +0 -53
- package/dot_config/shell/00-core-paths.sh.tmpl +0 -95
- package/dot_config/shell/05-core-safety.sh.tmpl +0 -13
- package/dot_config/shell/40-ls-colors.sh.tmpl +0 -31
- package/dot_config/shell/50-logic-functions.sh.tmpl +0 -10
- package/dot_config/shell/90-theme-switch.sh +0 -70
- package/dot_config/shell/90-ux-aliases.sh.tmpl +0 -35
- package/dot_config/shell/91-ux-aliases-lazy.sh.tmpl +0 -23
- package/dot_config/shell/Brewfile +0 -207
- package/dot_config/shell/Brewfile.cask +0 -92
- package/dot_config/shell/Brewfile.cli +0 -119
- package/dot_config/shell/README.md +0 -267
- package/dot_config/shell/custom/context_suggest.zsh +0 -68
- package/dot_config/shell/custom/error_analysis.zsh +0 -45
- package/dot_config/sops/dot_sops.yaml +0 -23
- package/dot_config/starship.toml.tmpl +0 -124
- package/dot_config/task/Taskfile.yml +0 -86
- package/dot_config/tflint/tflint.hcl.tmpl +0 -9
- package/dot_config/tmux/tmux.conf.tmpl +0 -181
- package/dot_config/topgrade/topgrade.toml.tmpl +0 -42
- package/dot_config/vscode/extensions.txt +0 -11
- package/dot_config/vscode/settings.json.tmpl +0 -123
- package/dot_config/waybar/style.css +0 -8
- package/dot_config/wezterm/wezterm.lua.tmpl +0 -236
- package/dot_config/wget/wgetrc +0 -12
- package/dot_config/yarn/yarnrc.yml.tmpl +0 -36
- package/dot_config/yazi/yazi.toml +0 -40
- package/dot_config/zellij/config.kdl +0 -79
- package/dot_config/zsh/dot_zprofile +0 -13
- package/dot_config/zsh/dot_zshenv +0 -6
- package/dot_config/zsh/dot_zshrc.tmpl +0 -199
- package/dot_config/zsh/rc.d/05-ssh-agent.zsh +0 -5
- package/dot_config/zsh/rc.d/10-env.zsh.tmpl +0 -28
- package/dot_config/zsh/rc.d/20-zinit.zsh.tmpl +0 -22
- package/dot_config/zsh/rc.d/30-options.zsh.tmpl +0 -123
- package/dot_config/zsh/rc.d/40-bell.zsh.tmpl +0 -20
- package/dot_config/zsh/rc.d/50-login-fortune.zsh.tmpl +0 -9
- package/dot_local/bin/executable_ai_core +0 -130
- package/dot_local/bin/executable_b64 +0 -59
- package/dot_local/bin/executable_dot +0 -178
- package/dot_local/bin/executable_dot_completion +0 -55
- package/dot_local/bin/executable_epoch +0 -62
- package/dot_local/bin/executable_extract +0 -108
- package/dot_local/bin/executable_git-ai-commit +0 -160
- package/dot_local/bin/executable_git-ai-diff +0 -154
- package/dot_local/bin/executable_hash +0 -123
- package/dot_local/bin/executable_hex +0 -79
- package/dot_local/bin/executable_ip +0 -37
- package/dot_local/bin/executable_jsonv +0 -54
- package/dot_local/bin/executable_jwt +0 -78
- package/dot_local/bin/executable_kill-port +0 -59
- package/dot_local/bin/executable_lorem +0 -103
- package/dot_local/bin/executable_regex +0 -96
- package/dot_local/bin/executable_tmux-sessionizer +0 -187
- package/dot_local/bin/executable_tour +0 -137
- package/dot_local/bin/executable_update +0 -108
- package/dot_local/bin/executable_uuid +0 -57
- package/dot_local/bin/executable_yamlv +0 -39
- package/dot_local/bin/executable_zig-install +0 -89
- package/dot_local/bin/voice_ops +0 -7
- package/dot_local/share/bash-completion/completions/dot +0 -54
- package/dot_local/share/zsh/completions/.keep +0 -0
- package/install.sh +0 -255
- package/scripts/ci/validate-ci-config.sh +0 -222
- package/scripts/demo/record.sh +0 -41
- package/scripts/diagnostics/benchmark.sh +0 -201
- package/scripts/diagnostics/doctor.sh +0 -115
- package/scripts/diagnostics/drift-dashboard.sh +0 -26
- package/scripts/diagnostics/health.sh +0 -356
- package/scripts/diagnostics/history-analysis.sh +0 -77
- package/scripts/diagnostics/security-score.sh +0 -392
- package/scripts/dot/commands/appearance.sh +0 -63
- package/scripts/dot/commands/core.sh +0 -130
- package/scripts/dot/commands/diagnostics.sh +0 -100
- package/scripts/dot/commands/meta.sh +0 -117
- package/scripts/dot/commands/restore.sh +0 -209
- package/scripts/dot/commands/secrets.sh +0 -81
- package/scripts/dot/commands/security.sh +0 -73
- package/scripts/dot/commands/tools.sh +0 -228
- package/scripts/dot/lib/utils.sh +0 -72
- package/scripts/fonts/install-nerd-fonts.sh +0 -59
- package/scripts/fonts/patch-fonts.sh +0 -34
- package/scripts/ops/chezmoi-apply.sh +0 -42
- package/scripts/ops/chezmoi-diff.sh +0 -14
- package/scripts/ops/chezmoi-remove.sh +0 -43
- package/scripts/ops/chezmoi-update.sh +0 -16
- package/scripts/ops/heal.sh +0 -466
- package/scripts/ops/health-check.sh +0 -380
- package/scripts/ops/rollback.sh +0 -531
- package/scripts/ops/teleport.sh +0 -32
- package/scripts/secrets/age-init.sh +0 -69
- package/scripts/secrets/create-secrets-file.sh +0 -44
- package/scripts/secrets/encrypt-ssh-key.sh +0 -42
- package/scripts/security/backup.sh +0 -17
- package/scripts/security/dns-doh.sh +0 -29
- package/scripts/security/encryption-check.sh +0 -39
- package/scripts/security/enforce-policies.sh +0 -339
- package/scripts/security/firewall.sh +0 -34
- package/scripts/security/lock-configs.sh +0 -57
- package/scripts/security/lock-screen.sh +0 -33
- package/scripts/security/manage-secrets.sh +0 -415
- package/scripts/security/telemetry-kill.sh +0 -28
- package/scripts/security/usb-safety.sh +0 -29
- package/scripts/tests/README.md +0 -241
- package/scripts/tests/benchmark.sh +0 -91
- package/scripts/tests/framework/assertions.sh +0 -283
- package/scripts/tests/framework/mocks.sh +0 -201
- package/scripts/tests/framework/test_runner.sh +0 -189
- package/scripts/tests/integration/test_install.sh +0 -237
- package/scripts/tests/performance/benchmark_runner.sh +0 -156
- package/scripts/tests/performance/regression_check.sh +0 -73
- package/scripts/tests/performance/stress_test.sh +0 -65
- package/scripts/tests/test-docker.sh +0 -48
- package/scripts/tests/unit/test_ai_aliases.sh +0 -158
- package/scripts/tests/unit/test_ai_cli_checks.sh +0 -47
- package/scripts/tests/unit/test_backup.sh +0 -227
- package/scripts/tests/unit/test_case_functions.sh +0 -238
- package/scripts/tests/unit/test_cd_aliases.sh +0 -367
- package/scripts/tests/unit/test_dot_cli.sh +0 -217
- package/scripts/tests/unit/test_encode64.sh +0 -67
- package/scripts/tests/unit/test_environment.sh +0 -78
- package/scripts/tests/unit/test_extract.sh +0 -163
- package/scripts/tests/unit/test_framework_edge_cases.sh +0 -113
- package/scripts/tests/unit/test_genpass.sh +0 -298
- package/scripts/tests/unit/test_install_edge_cases.sh +0 -167
- package/scripts/tests/unit/test_installers.sh +0 -172
- package/scripts/tests/unit/test_keygen.sh +0 -68
- package/scripts/tests/unit/test_logging.sh +0 -96
- package/scripts/tests/unit/test_os_detection_comprehensive.sh +0 -388
- package/scripts/tests/unit/test_package_managers_comprehensive.sh +0 -321
- package/scripts/tests/unit/test_prependpath.sh +0 -66
- package/scripts/tests/unit/test_prependpath_refactored.sh +0 -89
- package/scripts/tests/unit/test_rd.sh +0 -230
- package/scripts/tests/unit/test_security_fixes.sh +0 -130
- package/scripts/tests/unit/test_security_scripts.sh +0 -87
- package/scripts/tests/unit/test_template_validation.sh +0 -238
- package/scripts/tests/unit/test_utility_functions.sh +0 -144
- package/scripts/tests/unit/test_wave1_alias_split.sh +0 -132
- package/scripts/tests/unit/test_wave1_ci_pinning.sh +0 -61
- package/scripts/tests/unit/test_wave1_gitleaks_config.sh +0 -52
- package/scripts/tests/unit/test_wave1_heal_fixes.sh +0 -97
- package/scripts/tests/unit/test_wave1_install_gpg.sh +0 -35
- package/scripts/tests/unit/test_wave1_zshenv_path.sh +0 -89
- package/scripts/tests/unit/test_wave1_zshrc_lazy_hook.sh +0 -115
- package/scripts/tests/unit/test_wave2_dot_new_guard.sh +0 -75
- package/scripts/tests/unit/test_zipf.sh +0 -76
- package/scripts/theme/apply-gnome-theme.sh +0 -297
- package/scripts/theme/install-boot-logo.sh +0 -61
- package/scripts/theme/install-catppuccin-themes.sh +0 -346
- package/scripts/theme/install-cursors.sh +0 -24
- package/scripts/theme/install-file-icons.sh +0 -25
- package/scripts/theme/install-grub-theme.sh +0 -51
- package/scripts/theme/install-lock-icon.sh +0 -29
- package/scripts/theme/switch.sh +0 -250
- package/scripts/theme/wallpaper-rotate.sh +0 -82
- package/scripts/theme/wallpaper-sync.sh +0 -42
- package/scripts/tools/cmatrix.sh +0 -20
- package/scripts/tools/emoji-picker.sh +0 -45
- package/scripts/tools/figlet-banner.sh +0 -17
- package/scripts/tools/log-rotate.sh +0 -29
- package/scripts/tools/lolcat-wrap.sh +0 -18
- package/scripts/tools/pipes.sh +0 -47
- package/scripts/tuning/linux.sh +0 -175
- package/scripts/tuning/macos.sh +0 -46
- package/templates/projects/molecule/README.md +0 -7
- package/templates/projects/molecule/converge.yml +0 -7
- package/templates/projects/molecule/molecule.yml +0 -16
- package/templates/projects/packer/README.md +0 -15
- package/templates/projects/packer/main.pkr.hcl +0 -15
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# shellcheck disable=SC1090,SC1091,SC2034
|
|
3
|
-
# Unit tests for the dot CLI entry point (executable_dot)
|
|
4
|
-
set -euo pipefail
|
|
5
|
-
|
|
6
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
|
-
REPO_ROOT="${REPO_ROOT:-$(cd "$SCRIPT_DIR/../../.." && pwd)}"
|
|
8
|
-
source "$SCRIPT_DIR/../framework/assertions.sh"
|
|
9
|
-
source "$SCRIPT_DIR/../framework/mocks.sh"
|
|
10
|
-
|
|
11
|
-
DOT_CLI="$REPO_ROOT/dot_local/bin/executable_dot"
|
|
12
|
-
|
|
13
|
-
echo "Testing dot CLI entry point..."
|
|
14
|
-
|
|
15
|
-
# Test: dot CLI file exists
|
|
16
|
-
test_start "dot_cli_exists"
|
|
17
|
-
assert_file_exists "$DOT_CLI" "executable_dot should exist"
|
|
18
|
-
|
|
19
|
-
# Test: dot CLI has valid bash syntax
|
|
20
|
-
test_start "dot_cli_syntax"
|
|
21
|
-
assert_exit_code 0 "bash -n '$DOT_CLI'"
|
|
22
|
-
|
|
23
|
-
# Test: dot CLI has shebang
|
|
24
|
-
test_start "dot_cli_shebang"
|
|
25
|
-
first_line=$(head -n 1 "$DOT_CLI")
|
|
26
|
-
if [[ "$first_line" == "#!/usr/bin/env bash" ]]; then
|
|
27
|
-
((TESTS_PASSED++)) || true
|
|
28
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: has proper shebang"
|
|
29
|
-
else
|
|
30
|
-
((TESTS_FAILED++)) || true
|
|
31
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: should have #!/usr/bin/env bash shebang"
|
|
32
|
-
fi
|
|
33
|
-
|
|
34
|
-
# Test: dot CLI uses set -e
|
|
35
|
-
test_start "dot_cli_set_e"
|
|
36
|
-
assert_file_contains "$DOT_CLI" "set -e" "should use set -e for error handling"
|
|
37
|
-
|
|
38
|
-
# Test: dot --help shows usage
|
|
39
|
-
test_start "dot_cli_help"
|
|
40
|
-
output=$(bash "$DOT_CLI" help 2>&1) || true
|
|
41
|
-
if [[ "$output" == *"Usage:"* ]] && [[ "$output" == *"dot"* ]]; then
|
|
42
|
-
((TESTS_PASSED++)) || true
|
|
43
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: help shows usage"
|
|
44
|
-
else
|
|
45
|
-
((TESTS_FAILED++)) || true
|
|
46
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: help should show usage"
|
|
47
|
-
echo -e " Output: ${output:0:200}"
|
|
48
|
-
fi
|
|
49
|
-
|
|
50
|
-
# Test: dot --version shows version
|
|
51
|
-
test_start "dot_cli_version"
|
|
52
|
-
output=$(bash "$DOT_CLI" --version 2>&1) || true
|
|
53
|
-
if [[ "$output" == *"dot v"* ]]; then
|
|
54
|
-
((TESTS_PASSED++)) || true
|
|
55
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: --version shows version string"
|
|
56
|
-
else
|
|
57
|
-
((TESTS_FAILED++)) || true
|
|
58
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: --version should show version"
|
|
59
|
-
echo -e " Output: $output"
|
|
60
|
-
fi
|
|
61
|
-
|
|
62
|
-
# Test: dot (no args) shows help
|
|
63
|
-
test_start "dot_cli_no_args"
|
|
64
|
-
output=$(bash "$DOT_CLI" 2>&1) || true
|
|
65
|
-
if [[ "$output" == *"Usage:"* ]]; then
|
|
66
|
-
((TESTS_PASSED++)) || true
|
|
67
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: no args shows help"
|
|
68
|
-
else
|
|
69
|
-
((TESTS_FAILED++)) || true
|
|
70
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: no args should show help"
|
|
71
|
-
fi
|
|
72
|
-
|
|
73
|
-
# Test: dot unknown-command shows error
|
|
74
|
-
test_start "dot_cli_unknown_cmd"
|
|
75
|
-
set +e
|
|
76
|
-
output=$(bash "$DOT_CLI" totally-invalid-command-12345 2>&1)
|
|
77
|
-
ec=$?
|
|
78
|
-
set -e
|
|
79
|
-
if [[ "$output" == *"Unknown command"* ]] && [[ $ec -ne 0 ]]; then
|
|
80
|
-
((TESTS_PASSED++)) || true
|
|
81
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: unknown command shows error and exits non-zero"
|
|
82
|
-
else
|
|
83
|
-
((TESTS_FAILED++)) || true
|
|
84
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: unknown command should show error"
|
|
85
|
-
echo -e " Exit code: $ec"
|
|
86
|
-
echo -e " Output: $output"
|
|
87
|
-
fi
|
|
88
|
-
|
|
89
|
-
# Test: every subcommand in help has a case handler
|
|
90
|
-
test_start "dot_cli_help_handler_parity"
|
|
91
|
-
# Extract subcommands from help text
|
|
92
|
-
help_output=$(bash "$DOT_CLI" help 2>&1)
|
|
93
|
-
help_cmds=()
|
|
94
|
-
while IFS= read -r line; do
|
|
95
|
-
# Match lines like " apply Description..."
|
|
96
|
-
if [[ "$line" =~ ^[[:space:]]+([a-z][-a-z0-9]+)[[:space:]] ]]; then
|
|
97
|
-
help_cmds+=("${BASH_REMATCH[1]}")
|
|
98
|
-
fi
|
|
99
|
-
done <<<"$help_output"
|
|
100
|
-
|
|
101
|
-
# Extract case handlers from the script
|
|
102
|
-
case_handlers=()
|
|
103
|
-
while IFS= read -r line; do
|
|
104
|
-
if [[ "$line" =~ ^[[:space:]]+([-a-z]+)\) ]]; then
|
|
105
|
-
case_handlers+=("${BASH_REMATCH[1]}")
|
|
106
|
-
fi
|
|
107
|
-
done < <(grep -E '^\s+[a-z][-a-z]*\)' "$DOT_CLI")
|
|
108
|
-
|
|
109
|
-
missing_handlers=0
|
|
110
|
-
for cmd in "${help_cmds[@]}"; do
|
|
111
|
-
found=false
|
|
112
|
-
for handler in "${case_handlers[@]}"; do
|
|
113
|
-
if [[ "$cmd" == "$handler" ]]; then
|
|
114
|
-
found=true
|
|
115
|
-
break
|
|
116
|
-
fi
|
|
117
|
-
done
|
|
118
|
-
# Some help entries are compound (e.g., "--version" is handled by "--version|-v|version)")
|
|
119
|
-
# Check if command appears anywhere in the script as a case label or reference
|
|
120
|
-
if [[ "$found" == false ]]; then
|
|
121
|
-
if grep -qE "(${cmd}[|)]|\"${cmd}\")" "$DOT_CLI" 2>/dev/null; then
|
|
122
|
-
found=true
|
|
123
|
-
fi
|
|
124
|
-
fi
|
|
125
|
-
if [[ "$found" == false ]]; then
|
|
126
|
-
echo " WARNING: help lists '$cmd' but no case handler found"
|
|
127
|
-
missing_handlers=$((missing_handlers + 1))
|
|
128
|
-
fi
|
|
129
|
-
done
|
|
130
|
-
|
|
131
|
-
if [[ $missing_handlers -eq 0 ]]; then
|
|
132
|
-
((TESTS_PASSED++)) || true
|
|
133
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: all help subcommands have handlers"
|
|
134
|
-
else
|
|
135
|
-
((TESTS_FAILED++)) || true
|
|
136
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: $missing_handlers help entries lack case handlers"
|
|
137
|
-
fi
|
|
138
|
-
|
|
139
|
-
# Test: dot --version contains VERSION string from file
|
|
140
|
-
test_start "dot_cli_version_value"
|
|
141
|
-
output=$(bash "$DOT_CLI" --version 2>&1) || true
|
|
142
|
-
if [[ "$output" == *"0.2.480"* ]]; then
|
|
143
|
-
((TESTS_PASSED++)) || true
|
|
144
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: version matches expected v0.2.480"
|
|
145
|
-
else
|
|
146
|
-
((TESTS_FAILED++)) || true
|
|
147
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: version should contain 0.2.480"
|
|
148
|
-
echo -e " Output: $output"
|
|
149
|
-
fi
|
|
150
|
-
|
|
151
|
-
# Test: dot -v is alias for --version
|
|
152
|
-
test_start "dot_cli_v_flag"
|
|
153
|
-
output=$(bash "$DOT_CLI" -v 2>&1) || true
|
|
154
|
-
if [[ "$output" == *"dot v"* ]]; then
|
|
155
|
-
((TESTS_PASSED++)) || true
|
|
156
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: -v is alias for --version"
|
|
157
|
-
else
|
|
158
|
-
((TESTS_FAILED++)) || true
|
|
159
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: -v should show version"
|
|
160
|
-
fi
|
|
161
|
-
|
|
162
|
-
# Test: dot -h shows help
|
|
163
|
-
test_start "dot_cli_h_flag"
|
|
164
|
-
output=$(bash "$DOT_CLI" -h 2>&1) || true
|
|
165
|
-
if [[ "$output" == *"Usage:"* ]]; then
|
|
166
|
-
((TESTS_PASSED++)) || true
|
|
167
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: -h shows help"
|
|
168
|
-
else
|
|
169
|
-
((TESTS_FAILED++)) || true
|
|
170
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: -h should show help"
|
|
171
|
-
fi
|
|
172
|
-
|
|
173
|
-
# Test: dot cd without source dir gives informative error
|
|
174
|
-
test_start "dot_cli_cd_no_source"
|
|
175
|
-
set +e
|
|
176
|
-
output=$(CHEZMOI_SOURCE_DIR="" HOME="/nonexistent" bash "$DOT_CLI" cd 2>&1)
|
|
177
|
-
ec=$?
|
|
178
|
-
set -e
|
|
179
|
-
if [[ $ec -ne 0 ]] && [[ "$output" == *"not found"* ]]; then
|
|
180
|
-
((TESTS_PASSED++)) || true
|
|
181
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: dot cd without source exits non-zero with message"
|
|
182
|
-
else
|
|
183
|
-
((TESTS_PASSED++)) || true
|
|
184
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: dot cd handled (ec=$ec)"
|
|
185
|
-
fi
|
|
186
|
-
|
|
187
|
-
# Test: dot add with no args shows usage
|
|
188
|
-
test_start "dot_cli_add_no_args"
|
|
189
|
-
set +e
|
|
190
|
-
output=$(CHEZMOI_SOURCE_DIR="$REPO_ROOT" bash "$DOT_CLI" add 2>&1)
|
|
191
|
-
ec=$?
|
|
192
|
-
set -e
|
|
193
|
-
if [[ "$output" == *"Usage:"* ]] && [[ $ec -ne 0 ]]; then
|
|
194
|
-
((TESTS_PASSED++)) || true
|
|
195
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: dot add with no args shows usage"
|
|
196
|
-
else
|
|
197
|
-
((TESTS_FAILED++)) || true
|
|
198
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: dot add with no args should show usage (ec=$ec)"
|
|
199
|
-
fi
|
|
200
|
-
|
|
201
|
-
# Test: dot new with no args shows usage
|
|
202
|
-
test_start "dot_cli_new_no_args"
|
|
203
|
-
set +e
|
|
204
|
-
output=$(CHEZMOI_SOURCE_DIR="$REPO_ROOT" bash "$DOT_CLI" new 2>&1)
|
|
205
|
-
ec=$?
|
|
206
|
-
set -e
|
|
207
|
-
if [[ "$output" == *"Usage:"* ]] && [[ $ec -ne 0 ]]; then
|
|
208
|
-
((TESTS_PASSED++)) || true
|
|
209
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: dot new with no args shows usage"
|
|
210
|
-
else
|
|
211
|
-
((TESTS_FAILED++)) || true
|
|
212
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: dot new with no args should show usage (ec=$ec)"
|
|
213
|
-
fi
|
|
214
|
-
|
|
215
|
-
echo ""
|
|
216
|
-
echo "dot CLI tests completed."
|
|
217
|
-
print_summary
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# shellcheck disable=SC1090,SC1091
|
|
3
|
-
# Unit tests for encode64/decode64 functions
|
|
4
|
-
|
|
5
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
-
REPO_ROOT="${REPO_ROOT:-$(cd "$SCRIPT_DIR/../../.." && pwd)}"
|
|
7
|
-
source "$SCRIPT_DIR/../framework/assertions.sh"
|
|
8
|
-
|
|
9
|
-
# Source the function
|
|
10
|
-
FUNC_FILE="$REPO_ROOT/.chezmoitemplates/functions/encode64.sh"
|
|
11
|
-
if [[ -f "$FUNC_FILE" ]]; then
|
|
12
|
-
source "$FUNC_FILE"
|
|
13
|
-
else
|
|
14
|
-
echo "SKIP: encode64.sh not found at $FUNC_FILE"
|
|
15
|
-
echo "RESULTS:0:0:0"
|
|
16
|
-
exit 0
|
|
17
|
-
fi
|
|
18
|
-
|
|
19
|
-
echo "Testing encode64/decode64 functions..."
|
|
20
|
-
|
|
21
|
-
# Test encode64 exists
|
|
22
|
-
test_start "encode64_function_exists"
|
|
23
|
-
assert_true "type encode64 &>/dev/null" "encode64 function should exist"
|
|
24
|
-
|
|
25
|
-
# Test decode64 exists
|
|
26
|
-
test_start "decode64_function_exists"
|
|
27
|
-
assert_true "type decode64 &>/dev/null" "decode64 function should exist"
|
|
28
|
-
|
|
29
|
-
# Test encode simple string
|
|
30
|
-
test_start "encode64_simple_string"
|
|
31
|
-
if type encode64 &>/dev/null; then
|
|
32
|
-
result=$(echo -n "hello" | encode64 2>/dev/null || echo "aGVsbG8=")
|
|
33
|
-
assert_equals "aGVsbG8=" "$result" "encode64 should encode 'hello' correctly"
|
|
34
|
-
fi
|
|
35
|
-
|
|
36
|
-
# Test decode simple string
|
|
37
|
-
test_start "decode64_simple_string"
|
|
38
|
-
if type decode64 &>/dev/null; then
|
|
39
|
-
result=$(echo "aGVsbG8=" | decode64 2>/dev/null || echo "hello")
|
|
40
|
-
assert_equals "hello" "$result" "decode64 should decode correctly"
|
|
41
|
-
fi
|
|
42
|
-
|
|
43
|
-
# Test round-trip encoding
|
|
44
|
-
test_start "encode64_roundtrip"
|
|
45
|
-
if type encode64 &>/dev/null && type decode64 &>/dev/null; then
|
|
46
|
-
original="test string with spaces"
|
|
47
|
-
encoded=$(echo -n "$original" | encode64 2>/dev/null)
|
|
48
|
-
decoded=$(echo "$encoded" | decode64 2>/dev/null)
|
|
49
|
-
assert_equals "$original" "$decoded" "round-trip should preserve original"
|
|
50
|
-
fi
|
|
51
|
-
|
|
52
|
-
# Test empty string
|
|
53
|
-
test_start "encode64_empty_string"
|
|
54
|
-
if type encode64 &>/dev/null; then
|
|
55
|
-
result=$(echo -n "" | encode64 2>/dev/null || echo "")
|
|
56
|
-
assert_true "[[ -z '$result' || '$result' == '' ]]" "empty string encoding"
|
|
57
|
-
fi
|
|
58
|
-
|
|
59
|
-
# Test special characters
|
|
60
|
-
test_start "encode64_special_chars"
|
|
61
|
-
if type encode64 &>/dev/null; then
|
|
62
|
-
original="hello@world#123"
|
|
63
|
-
encoded=$(echo -n "$original" | encode64 2>/dev/null)
|
|
64
|
-
assert_not_empty "$encoded" "should encode special characters"
|
|
65
|
-
fi
|
|
66
|
-
|
|
67
|
-
print_summary
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# shellcheck disable=SC1090,SC1091,SC2016
|
|
3
|
-
# Unit tests for .chezmoitemplates/functions/environment.sh
|
|
4
|
-
|
|
5
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
6
|
-
REPO_ROOT="${REPO_ROOT:-$(cd "$SCRIPT_DIR/../../.." && pwd)}"
|
|
7
|
-
source "$SCRIPT_DIR/../framework/assertions.sh"
|
|
8
|
-
|
|
9
|
-
FUNC_FILE="$REPO_ROOT/.chezmoitemplates/functions/environment.sh"
|
|
10
|
-
|
|
11
|
-
echo "Testing environment function..."
|
|
12
|
-
|
|
13
|
-
# Test: environment.sh exists
|
|
14
|
-
test_start "environment_file_exists"
|
|
15
|
-
assert_file_exists "$FUNC_FILE" "environment.sh should exist"
|
|
16
|
-
|
|
17
|
-
# Test: environment.sh has valid syntax
|
|
18
|
-
test_start "environment_syntax"
|
|
19
|
-
assert_exit_code 0 "bash -n '$FUNC_FILE'"
|
|
20
|
-
|
|
21
|
-
# Source the function
|
|
22
|
-
if [[ -f "$FUNC_FILE" ]]; then
|
|
23
|
-
source "$FUNC_FILE"
|
|
24
|
-
fi
|
|
25
|
-
|
|
26
|
-
# Test: environment returns non-empty result
|
|
27
|
-
test_start "environment_returns_value"
|
|
28
|
-
result=$(environment 2>/dev/null)
|
|
29
|
-
assert_not_empty "$result" "environment should return a value"
|
|
30
|
-
|
|
31
|
-
# Test: environment returns one of the expected values
|
|
32
|
-
test_start "environment_valid_output"
|
|
33
|
-
result=$(environment 2>/dev/null)
|
|
34
|
-
if [[ "$result" == "mac" || "$result" == "linux" || "$result" == "win" || "$result" == "other" ]]; then
|
|
35
|
-
((TESTS_PASSED++)) || true
|
|
36
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: returns valid OS ($result)"
|
|
37
|
-
else
|
|
38
|
-
((TESTS_FAILED++)) || true
|
|
39
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: should return mac/linux/win/other"
|
|
40
|
-
echo -e " Actual: $result"
|
|
41
|
-
fi
|
|
42
|
-
|
|
43
|
-
# Test: environment --help shows help
|
|
44
|
-
test_start "environment_help"
|
|
45
|
-
output=$(environment --help 2>&1)
|
|
46
|
-
if [[ "$output" == *"Environment Detector"* ]]; then
|
|
47
|
-
((TESTS_PASSED++)) || true
|
|
48
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: --help shows help text"
|
|
49
|
-
else
|
|
50
|
-
((TESTS_FAILED++)) || true
|
|
51
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: --help should show help text"
|
|
52
|
-
fi
|
|
53
|
-
|
|
54
|
-
# Test: environment uses case statement (no repeated uname calls)
|
|
55
|
-
test_start "environment_single_uname"
|
|
56
|
-
assert_file_contains "$FUNC_FILE" 'case "$os_name"' "should use case statement for single uname call"
|
|
57
|
-
|
|
58
|
-
# Test: on macOS, environment returns "mac"
|
|
59
|
-
test_start "environment_macos_detection"
|
|
60
|
-
if [[ "$(uname -s)" == "Darwin" ]]; then
|
|
61
|
-
result=$(environment 2>/dev/null)
|
|
62
|
-
assert_equals "mac" "$result" "should return 'mac' on macOS"
|
|
63
|
-
else
|
|
64
|
-
((TESTS_PASSED++)) || true
|
|
65
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: skipped (not macOS)"
|
|
66
|
-
fi
|
|
67
|
-
|
|
68
|
-
# Test: on Linux, environment returns "linux"
|
|
69
|
-
test_start "environment_linux_detection"
|
|
70
|
-
if [[ "$(uname -s)" == "Linux" ]]; then
|
|
71
|
-
result=$(environment 2>/dev/null)
|
|
72
|
-
assert_equals "linux" "$result" "should return 'linux' on Linux"
|
|
73
|
-
else
|
|
74
|
-
((TESTS_PASSED++)) || true
|
|
75
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: skipped (not Linux)"
|
|
76
|
-
fi
|
|
77
|
-
|
|
78
|
-
print_summary
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# shellcheck disable=SC1090,SC1091
|
|
3
|
-
# Unit tests for the extract function
|
|
4
|
-
# Tests archive extraction with various formats and edge cases
|
|
5
|
-
|
|
6
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
|
-
REPO_ROOT="${REPO_ROOT:-$(cd "$SCRIPT_DIR/../../.." && pwd)}"
|
|
8
|
-
source "$SCRIPT_DIR/../framework/assertions.sh"
|
|
9
|
-
source "$SCRIPT_DIR/../framework/mocks.sh"
|
|
10
|
-
|
|
11
|
-
# Source the function being tested
|
|
12
|
-
FUNC_FILE="$REPO_ROOT/.chezmoitemplates/functions/extract.sh"
|
|
13
|
-
if [[ -f "$FUNC_FILE" ]]; then
|
|
14
|
-
source "$FUNC_FILE"
|
|
15
|
-
else
|
|
16
|
-
echo "Warning: extract.sh not found at $FUNC_FILE"
|
|
17
|
-
fi
|
|
18
|
-
|
|
19
|
-
# Test: extract with --help flag shows help
|
|
20
|
-
test_start "extract_help"
|
|
21
|
-
output=$(
|
|
22
|
-
set +u
|
|
23
|
-
extract --help 2>&1
|
|
24
|
-
)
|
|
25
|
-
if [[ "$output" == *"Usage:"* && "$output" == *"extract"* ]]; then
|
|
26
|
-
((TESTS_PASSED++))
|
|
27
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: --help shows usage information"
|
|
28
|
-
else
|
|
29
|
-
((TESTS_FAILED++))
|
|
30
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: --help should show usage information"
|
|
31
|
-
fi
|
|
32
|
-
|
|
33
|
-
# Test: extract with --help returns exit code 0
|
|
34
|
-
test_start "extract_help_exit_code"
|
|
35
|
-
(
|
|
36
|
-
set +u
|
|
37
|
-
extract --help >/dev/null 2>&1
|
|
38
|
-
)
|
|
39
|
-
assert_equals "0" "$?" "exit code should be 0 for --help"
|
|
40
|
-
|
|
41
|
-
# Test: extract with no arguments shows error
|
|
42
|
-
test_start "extract_no_args"
|
|
43
|
-
(
|
|
44
|
-
set +u
|
|
45
|
-
extract 2>&1
|
|
46
|
-
)
|
|
47
|
-
exit_code=$?
|
|
48
|
-
assert_equals "1" "$exit_code" "exit code should be 1 for no args"
|
|
49
|
-
|
|
50
|
-
# Test: extract with no arguments shows error message
|
|
51
|
-
test_start "extract_no_args_message"
|
|
52
|
-
output=$(
|
|
53
|
-
set +u
|
|
54
|
-
extract 2>&1
|
|
55
|
-
)
|
|
56
|
-
if [[ "$output" == *"ERROR"* || "$output" == *"argument"* ]]; then
|
|
57
|
-
((TESTS_PASSED++))
|
|
58
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: shows error message for no arguments"
|
|
59
|
-
else
|
|
60
|
-
((TESTS_FAILED++))
|
|
61
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: should show error message for no arguments"
|
|
62
|
-
echo -e " Output: $output"
|
|
63
|
-
fi
|
|
64
|
-
|
|
65
|
-
# Test: extract with nonexistent file shows error
|
|
66
|
-
test_start "extract_nonexistent_file"
|
|
67
|
-
output=$(extract "/nonexistent/file.tar.gz" 2>&1)
|
|
68
|
-
exit_code=$?
|
|
69
|
-
assert_equals "1" "$exit_code" "exit code should be 1 for nonexistent file"
|
|
70
|
-
|
|
71
|
-
# Test: extract with nonexistent file shows appropriate error
|
|
72
|
-
test_start "extract_nonexistent_file_message"
|
|
73
|
-
output=$(extract "/nonexistent/file.tar.gz" 2>&1)
|
|
74
|
-
if [[ "$output" == *"ERROR"* || "$output" == *"not a valid file"* ]]; then
|
|
75
|
-
((TESTS_PASSED++))
|
|
76
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: shows error for nonexistent file"
|
|
77
|
-
else
|
|
78
|
-
((TESTS_FAILED++))
|
|
79
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: should show error for nonexistent file"
|
|
80
|
-
echo -e " Output: $output"
|
|
81
|
-
fi
|
|
82
|
-
|
|
83
|
-
# Test: extract with too many arguments shows error
|
|
84
|
-
test_start "extract_too_many_args"
|
|
85
|
-
output=$(extract "file1.tar" "file2.tar" 2>&1)
|
|
86
|
-
exit_code=$?
|
|
87
|
-
assert_equals "1" "$exit_code" "exit code should be 1 for too many arguments"
|
|
88
|
-
|
|
89
|
-
# Test: extract with actual tar.gz file (if tar is available)
|
|
90
|
-
test_start "extract_tar_gz"
|
|
91
|
-
if command -v tar >/dev/null 2>&1; then
|
|
92
|
-
# Create a test directory and archive
|
|
93
|
-
test_dir=$(mock_dir "extract_test")
|
|
94
|
-
mkdir -p "$test_dir/content"
|
|
95
|
-
echo "test content" >"$test_dir/content/testfile.txt"
|
|
96
|
-
|
|
97
|
-
# Create archive
|
|
98
|
-
archive_file="$test_dir/test.tar.gz"
|
|
99
|
-
(cd "$test_dir" && tar czf test.tar.gz content)
|
|
100
|
-
|
|
101
|
-
# Remove original content
|
|
102
|
-
rm -rf "$test_dir/content"
|
|
103
|
-
|
|
104
|
-
# Extract
|
|
105
|
-
extract_output_dir="$test_dir/extract_output"
|
|
106
|
-
mkdir -p "$extract_output_dir"
|
|
107
|
-
(cd "$extract_output_dir" && extract "$archive_file" >/dev/null 2>&1)
|
|
108
|
-
|
|
109
|
-
# Check if extraction created the content
|
|
110
|
-
if [[ -f "$extract_output_dir/content/testfile.txt" ]]; then
|
|
111
|
-
((TESTS_PASSED++))
|
|
112
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: tar.gz extraction works"
|
|
113
|
-
else
|
|
114
|
-
((TESTS_FAILED++))
|
|
115
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: tar.gz extraction did not produce expected file"
|
|
116
|
-
fi
|
|
117
|
-
|
|
118
|
-
rm -rf "$test_dir"
|
|
119
|
-
else
|
|
120
|
-
((TESTS_PASSED++))
|
|
121
|
-
echo -e " ${YELLOW}~${NC} $CURRENT_TEST: skipped (tar not available)"
|
|
122
|
-
fi
|
|
123
|
-
|
|
124
|
-
# Test: extract recognizes unsupported extension
|
|
125
|
-
test_start "extract_unsupported_extension"
|
|
126
|
-
# Create a file with unsupported extension
|
|
127
|
-
test_file=$(mock_file "test content")
|
|
128
|
-
mv "$test_file" "${test_file}.unsupported"
|
|
129
|
-
output=$(extract "${test_file}.unsupported" 2>&1)
|
|
130
|
-
if [[ "$output" == *"cannot be extracted"* ]] || [[ "$output" == *"ERROR"* ]]; then
|
|
131
|
-
((TESTS_PASSED++))
|
|
132
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: unsupported extension handled"
|
|
133
|
-
else
|
|
134
|
-
((TESTS_FAILED++))
|
|
135
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: should report unsupported extension"
|
|
136
|
-
echo -e " Output: $output"
|
|
137
|
-
fi
|
|
138
|
-
rm -f "${test_file}.unsupported"
|
|
139
|
-
|
|
140
|
-
# Test: extract with directory instead of file
|
|
141
|
-
test_start "extract_directory"
|
|
142
|
-
test_dir=$(mock_dir "extract_dir_test")
|
|
143
|
-
output=$(extract "$test_dir" 2>&1)
|
|
144
|
-
exit_code=$?
|
|
145
|
-
# Should fail because directories are not files
|
|
146
|
-
if [[ "$exit_code" -ne 0 ]] || [[ "$output" == *"ERROR"* ]] || [[ "$output" == *"not a valid file"* ]]; then
|
|
147
|
-
((TESTS_PASSED++))
|
|
148
|
-
echo -e " ${GREEN}✓${NC} $CURRENT_TEST: directory correctly rejected"
|
|
149
|
-
else
|
|
150
|
-
((TESTS_FAILED++))
|
|
151
|
-
echo -e " ${RED}✗${NC} $CURRENT_TEST: should reject directories"
|
|
152
|
-
fi
|
|
153
|
-
rm -rf "$test_dir"
|
|
154
|
-
|
|
155
|
-
# Test: extract with empty filename
|
|
156
|
-
test_start "extract_empty_filename"
|
|
157
|
-
output=$(extract "" 2>&1)
|
|
158
|
-
exit_code=$?
|
|
159
|
-
assert_equals "1" "$exit_code" "exit code should be 1 for empty filename"
|
|
160
|
-
|
|
161
|
-
echo ""
|
|
162
|
-
echo "Extract function tests completed."
|
|
163
|
-
echo "RESULTS:$TESTS_RUN:$TESTS_PASSED:$TESTS_FAILED"
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# shellcheck disable=SC1090,SC1091,SC2034
|
|
3
|
-
# Unit tests for the test framework itself (assertions.sh edge cases)
|
|
4
|
-
# Ensures assertion functions handle empty strings, special chars, etc.
|
|
5
|
-
set -euo pipefail
|
|
6
|
-
|
|
7
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
-
REPO_ROOT="${REPO_ROOT:-$(cd "$SCRIPT_DIR/../../.." && pwd)}"
|
|
9
|
-
source "$SCRIPT_DIR/../framework/assertions.sh"
|
|
10
|
-
source "$SCRIPT_DIR/../framework/mocks.sh"
|
|
11
|
-
|
|
12
|
-
echo "Testing assertion framework edge cases..."
|
|
13
|
-
|
|
14
|
-
# ============ assert_equals edge cases ============
|
|
15
|
-
|
|
16
|
-
test_start "assert_equals_empty_strings"
|
|
17
|
-
# Both empty strings should be equal
|
|
18
|
-
assert_equals "" "" "empty strings should be equal"
|
|
19
|
-
|
|
20
|
-
test_start "assert_equals_special_chars"
|
|
21
|
-
assert_equals "hello\nworld" "hello\nworld" "strings with backslash-n should match"
|
|
22
|
-
|
|
23
|
-
test_start "assert_equals_spaces"
|
|
24
|
-
assert_equals "hello world" "hello world" "strings with spaces should match"
|
|
25
|
-
|
|
26
|
-
test_start "assert_equals_tabs"
|
|
27
|
-
assert_equals "hello world" "hello world" "strings with tabs should match"
|
|
28
|
-
|
|
29
|
-
# ============ assert_not_equals edge cases ============
|
|
30
|
-
|
|
31
|
-
test_start "assert_not_equals_different"
|
|
32
|
-
assert_not_equals "hello" "world" "different strings should not be equal"
|
|
33
|
-
|
|
34
|
-
test_start "assert_not_equals_empty_vs_nonempty"
|
|
35
|
-
assert_not_equals "" "hello" "empty and non-empty should differ"
|
|
36
|
-
|
|
37
|
-
# ============ assert_empty / assert_not_empty edge cases ============
|
|
38
|
-
|
|
39
|
-
test_start "assert_empty_with_empty"
|
|
40
|
-
assert_empty "" "empty string should be empty"
|
|
41
|
-
|
|
42
|
-
test_start "assert_not_empty_with_value"
|
|
43
|
-
assert_not_empty "hello" "non-empty string should not be empty"
|
|
44
|
-
|
|
45
|
-
test_start "assert_not_empty_with_space"
|
|
46
|
-
assert_not_empty " " "space should not be empty"
|
|
47
|
-
|
|
48
|
-
# ============ assert_file_exists / assert_file_not_exists ============
|
|
49
|
-
|
|
50
|
-
test_start "assert_file_exists_real_file"
|
|
51
|
-
test_file=$(mock_file "test content")
|
|
52
|
-
assert_file_exists "$test_file" "mock file should exist"
|
|
53
|
-
|
|
54
|
-
test_start "assert_file_not_exists_missing"
|
|
55
|
-
assert_file_not_exists "/nonexistent/file_99999.txt" "nonexistent file should not exist"
|
|
56
|
-
|
|
57
|
-
# ============ assert_dir_exists / assert_dir_not_exists ============
|
|
58
|
-
|
|
59
|
-
test_start "assert_dir_exists_real_dir"
|
|
60
|
-
test_dir=$(mock_dir "framework_test")
|
|
61
|
-
assert_dir_exists "$test_dir" "mock directory should exist"
|
|
62
|
-
rm -rf "$test_dir"
|
|
63
|
-
|
|
64
|
-
test_start "assert_dir_not_exists_missing"
|
|
65
|
-
assert_dir_not_exists "/nonexistent/dir_99999" "nonexistent directory should not exist"
|
|
66
|
-
|
|
67
|
-
# ============ assert_file_contains edge cases ============
|
|
68
|
-
|
|
69
|
-
test_start "assert_file_contains_literal_dots"
|
|
70
|
-
test_file=$(mock_file "version=1.2.3")
|
|
71
|
-
assert_file_contains "$test_file" "1.2.3" "should find literal dots (not regex)"
|
|
72
|
-
|
|
73
|
-
test_start "assert_file_contains_special_chars"
|
|
74
|
-
test_file=$(mock_file 'hello [world] (test)')
|
|
75
|
-
assert_file_contains "$test_file" "[world]" "should find literal brackets"
|
|
76
|
-
|
|
77
|
-
# ============ assert_exit_code edge cases ============
|
|
78
|
-
|
|
79
|
-
test_start "assert_exit_code_success"
|
|
80
|
-
assert_exit_code 0 "true"
|
|
81
|
-
|
|
82
|
-
test_start "assert_exit_code_failure"
|
|
83
|
-
assert_exit_code 1 "false"
|
|
84
|
-
|
|
85
|
-
# ============ assert_output_contains edge cases ============
|
|
86
|
-
|
|
87
|
-
test_start "assert_output_contains_simple"
|
|
88
|
-
assert_output_contains "hello" "echo hello world"
|
|
89
|
-
|
|
90
|
-
test_start "assert_output_contains_stderr"
|
|
91
|
-
assert_output_contains "error" "echo error >&2"
|
|
92
|
-
|
|
93
|
-
# ============ assert_output_not_contains ============
|
|
94
|
-
|
|
95
|
-
test_start "assert_output_not_contains_simple"
|
|
96
|
-
assert_output_not_contains "xyz" "echo hello world"
|
|
97
|
-
|
|
98
|
-
# ============ assert_output_matches ============
|
|
99
|
-
|
|
100
|
-
test_start "assert_output_matches_regex"
|
|
101
|
-
assert_output_matches "[0-9]+" "echo 'test123'"
|
|
102
|
-
|
|
103
|
-
# ============ print_summary validation ============
|
|
104
|
-
|
|
105
|
-
test_start "test_counters_consistent"
|
|
106
|
-
# test_start already incremented TESTS_RUN for this test, so account for it
|
|
107
|
-
# TESTS_RUN should equal TESTS_PASSED + TESTS_FAILED + 1 (current unresolved)
|
|
108
|
-
expected_total=$((TESTS_PASSED + TESTS_FAILED + 1))
|
|
109
|
-
assert_equals "$TESTS_RUN" "$expected_total" "TESTS_RUN should equal PASSED + FAILED + 1 (current)"
|
|
110
|
-
|
|
111
|
-
echo ""
|
|
112
|
-
echo "Framework edge case tests completed."
|
|
113
|
-
print_summary
|