{"record":{"id":"ba7588b6ad8598e2","repo":"GoogleContainerTools/skaffold","slug":"failed-to-test-w","errorCode":null,"errorMessage":"failed to test: %w","messagePattern":"failed to test: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/skaffold/app/cmd/run.go","lineNumber":54,"sourceCode":"\t\tWithLongDescription(\"Run a pipeline: build and test artifacts, tag them, update Kubernetes manifests and deploy to a cluster.\").\n\t\tWithExample(\"Build, test, deploy and tail the logs\", \"run --tail\").\n\t\tWithExample(\"Run with a given profile\", \"run -p <profile>\").\n\t\tWithCommonFlags().\n\t\tWithHouseKeepingMessages().\n\t\tNoArgs(doRun)\n}\n\nfunc doRun(ctx context.Context, out io.Writer) error {\n\treturn withRunner(ctx, out, func(r runner.Runner, configs []util.VersionedConfig) error {\n\t\tbRes, err := r.Build(ctx, out, targetArtifacts(opts, configs))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to build: %w\", err)\n\t\t}\n\n\t\tif !opts.SkipTests {\n\t\t\terr = r.Test(ctx, out, bRes)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to test: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\t// Render\n\t\tmanifestList, err := r.Render(ctx, out, bRes, false)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"rendering manifests: %w\", err)\n\t\t}\n\t\tif opts.RenderOnly {\n\t\t\treturn manifest.Write(manifestList.String(), opts.RenderOutput, out)\n\t\t}\n\n\t\terr = r.DeployAndLog(ctx, out, bRes, manifestList)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to deploy: %w\", err)\n\t\t}\n\n\t\ttips.PrintForRun(out, opts)","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/cmd/skaffold/app/cmd/run.go#L36-L72","documentation":"After a successful build, `skaffold run` executes the test suite defined in the test section via `r.Test`; this wrapper reports a test failure and stops the run before deploy. It means one of the configured image/container-structure tests or custom test runners returned a non-zero result.","triggerScenarios":"`skaffold run` (without --skip-tests) where a test in the skaffold.yaml test section fails: container-structure-test failures, custom test command exits non-zero, test image missing, or the test harness can't start (e.g. docker unavailable).","commonSituations":"A recently changed application breaks container-structure-test assertions; custom test scripts depend on files/env vars absent in CI; test image wasn't rebuilt after dependency changes; flaky tests failing in CI only.","solutions":["Read the wrapped test output to identify which test suite failed and why.","Reproduce locally with `skaffold test` (or `skaffold run --skip-tests` to isolate) and fix the failing test or the code it covers.","If tests are intentionally skipped in this context, run `skaffold run --skip-tests`.","Rebuild test images / clear stale cache so tests run against current code: `skaffold build --profile <test-profile>` then run."],"exampleFix":"# before: run fails on failing tests\nskaffold run\n# after: intentionally bypass tests (or fix them first)\nskaffold run --skip-tests\n# or, to debug:\nskaffold test\n","handlingStrategy":"try-catch","validationCode":"// Ensure test prerequisites exist before skaffold run\nconst cfg = require('js-yaml').load(require('fs').readFileSync('skaffold.yaml', 'utf8'));\nconst hasTests = Array.isArray(cfg.test) && cfg.test.length > 0;\nconst skip = process.env.SKIP_TESTS === 'true';\nif (hasTests && !skip) {\n  // run tests alone first so failures don't abort run mid-pipeline\n  execFileSync('skaffold', ['test'], {stdio: 'inherit'});\n}","typeGuard":null,"tryCatchPattern":"try {\n  execFileSync('skaffold', ['run'], {stdio: 'pipe'});\n} catch (e) {\n  const msg = e.stderr?.toString() ?? '';\n  if (msg.includes('failed to test')) {\n    console.error('skaffold run aborted at test stage; run `skaffold test` to see failing suites:', msg);\n    // fallback for non-blocking pipelines:\n    // execFileSync('skaffold', ['run', '--skip-tests']);\n  } else throw e;\n}","preventionTips":["Run `skaffold test` as a standalone CI step before `skaffold run` so test failures are reported in isolation.","Keep container-structure-test configs in sync with the images they assert on.","Use --skip-tests deliberately (e.g. deploy-only pipelines) instead of ad-hoc when tests are known-broken.","Make custom test scripts fail loudly with clear messages so wrapped output is actionable."],"tags":["skaffold","test","run","ci"],"backgroundTag":"test-suite-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}