From 796459611cfc776567c185381e6b1063390bb426 Mon Sep 17 00:00:00 2001 From: yangyile Date: Wed, 4 Dec 2024 15:34:58 +0700 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E8=A1=A5=E6=B5=8B=E8=AF=95=E6=B5=81?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exec_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/exec_test.go b/exec_test.go index 61a758b..e339763 100644 --- a/exec_test.go +++ b/exec_test.go @@ -1,6 +1,7 @@ package osexec_test import ( + "os/exec" "strings" "testing" @@ -39,6 +40,13 @@ func TestCommandConfig_ExecXshRun_WithBash(t *testing.T) { } func TestCommandConfig_ExecXshRun_WithZsh(t *testing.T) { + // 检测环境是否支持 zsh + path, err := exec.LookPath("zsh") + if err != nil { // 假如测试环境里没有 zsh 就会报错 + t.Skip("zsh is not available on this system, skipping test case") + } + t.Log(path) + data, err := osexec.NewCommandConfig().WithZsh().Exec("echo", "$HOME") require.NoError(t, err) t.Log(string(data))