From a39138aaa64c8449f660cd833435bc5e4140ec88 Mon Sep 17 00:00:00 2001 From: furedea <132188853+furedea@users.noreply.github.com> Date: Wed, 11 Nov 2026 02:02:21 +0900 Subject: [PATCH 1/4] test(esa): run the Neovim specs on Linux The specs relied on ~/.config/nvim pointing at the repository, so put the repository nvim directory on runtimepath, and add neovim to the dev shell. Co-Authored-By: Claude Sonnet 5.5 --- flake.nix | 2 ++ tests/esa/nvim.bats | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 64fe8743..7f4c482e 100644 --- a/flake.nix +++ b/flake.nix @@ -196,6 +196,8 @@ shellPkgs.actionlint shellPkgs.bats shellPkgs.commitlint + # Headless Neovim runs the esa and LSP Bats specs on Linux. + shellPkgs.neovim # lefthook before 2.1.6 runs hooks under a pty, which agent sandboxes deny. shellUnstable.lefthook # Same uv and Python as the Home Manager profile; Nix owns the interpreter, uv owns dependencies. diff --git a/tests/esa/nvim.bats b/tests/esa/nvim.bats index 95728c76..b9126aa1 100644 --- a/tests/esa/nvim.bats +++ b/tests/esa/nvim.bats @@ -14,7 +14,7 @@ setup() { ESA_EDIT_POST_NUMBER=1515 \ ESA_EDIT_FILE="$ARTICLE_FILE" \ XDG_DATA_HOME="$NVIM_DATA_HOME" \ - nvim --headless -u "$REPO_ROOT/nvim/init.lua" \ + nvim --headless --cmd "set runtimepath^=$REPO_ROOT/nvim" -u "$REPO_ROOT/nvim/init.lua" \ "$ARTICLE_FILE" \ -c "call setline(1, '# After')" \ -c write \ @@ -32,7 +32,7 @@ setup() { ESA_EDIT_POST_NUMBER=1515 \ ESA_EDIT_FILE="$ARTICLE_FILE" \ XDG_DATA_HOME="$NVIM_DATA_HOME" \ - nvim --headless -u "$REPO_ROOT/nvim/init.lua" \ + nvim --headless --cmd "set runtimepath^=$REPO_ROOT/nvim" -u "$REPO_ROOT/nvim/init.lua" \ "$other_file" \ -c "call setline(1, '# Changed')" \ -c write \ From 1a9fe2ee8c8db0a242429104abf22bac775db39c Mon Sep 17 00:00:00 2001 From: furedea <132188853+furedea@users.noreply.github.com> Date: Wed, 11 Nov 2026 02:02:22 +0900 Subject: [PATCH 2/4] ci: run every Bats file on Linux except those tagged macos CI discovers tests recursively and excludes files tagged macos, so a new Bats file can no longer drop out silently. macOS-only specs get a file tag and a reason; mixed files are split into *_macos.bats, and the SSH directory mode check now uses a portable find -perm. Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/ci.yml | 3 +- README.md | 7 ++++ tests/herdr/herdr_command.bats | 3 ++ tests/nix/agent_hook.bats | 3 ++ tests/nix/codex_notification.bats | 3 ++ tests/nix/configuration.bats | 3 ++ tests/ssh-agent/load_identity.bats | 4 +-- tests/terminal-browser/terminal_browser.bats | 3 ++ tests/zsh/ssh_agent.bats | 37 ++------------------ tests/zsh/ssh_agent_macos.bats | 22 ++++++++++++ tests/zsh/startup.bats | 17 --------- tests/zsh/startup_macos.bats | 28 +++++++++++++++ tests/zsh/test-helper/ssh_agent.bash | 26 ++++++++++++++ 13 files changed, 104 insertions(+), 55 deletions(-) create mode 100644 tests/zsh/ssh_agent_macos.bats create mode 100644 tests/zsh/startup_macos.bats create mode 100644 tests/zsh/test-helper/ssh_agent.bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f5ce9c1..bf2e712d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,8 @@ jobs: sudo apt-get install -y --no-install-recommends zsh - name: Run Bats tests - run: uv run bats --print-output-on-failure tests/esa/zsh.bats tests/moshi/update_moshi_hook.bats tests/codex/update_codex.bats + # Discovery keeps new files in CI; files tagged macos need a macOS host and are excluded. + run: uv run bats --recursive --filter-tags '!macos' --print-output-on-failure tests - name: Run Python integration tests # The installed macOS popup profile is checked locally; static TOML checks run on Linux. diff --git a/README.md b/README.md index 8390d011..411ce4f7 100644 --- a/README.md +++ b/README.md @@ -351,6 +351,13 @@ uv run --frozen pytest nix flake check ``` +Bats files that need a macOS host or builder, such as ones that build the +aarch64-darwin Home Manager configuration, carry `# bats file_tags=macos` and a +comment stating why. Put such tests in their own file (for example +`_macos.bats`) so the tag applies to the whole file. CI runs +`bats --recursive --filter-tags '!macos' tests`, so an untagged file must pass on +Linux, while `bats --recursive tests` on a Mac runs everything. + CI checks shell integration with Bats and checks Python automation with Ruff, ty, and pytest. Tests marked `integration` run in the Bats job; other pytest tests run separately without duplicating those cases. diff --git a/tests/herdr/herdr_command.bats b/tests/herdr/herdr_command.bats index 6de03076..a461b629 100755 --- a/tests/herdr/herdr_command.bats +++ b/tests/herdr/herdr_command.bats @@ -1,5 +1,8 @@ #!/usr/bin/env bats # Executable specifications for Nix-managed Herdr command helpers. +# macOS only: builds the aarch64-darwin Home Manager configuration, which needs a macOS host or builder. +# bats file_tags=macos + bats_require_minimum_version 1.5.0 diff --git a/tests/nix/agent_hook.bats b/tests/nix/agent_hook.bats index 9c193d3d..2b8b9105 100644 --- a/tests/nix/agent_hook.bats +++ b/tests/nix/agent_hook.bats @@ -1,5 +1,8 @@ #!/usr/bin/env bats # Executable specifications for external agent hook composition. +# macOS only: builds the aarch64-darwin Home Manager activation package, which needs a macOS host or builder. +# bats file_tags=macos + bats_require_minimum_version 1.5.0 diff --git a/tests/nix/codex_notification.bats b/tests/nix/codex_notification.bats index 893f7b54..5e1cbd93 100644 --- a/tests/nix/codex_notification.bats +++ b/tests/nix/codex_notification.bats @@ -2,6 +2,9 @@ # Codex delegates terminal notifications only when launched inside Herdr. # Bats isolates each test's environment. # shellcheck disable=SC2030,SC2031 +# macOS only: builds the codex package for aarch64-darwin, which needs a macOS host or builder. +# bats file_tags=macos + setup_file() { local _repo_root _derivation _package diff --git a/tests/nix/configuration.bats b/tests/nix/configuration.bats index 92fd456e..c75ba46b 100644 --- a/tests/nix/configuration.bats +++ b/tests/nix/configuration.bats @@ -1,5 +1,8 @@ #!/usr/bin/env bats # The hook's Bats entry point delegates declarative contracts to native flake checks. +# macOS only: builds the aarch64-darwin flake checks, which need a macOS host or builder. +# bats file_tags=macos + bats_require_minimum_version 1.5.0 diff --git a/tests/ssh-agent/load_identity.bats b/tests/ssh-agent/load_identity.bats index df3e1862..9b66c0d4 100644 --- a/tests/ssh-agent/load_identity.bats +++ b/tests/ssh-agent/load_identity.bats @@ -31,10 +31,10 @@ evaluate_ssh_directory_permissions() { [ "$status" -eq 0 ] [ -f "$BATS_TEST_TMPDIR/home/.ssh/existing-file" ] - run /usr/bin/stat -f "%Lp" "$BATS_TEST_TMPDIR/home/.ssh" + run find "$BATS_TEST_TMPDIR/home/.ssh" -maxdepth 0 -perm 0700 [ "$status" -eq 0 ] - [ "$output" = "700" ] + [ "$output" = "$BATS_TEST_TMPDIR/home/.ssh" ] } @test "home activation reports a missing SSH public key" { diff --git a/tests/terminal-browser/terminal_browser.bats b/tests/terminal-browser/terminal_browser.bats index 2fb9d1f5..0fc442b8 100644 --- a/tests/terminal-browser/terminal_browser.bats +++ b/tests/terminal-browser/terminal_browser.bats @@ -1,5 +1,8 @@ #!/usr/bin/env bats # Executable specifications for the terminal-browser package. +# macOS only: runs the darwin-arm64 terminal-browser binary. +# bats file_tags=macos + bats_require_minimum_version 1.5.0 diff --git a/tests/zsh/ssh_agent.bats b/tests/zsh/ssh_agent.bats index df474435..b4bb9e09 100644 --- a/tests/zsh/ssh_agent.bats +++ b/tests/zsh/ssh_agent.bats @@ -2,28 +2,8 @@ # Interactive Zsh points SSH_AUTH_SOCK at the user's 1Password agent, never at another local agent. setup() { - REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)" - export REPO_ROOT - export TEST_HOME="$BATS_TEST_TMPDIR/home" - export AGENT_DIR="$TEST_HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t" - export AGENT_SOCKET="$AGENT_DIR/agent.sock" - unset SSH_AUTH_SOCK SSH_CONNECTION - mkdir -p "$AGENT_DIR" "$TEST_HOME/.config/zsh" "$TEST_HOME/ghq/github.com/furedea/dotfiles/zsh" - # The full path exceeds the sockaddr_un limit, so bind by a relative name. - /usr/bin/perl -MIO::Socket::UNIX -e 'chdir $ARGV[0] or die $!; IO::Socket::UNIX->new(Local => "agent.sock", Listen => 1) or die $!' "$AGENT_DIR" - touch "$TEST_HOME/.config/zsh/nix-plugins.zsh" - touch "$TEST_HOME/ghq/github.com/furedea/dotfiles/zsh/esa.zsh" -} - -run_startup() { - # Expand variables in the child Zsh, not in the Bats process. - # shellcheck disable=SC2016 - run env HOME="$TEST_HOME" zsh -dfi -c ' - source "$REPO_ROOT/zsh/.zshenv" - function autoload compinit carapace abbr atuin direnv starship zoxide() { :; } - source "$REPO_ROOT/zsh/.zshrc" - print -r -- "${SSH_AUTH_SOCK:-unset}" - ' + load test-helper/ssh_agent + setup_agent_environment } @test "noninteractive startup does not attach an agent" { @@ -32,19 +12,6 @@ run_startup() { [ "$output" = unset ] } -@test "startup attaches the 1Password agent when none is inherited" { - run_startup - [ "$status" -eq 0 ] - [ "$output" = "$AGENT_SOCKET" ] -} - -@test "startup replaces the login session's local agent with 1Password" { - export SSH_AUTH_SOCK="$BATS_TEST_TMPDIR/apple-agent" - run_startup - [ "$status" -eq 0 ] - [ "$output" = "$AGENT_SOCKET" ] -} - @test "startup preserves an agent forwarded into a remote session" { export SSH_CONNECTION="192.0.2.1 50000 192.0.2.2 22" export SSH_AUTH_SOCK="$BATS_TEST_TMPDIR/forwarded-agent" diff --git a/tests/zsh/ssh_agent_macos.bats b/tests/zsh/ssh_agent_macos.bats new file mode 100644 index 00000000..bdfe74c4 --- /dev/null +++ b/tests/zsh/ssh_agent_macos.bats @@ -0,0 +1,22 @@ +#!/usr/bin/env bats +# Interactive Zsh attaches the user's 1Password agent. +# macOS only: zsh/.zshrc attaches the 1Password agent only when OSTYPE is darwin. +# bats file_tags=macos + +setup() { + load test-helper/ssh_agent + setup_agent_environment +} + +@test "startup attaches the 1Password agent when none is inherited" { + run_startup + [ "$status" -eq 0 ] + [ "$output" = "$AGENT_SOCKET" ] +} + +@test "startup replaces the login session's local agent with 1Password" { + export SSH_AUTH_SOCK="$BATS_TEST_TMPDIR/apple-agent" + run_startup + [ "$status" -eq 0 ] + [ "$output" = "$AGENT_SOCKET" ] +} diff --git a/tests/zsh/startup.bats b/tests/zsh/startup.bats index bd0e67b3..41dd2209 100644 --- a/tests/zsh/startup.bats +++ b/tests/zsh/startup.bats @@ -271,20 +271,3 @@ run_startup_path() { print -rl -- "${path[@]}" ' } - -@test "Home Manager activation invokes the packaged Zsh cache builder" { - run --separate-stderr nix build --no-link --print-out-paths \ - "$TEST_FLAKE#homeConfigurations.\"kaito@mbp\".activationPackage" - - if [ "$status" -ne 0 ]; then - printf '%s\n' "$stderr" >&2 - fi - [ "$status" -eq 0 ] - - local _activation_package="$output" - [ -f "$_activation_package/activate" ] - local _builder - _builder="$(grep -Eo '/nix/store/[^"[:space:]]+-build_cache[.]zsh' "$_activation_package/activate" | head -n 1)" - [ -f "$_builder" ] - cmp --silent "$REPO_ROOT/zsh/build_cache.zsh" "$_builder" -} diff --git a/tests/zsh/startup_macos.bats b/tests/zsh/startup_macos.bats new file mode 100644 index 00000000..c4b19a85 --- /dev/null +++ b/tests/zsh/startup_macos.bats @@ -0,0 +1,28 @@ +#!/usr/bin/env bats +# Executable specifications for Zsh startup behavior that needs the darwin Home Manager build. +# macOS only: builds the aarch64-darwin Home Manager activation package, which needs a macOS host or builder. +# bats file_tags=macos + +bats_require_minimum_version 1.5.0 + +setup() { + REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)" + TEST_FLAKE="${DOTFILES_TEST_FLAKE:-$REPO_ROOT}" +} + +@test "Home Manager activation invokes the packaged Zsh cache builder" { + run --separate-stderr nix build --no-link --print-out-paths \ + "$TEST_FLAKE#homeConfigurations.\"kaito@mbp\".activationPackage" + + if [ "$status" -ne 0 ]; then + printf '%s\n' "$stderr" >&2 + fi + [ "$status" -eq 0 ] + + local _activation_package="$output" + [ -f "$_activation_package/activate" ] + local _builder + _builder="$(grep -Eo '/nix/store/[^"[:space:]]+-build_cache[.]zsh' "$_activation_package/activate" | head -n 1)" + [ -f "$_builder" ] + cmp --silent "$REPO_ROOT/zsh/build_cache.zsh" "$_builder" +} diff --git a/tests/zsh/test-helper/ssh_agent.bash b/tests/zsh/test-helper/ssh_agent.bash new file mode 100644 index 00000000..058e0449 --- /dev/null +++ b/tests/zsh/test-helper/ssh_agent.bash @@ -0,0 +1,26 @@ +# Shared fixtures for the Zsh SSH agent specs. + +setup_agent_environment() { + REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)" + export REPO_ROOT + export TEST_HOME="$BATS_TEST_TMPDIR/home" + export AGENT_DIR="$TEST_HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t" + export AGENT_SOCKET="$AGENT_DIR/agent.sock" + unset SSH_AUTH_SOCK SSH_CONNECTION + mkdir -p "$AGENT_DIR" "$TEST_HOME/.config/zsh" "$TEST_HOME/ghq/github.com/furedea/dotfiles/zsh" + # The full path exceeds the sockaddr_un limit, so bind by a relative name. + /usr/bin/perl -MIO::Socket::UNIX -e 'chdir $ARGV[0] or die $!; IO::Socket::UNIX->new(Local => "agent.sock", Listen => 1) or die $!' "$AGENT_DIR" + touch "$TEST_HOME/.config/zsh/nix-plugins.zsh" + touch "$TEST_HOME/ghq/github.com/furedea/dotfiles/zsh/esa.zsh" +} + +run_startup() { + # Expand variables in the child Zsh, not in the Bats process. + # shellcheck disable=SC2016 + run env HOME="$TEST_HOME" zsh -dfi -c ' + source "$REPO_ROOT/zsh/.zshenv" + function autoload compinit carapace abbr atuin direnv starship zoxide() { :; } + source "$REPO_ROOT/zsh/.zshrc" + print -r -- "${SSH_AUTH_SOCK:-unset}" + ' +} From 9cf616c0817fae70abe7adf7a57b8fa725ccc520 Mon Sep 17 00:00:00 2001 From: furedea <132188853+furedea@users.noreply.github.com> Date: Wed, 11 Nov 2026 02:14:58 +0900 Subject: [PATCH 3/4] test(esa): keep dprint stderr out of output and load the lazy stub dprint prints plugin compile messages on a cold cache, which broke the exact output checks on CI. Separate stderr in the format specs. Put the lazy.nvim stub on runtimepath so init.lua loads fully in the Neovim specs. Co-Authored-By: Claude Sonnet 5.5 --- tests/esa/format.bats | 8 +++++--- tests/esa/nvim.bats | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/esa/format.bats b/tests/esa/format.bats index 4c5eba3f..6227f120 100644 --- a/tests/esa/format.bats +++ b/tests/esa/format.bats @@ -1,6 +1,8 @@ #!/usr/bin/env bats # Tests Markdown formatting used for esa posts. +bats_require_minimum_version 1.5.0 + setup() { load test-helper/setup } @@ -10,14 +12,14 @@ format_markdown() { } @test "Markdown formatting preserves line breaks in esa prose" { - run format_markdown < <(printf 'こんにちは.\nこんばんは.\n') + run --separate-stderr format_markdown < <(printf 'こんにちは.\nこんばんは.\n') [ "$status" -eq 0 ] [ "$output" = $'こんにちは.\nこんばんは.' ] } @test "Markdown formatting indents nested lists by four spaces" { - run format_markdown < <(printf -- '- parent\n - child\n') + run --separate-stderr format_markdown < <(printf -- '- parent\n - child\n') [ "$status" -eq 0 ] [ "$output" = $'- parent\n - child' ] @@ -27,7 +29,7 @@ format_markdown() { local _outside="$BATS_TEST_TMPDIR/outside/post.md" mkdir -p "${_outside%/*}" - run dprint fmt --config "$REPO_ROOT/dprint/dprint.json" --stdin "$_outside" < <(printf -- '- parent\n - child\n') + run --separate-stderr dprint fmt --config "$REPO_ROOT/dprint/dprint.json" --stdin "$_outside" < <(printf -- '- parent\n - child\n') [ "$status" -eq 0 ] [ "$output" = $'- parent\n - child' ] diff --git a/tests/esa/nvim.bats b/tests/esa/nvim.bats index b9126aa1..a726fa6b 100644 --- a/tests/esa/nvim.bats +++ b/tests/esa/nvim.bats @@ -14,7 +14,7 @@ setup() { ESA_EDIT_POST_NUMBER=1515 \ ESA_EDIT_FILE="$ARTICLE_FILE" \ XDG_DATA_HOME="$NVIM_DATA_HOME" \ - nvim --headless --cmd "set runtimepath^=$REPO_ROOT/nvim" -u "$REPO_ROOT/nvim/init.lua" \ + nvim --headless --cmd "set runtimepath^=$REPO_ROOT/nvim,$NVIM_DATA_HOME/nvim/lazy/lazy.nvim" -u "$REPO_ROOT/nvim/init.lua" \ "$ARTICLE_FILE" \ -c "call setline(1, '# After')" \ -c write \ @@ -32,7 +32,7 @@ setup() { ESA_EDIT_POST_NUMBER=1515 \ ESA_EDIT_FILE="$ARTICLE_FILE" \ XDG_DATA_HOME="$NVIM_DATA_HOME" \ - nvim --headless --cmd "set runtimepath^=$REPO_ROOT/nvim" -u "$REPO_ROOT/nvim/init.lua" \ + nvim --headless --cmd "set runtimepath^=$REPO_ROOT/nvim,$NVIM_DATA_HOME/nvim/lazy/lazy.nvim" -u "$REPO_ROOT/nvim/init.lua" \ "$other_file" \ -c "call setline(1, '# Changed')" \ -c write \ From 4cae7dd8d330618d3a7b5d003ff1f7748bd1e9c9 Mon Sep 17 00:00:00 2001 From: furedea <132188853+furedea@users.noreply.github.com> Date: Wed, 11 Nov 2026 02:19:53 +0900 Subject: [PATCH 4/4] test(zsh): tag the whole SSH agent spec as macOS only .zshrc gates the 1Password agent logic behind OSTYPE=darwin, so the cases that passed on Linux were vacuous. Keep them in one tagged file instead of splitting. Co-Authored-By: Claude Sonnet 5.5 --- tests/zsh/ssh_agent.bats | 40 ++++++++++++++++++++++++++-- tests/zsh/ssh_agent_macos.bats | 22 --------------- tests/zsh/test-helper/ssh_agent.bash | 26 ------------------ 3 files changed, 38 insertions(+), 50 deletions(-) delete mode 100644 tests/zsh/ssh_agent_macos.bats delete mode 100644 tests/zsh/test-helper/ssh_agent.bash diff --git a/tests/zsh/ssh_agent.bats b/tests/zsh/ssh_agent.bats index b4bb9e09..81288415 100644 --- a/tests/zsh/ssh_agent.bats +++ b/tests/zsh/ssh_agent.bats @@ -1,9 +1,32 @@ #!/usr/bin/env bats # Interactive Zsh points SSH_AUTH_SOCK at the user's 1Password agent, never at another local agent. +# macOS only: zsh/.zshrc attaches the 1Password agent and validates its socket only when OSTYPE is darwin, +# so every case here would pass vacuously on Linux. +# bats file_tags=macos setup() { - load test-helper/ssh_agent - setup_agent_environment + REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)" + export REPO_ROOT + export TEST_HOME="$BATS_TEST_TMPDIR/home" + export AGENT_DIR="$TEST_HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t" + export AGENT_SOCKET="$AGENT_DIR/agent.sock" + unset SSH_AUTH_SOCK SSH_CONNECTION + mkdir -p "$AGENT_DIR" "$TEST_HOME/.config/zsh" "$TEST_HOME/ghq/github.com/furedea/dotfiles/zsh" + # The full path exceeds the sockaddr_un limit, so bind by a relative name. + /usr/bin/perl -MIO::Socket::UNIX -e 'chdir $ARGV[0] or die $!; IO::Socket::UNIX->new(Local => "agent.sock", Listen => 1) or die $!' "$AGENT_DIR" + touch "$TEST_HOME/.config/zsh/nix-plugins.zsh" + touch "$TEST_HOME/ghq/github.com/furedea/dotfiles/zsh/esa.zsh" +} + +run_startup() { + # Expand variables in the child Zsh, not in the Bats process. + # shellcheck disable=SC2016 + run env HOME="$TEST_HOME" zsh -dfi -c ' + source "$REPO_ROOT/zsh/.zshenv" + function autoload compinit carapace abbr atuin direnv starship zoxide() { :; } + source "$REPO_ROOT/zsh/.zshrc" + print -r -- "${SSH_AUTH_SOCK:-unset}" + ' } @test "noninteractive startup does not attach an agent" { @@ -12,6 +35,19 @@ setup() { [ "$output" = unset ] } +@test "startup attaches the 1Password agent when none is inherited" { + run_startup + [ "$status" -eq 0 ] + [ "$output" = "$AGENT_SOCKET" ] +} + +@test "startup replaces the login session's local agent with 1Password" { + export SSH_AUTH_SOCK="$BATS_TEST_TMPDIR/apple-agent" + run_startup + [ "$status" -eq 0 ] + [ "$output" = "$AGENT_SOCKET" ] +} + @test "startup preserves an agent forwarded into a remote session" { export SSH_CONNECTION="192.0.2.1 50000 192.0.2.2 22" export SSH_AUTH_SOCK="$BATS_TEST_TMPDIR/forwarded-agent" diff --git a/tests/zsh/ssh_agent_macos.bats b/tests/zsh/ssh_agent_macos.bats deleted file mode 100644 index bdfe74c4..00000000 --- a/tests/zsh/ssh_agent_macos.bats +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bats -# Interactive Zsh attaches the user's 1Password agent. -# macOS only: zsh/.zshrc attaches the 1Password agent only when OSTYPE is darwin. -# bats file_tags=macos - -setup() { - load test-helper/ssh_agent - setup_agent_environment -} - -@test "startup attaches the 1Password agent when none is inherited" { - run_startup - [ "$status" -eq 0 ] - [ "$output" = "$AGENT_SOCKET" ] -} - -@test "startup replaces the login session's local agent with 1Password" { - export SSH_AUTH_SOCK="$BATS_TEST_TMPDIR/apple-agent" - run_startup - [ "$status" -eq 0 ] - [ "$output" = "$AGENT_SOCKET" ] -} diff --git a/tests/zsh/test-helper/ssh_agent.bash b/tests/zsh/test-helper/ssh_agent.bash deleted file mode 100644 index 058e0449..00000000 --- a/tests/zsh/test-helper/ssh_agent.bash +++ /dev/null @@ -1,26 +0,0 @@ -# Shared fixtures for the Zsh SSH agent specs. - -setup_agent_environment() { - REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)" - export REPO_ROOT - export TEST_HOME="$BATS_TEST_TMPDIR/home" - export AGENT_DIR="$TEST_HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t" - export AGENT_SOCKET="$AGENT_DIR/agent.sock" - unset SSH_AUTH_SOCK SSH_CONNECTION - mkdir -p "$AGENT_DIR" "$TEST_HOME/.config/zsh" "$TEST_HOME/ghq/github.com/furedea/dotfiles/zsh" - # The full path exceeds the sockaddr_un limit, so bind by a relative name. - /usr/bin/perl -MIO::Socket::UNIX -e 'chdir $ARGV[0] or die $!; IO::Socket::UNIX->new(Local => "agent.sock", Listen => 1) or die $!' "$AGENT_DIR" - touch "$TEST_HOME/.config/zsh/nix-plugins.zsh" - touch "$TEST_HOME/ghq/github.com/furedea/dotfiles/zsh/esa.zsh" -} - -run_startup() { - # Expand variables in the child Zsh, not in the Bats process. - # shellcheck disable=SC2016 - run env HOME="$TEST_HOME" zsh -dfi -c ' - source "$REPO_ROOT/zsh/.zshenv" - function autoload compinit carapace abbr atuin direnv starship zoxide() { :; } - source "$REPO_ROOT/zsh/.zshrc" - print -r -- "${SSH_AUTH_SOCK:-unset}" - ' -}