diff --git a/pkg/task/generictaskhandler.go b/pkg/task/generictaskhandler.go index dd44655b..dc215288 100644 --- a/pkg/task/generictaskhandler.go +++ b/pkg/task/generictaskhandler.go @@ -457,10 +457,14 @@ func applyResourceMutations(ctx context.Context, draft repository.PackageRevisio } if taskResult != nil && task.Type == api.TaskTypeEval { renderStatus = taskResult.RenderStatus + if err != nil { + klog.Error(err) + err = fmt.Errorf("%w\n\n%s\n%s\n%s", err, "Error occurred rendering package in kpt function pipeline.", "Package has NOT been pushed to remote.", "Please fix package locally (modify until 'kpt fn render' succeeds) and retry.") + return updatedResources, renderStatus, err + } } if err != nil { klog.Error(err) - err = fmt.Errorf("%w\n\n%s\n%s\n%s", err, "Error occurred rendering package in kpt function pipeline.", "Package has NOT been pushed to remote.", "Please fix package locally (modify until 'kpt fn render' succeeds) and retry.") return updatedResources, renderStatus, err } diff --git a/test/e2e/cli/config.go b/test/e2e/cli/config.go index 689b51a9..cfef3073 100644 --- a/test/e2e/cli/config.go +++ b/test/e2e/cli/config.go @@ -40,6 +40,8 @@ type Command struct { IgnoreWhitespace bool `yaml:"ignoreWhitespace,omitempty"` // StdErrTabToWhitespace replaces "\t" (tab) character with whitespace " " StdErrTabToWhitespace bool `yaml:"stdErrTabToWhitespace,omitempty"` + // ContainsErrorString changes Stderr check from exact string match to contains string match + ContainsErrorString bool `yaml:"containsErrorString,omitempty"` } type TestCaseConfig struct { diff --git a/test/e2e/cli/suite.go b/test/e2e/cli/suite.go index 380320ee..f23a1d2b 100644 --- a/test/e2e/cli/suite.go +++ b/test/e2e/cli/suite.go @@ -148,7 +148,7 @@ func (s *CliTestSuite) RunTestCase(t *testing.T, tc TestCaseConfig) { command.Stdout = strings.ReplaceAll(command.Stdout, search, replace) command.Stderr = strings.ReplaceAll(command.Stderr, search, replace) } - + if command.StdErrTabToWhitespace { stderrStr = strings.ReplaceAll(stderrStr, "\t", " ") // Replace tabs with spaces } @@ -173,8 +173,14 @@ func (s *CliTestSuite) RunTestCase(t *testing.T, tc TestCaseConfig) { got, want := stderrStr, command.Stderr got = removeArmPlatformWarning(got) - if got != want { - t.Errorf("unexpected stderr content from '%s'; (-want, +got) %s", strings.Join(command.Args, " "), cmp.Diff(want, got)) + if command.ContainsErrorString { + if !strings.Contains(got, want) { + t.Errorf("unexpected stderr content from '%s'; \n Error we got = \n(%s) \n Should contain substring = \n(%s)\n", strings.Join(command.Args, " "), got, want) + } + } else { + if got != want { + t.Errorf("unexpected stderr content from '%s'; (-want, +got) %s", strings.Join(command.Args, " "), cmp.Diff(want, got)) + } } // hack here; but if the command registered a repo, give a few extra seconds for the repo to reach readiness diff --git a/test/e2e/cli/testdata/rpkg-push/config.yaml b/test/e2e/cli/testdata/rpkg-push/config.yaml index 1fc7fe99..c71fabda 100644 --- a/test/e2e/cli/testdata/rpkg-push/config.yaml +++ b/test/e2e/cli/testdata/rpkg-push/config.yaml @@ -258,12 +258,8 @@ commands: - git-efe3d01c68dfdcdd69114c9a7c65cce0d662a46f - /tmp/porch-e2e/testing-invalid-render stderr: | - Error: Internal error occurred: fn.render: pkg /: - pkg.render: - pipeline.run: func eval "gcr.io/kpt-fn/set-annotations:v0.1.4" failed: rpc error: code = Internal desc = Failed to execute function "gcr.io/kpt-fn/set-annotations:v0.1.4": exit status 1 ([error] : failed to configure function: `functionConfig` must be a `ConfigMap` or `SetAnnotations`) - Error occurred rendering package in kpt function pipeline. Package has NOT been pushed to remote. Please fix package locally (modify until 'kpt fn render' succeeds) and retry. - stdErrTabToWhitespace: true + containsErrorString: true exitCode: 1