Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configs/core/perf.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ _zsh_report() {
_print_duration_row 'total' "$total_ms"
echo '└────────────────────────────┘'

if [[ "${_zsh_completion_cache_mode:-}" == 'cache-hit' && -n "${_zsh_compdump_file:-}" ]]; then
if [[ "${SUITUP_SHOW_COMPLETION_CACHE_HINT:-0}" == '1' && "${_zsh_completion_cache_mode:-}" == 'cache-hit' && -n "${_zsh_compdump_file:-}" ]]; then
printf 'completion cache hit; remove %s to rebuild\n' "$_zsh_compdump_file"
fi
}
1 change: 1 addition & 0 deletions configs/shared/tools/_loader.zsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ============================================================================
# Shared tool loader and cached init helpers
# Generated by suitup
# ============================================================================
#
# This file contains common helpers used by multiple tool modules.
Expand Down
1 change: 1 addition & 0 deletions configs/shared/tools/atuin.zsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ============================================================================
# atuin history integration
# Generated by suitup
# ============================================================================
#
# This module owns shell initialization for atuin.
Expand Down
1 change: 1 addition & 0 deletions configs/shared/tools/bun.zsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ============================================================================
# bun completion
# Generated by suitup
# ============================================================================
#
# This module keeps bun completion isolated because it is optional and can be
Expand Down
1 change: 1 addition & 0 deletions configs/shared/tools/fzf.zsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ============================================================================
# fzf configuration and Ctrl-T widget
# Generated by suitup
# ============================================================================
#
# This module owns all fzf-specific shell behavior in this config.
Expand Down
1 change: 1 addition & 0 deletions configs/shared/tools/runtime.zsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ============================================================================
# Runtime helper tools
# Generated by suitup
# ============================================================================
#
# This module groups lightweight shell integrations that do not own complex
Expand Down
57 changes: 57 additions & 0 deletions tests/setup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,63 @@ describe("Setup simulation in sandbox", () => {
}
});

test("flags managed tool module edits as zsh-config pending", () => {
const completedSandbox = createSandbox();
try {
mkdirSync(join(completedSandbox.path, ".config", "zsh", "core"), { recursive: true });
mkdirSync(join(completedSandbox.path, ".config", "zsh", "shared"), { recursive: true });
mkdirSync(join(completedSandbox.path, ".config", "zsh", "local"), { recursive: true });
mkdirSync(join(completedSandbox.path, ".config", "zsh", "shared", "tools"), { recursive: true });

copyFileSync(join(CONFIGS_DIR, "zshrc.template"), join(completedSandbox.path, ".zshrc"));
copyFileSync(join(CONFIGS_DIR, "zshenv.template"), join(completedSandbox.path, ".zshenv"));
for (const file of ["perf.zsh", "env.zsh", "paths.zsh", "options.zsh"]) {
copyFileSync(
join(CONFIGS_DIR, "core", file),
join(completedSandbox.path, ".config", "zsh", "core", file)
);
}
for (const file of ["tools.zsh", "completion.zsh", "highlighting.zsh", "aliases.zsh", "plugins.zsh", "prompt.zsh"]) {
copyFileSync(
join(CONFIGS_DIR, "shared", file),
join(completedSandbox.path, ".config", "zsh", "shared", file)
);
}
for (const file of ["_loader.zsh", "fzf.zsh", "runtime.zsh", "atuin.zsh", "bun.zsh"]) {
copyFileSync(
join(CONFIGS_DIR, "shared", "tools", file),
join(completedSandbox.path, ".config", "zsh", "shared", "tools", file)
);
}
copyFileSync(
join(CONFIGS_DIR, "local", "machine.zsh"),
join(completedSandbox.path, ".config", "zsh", "local", "machine.zsh")
);
Comment on lines +379 to +394
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

测试设置中包含了拷贝多个不相关文件(aliases.zshplugins.zshprompt.zshmachine.zsh)的操作,这些文件与正在测试的 zsh-config 待更新状态无关。具体来说,aliases.zshplugins.zsh 会触发它们各自独立的待更新标记,而 prompt.zshmachine.zsh 并不在更新检测范围内。移除这些无关设置可以使测试更聚焦且更易于维护。

Suggested change
for (const file of ["tools.zsh", "completion.zsh", "highlighting.zsh", "aliases.zsh", "plugins.zsh", "prompt.zsh"]) {
copyFileSync(
join(CONFIGS_DIR, "shared", file),
join(completedSandbox.path, ".config", "zsh", "shared", file)
);
}
for (const file of ["_loader.zsh", "fzf.zsh", "runtime.zsh", "atuin.zsh", "bun.zsh"]) {
copyFileSync(
join(CONFIGS_DIR, "shared", "tools", file),
join(completedSandbox.path, ".config", "zsh", "shared", "tools", file)
);
}
copyFileSync(
join(CONFIGS_DIR, "local", "machine.zsh"),
join(completedSandbox.path, ".config", "zsh", "local", "machine.zsh")
);
for (const file of ["tools.zsh", "completion.zsh", "highlighting.zsh"]) {
copyFileSync(
join(CONFIGS_DIR, "shared", file),
join(completedSandbox.path, ".config", "zsh", "shared", file)
);
}
for (const file of ["_loader.zsh", "fzf.zsh", "runtime.zsh", "atuin.zsh", "bun.zsh"]) {
copyFileSync(
join(CONFIGS_DIR, "shared", "tools", file),
join(completedSandbox.path, ".config", "zsh", "shared", "tools", file)
);
}


const loaderPath = join(completedSandbox.path, ".config", "zsh", "shared", "tools", "_loader.zsh");
const loader = readFileSync(loaderPath, "utf-8");
writeFileSync(
loaderPath,
loader.replace(
"# This file contains common helpers used by multiple tool modules.",
"# This file contains common helpers used by multiple tool modules, now with an added note."
)
);

const opts = {
home: completedSandbox.path,
platform: "darwin",
commandExistsFn(name) {
return ["zsh", "brew"].includes(name);
},
};
Comment on lines +406 to +412
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

传递给 detectPendingStepUpdatesopts 对象包含未使用的属性 platformcommandExistsFn。该函数仅利用 home 属性进行路径解析。清理这些属性可以提高测试代码的清晰度。

      const opts = {
        home: completedSandbox.path,
      };


expect(detectPendingStepUpdates(opts)).toContain("zsh-config");
} finally {
completedSandbox.cleanup();
}
});

test("does not treat non-suitup shell files as completed zsh config", () => {
mkdirSync(join(sandbox, ".config", "zsh", "core"), { recursive: true });
mkdirSync(join(sandbox, ".config", "zsh", "shared"), { recursive: true });
Expand Down
Loading