From 811145012b1c591cb3fdcf8815a0261655f5ce82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Suszy=C5=84ski?= Date: Mon, 25 Mar 2024 14:54:22 +0100 Subject: [PATCH] Use knative/client-pkg#164 --- go.mod | 2 ++ go.sum | 4 ++-- tests/project_build_test.go | 24 ++++++++++++++++++------ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 96d0de9..3e5d359 100644 --- a/go.mod +++ b/go.mod @@ -200,3 +200,5 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.4.0 // indirect ) + +replace knative.dev/client-pkg => github.com/cardil/knative-client-pkg v0.0.0-20240326100345-3ccca71a6736 diff --git a/go.sum b/go.sum index a0406d0..84923e1 100644 --- a/go.sum +++ b/go.sum @@ -116,6 +116,8 @@ github.com/bodgit/windows v1.0.1 h1:tF7K6KOluPYygXa3Z2594zxlkbKPAOvqr97etrGNIz4= github.com/bodgit/windows v1.0.1/go.mod h1:a6JLwrB4KrTR5hBpp8FI9/9W9jJfeQ2h4XDXU74ZCdM= github.com/cardil/ghet v0.0.1-0.20240322174403-1901c4fe21ac h1:J6clysTPmIXMLYNh5Vu+x3qNiMTXKibibYz4dO/tiT8= github.com/cardil/ghet v0.0.1-0.20240322174403-1901c4fe21ac/go.mod h1:INmHFxuHn5LmjkjmR9aCqa6msghwM/4q5He/vYlucfY= +github.com/cardil/knative-client-pkg v0.0.0-20240326100345-3ccca71a6736 h1:6FRzUreKm22cPp6ckwc6FFuPvAByH8HObF0QWEtHuKU= +github.com/cardil/knative-client-pkg v0.0.0-20240326100345-3ccca71a6736/go.mod h1:+wx9/SVVGLte1JRcULet7kKnnUmgPzG1vQpD8E4DwVs= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -799,8 +801,6 @@ k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/utils v0.0.0-20240310230437-4693a0247e57 h1:gbqbevonBh57eILzModw6mrkbwM0gQBEuevE/AaBsHY= k8s.io/utils v0.0.0-20240310230437-4693a0247e57/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -knative.dev/client-pkg v0.0.0-20240322171749-cf1573f93631 h1:LRwjoTbqyruGECvQZyGQE3k5clxwmgCQEt5HcWTUz2Y= -knative.dev/client-pkg v0.0.0-20240322171749-cf1573f93631/go.mod h1:CODwMfQexBzzgB2fv9hYF1+FZfrYc9TF3B26GxW69zQ= knative.dev/pkg v0.0.0-20240318073042-db6f3b074e8c h1:d8GmDhObjnH/iKrazsNjgLuuEnxLiFE/QSaeFY337cw= knative.dev/pkg v0.0.0-20240318073042-db6f3b074e8c/go.mod h1:RfDXq7Rf7UmGCEdAiJZPpBRuh7dX73T8clniFt2zEAA= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/tests/project_build_test.go b/tests/project_build_test.go index 65c61e8..9f0bf7e 100644 --- a/tests/project_build_test.go +++ b/tests/project_build_test.go @@ -17,13 +17,16 @@ func TestProjectBuild(t *testing.T) { if testing.Short() { t.Skip("short tests only") } - execCmd(t, "./example", "./mage", "clean", "build") - execCmd(t, "./example/build/_output/bin", fmt.Sprintf("./other-%s-%s", - runtime.GOOS, runtime.GOARCH)) + c := mkCmd("./example", "./mage", "clean", "build") + assertCommandStarted(t, c) + assertCommandSucceded(t, c) + c = mkCmd("./example/build/_output/bin", + fmt.Sprintf("./other-%s-%s", runtime.GOOS, runtime.GOARCH)) + assertCommandStarted(t, c) + assertCommandSucceded(t, c) } -func execCmd(tb testing.TB, dir, name string, args ...string) { - tb.Helper() +func mkCmd(dir, name string, args ...string) *exec.Cmd { c := exec.Command(name, args...) c.Env = append( env(filterOutByName{names: []string{"GOOS"}}), @@ -32,10 +35,19 @@ func execCmd(tb testing.TB, dir, name string, args ...string) { c.Dir = dir c.Stdout = os.Stdout c.Stderr = os.Stderr + return c +} + +func assertCommandStarted(tb testing.TB, c *exec.Cmd) { + tb.Helper() assert.NilError(tb, c.Start()) tb.Logf("Started `%q` with pid %d", - append([]string{name}, args...), + append([]string{c.Path}, c.Args...), c.Process.Pid) +} + +func assertCommandSucceded(tb testing.TB, c *exec.Cmd) { + tb.Helper() assert.NilError(tb, c.Wait()) }