From 92c36c288436f6427ce1d461ce36e6f32a834229 Mon Sep 17 00:00:00 2001 From: Branson404 <78994175+branson404@users.noreply.github.com> Date: Sun, 6 Dec 2026 12:51:30 +0000 Subject: [PATCH] fix(install): return the error from NewTesting ct install printed the error from chart.NewTesting and carried on, so a failure to set up Helm (for example helm not on PATH) could end in exit status 0 when no charts were selected. ct lint and the other commands already return this error. Return it here too, with a regression test. Signed-off-by: Branson404 <78994175+branson404@users.noreply.github.com> --- ct/cmd/install.go | 2 +- ct/cmd/install_test.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 ct/cmd/install_test.go diff --git a/ct/cmd/install.go b/ct/cmd/install.go index 4afeb8186..6a79016d3 100644 --- a/ct/cmd/install.go +++ b/ct/cmd/install.go @@ -98,7 +98,7 @@ func install(cmd *cobra.Command, _ []string) error { testing, err := chart.NewTesting(*configuration) if err != nil { - fmt.Println(err) + return err } results, err := testing.InstallCharts() testing.PrintResults(results) diff --git a/ct/cmd/install_test.go b/ct/cmd/install_test.go new file mode 100644 index 000000000..b7b118907 --- /dev/null +++ b/ct/cmd/install_test.go @@ -0,0 +1,35 @@ +// Copyright The Helm Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package cmd + +import ( + "errors" + "os/exec" + "testing" +) + +func TestInstallReturnsHelmLookupError(t *testing.T) { + t.Setenv("PATH", "") + t.Setenv("CT_CONFIG_DIR", "install-test-no-config") + + cmd := NewRootCmd() + cmd.SetArgs([]string{"install", "--all", "--chart-dirs="}) + err := cmd.Execute() + + var lookupErr *exec.Error + if !errors.As(err, &lookupErr) || lookupErr.Name != "helm" || !errors.Is(err, exec.ErrNotFound) { + t.Fatalf("ct install returned %v, want a Helm executable lookup error", err) + } +}