diff --git a/library.sh b/library.sh index f4ef09c6..b1511829 100755 --- a/library.sh +++ b/library.sh @@ -774,7 +774,7 @@ function go_update_deps() { function __clean_goworksum_if_exists() { if [ -f "$REPO_ROOT_DIR/go.work.sum" ]; then log.step 'Cleaning the go.work.sum file' - true > "$REPO_ROOT_DIR/go.work.sum" + truncate --size 0 "$REPO_ROOT_DIR/go.work.sum" fi } diff --git a/test/unit/presubmit_test.go b/test/unit/presubmit_test.go index d4f4c961..bf002f5b 100644 --- a/test/unit/presubmit_test.go +++ b/test/unit/presubmit_test.go @@ -24,9 +24,9 @@ func TestPresubmitTestMainFunc(t *testing.T) { contains("Build tests for knative.dev/hack/schema"), contains("Build tests for knative.dev/hack"), contains("Checking that go code builds"), - contains("go test -vet=off -tags e2e,library -exec echo ./..."), - contains("go test -vet=off -tags -exec echo ./..."), - contains("go run knative.dev/test-infra/tools/kntest/cmd/kntest@latest" + + contains("👻 go test -vet=off -tags e2e,library -exec echo ./..."), + contains("👻 go test -vet=off -tags -exec echo ./..."), + contains("👻 go run knative.dev/test-infra/tools/kntest/cmd/kntest@latest" + " junit --suite=_build_tests --name=Check_Licenses --err-msg= --dest="), header("BUILD TESTS PASSED"), }, diff --git a/test/unit/update_deps_test.go b/test/unit/update_deps_test.go index 26bdb290..85159236 100644 --- a/test/unit/update_deps_test.go +++ b/test/unit/update_deps_test.go @@ -9,6 +9,10 @@ func TestUpdateDeps(t *testing.T) { sc := newShellScript( loadFile("source-library.bash"), mockGo(), + mockBinary("truncate", response{ + args: startsWith{"--size 0"}, + response: simply(""), + }), ) tcs := []testCase{{ name: "go_update_deps --unknown", @@ -24,24 +28,26 @@ func TestUpdateDeps(t *testing.T) { contains("Golang module: knative.dev/hack"), contains("Checking licenses"), contains("Removing unwanted vendor files"), - contains("go mod tidy"), - contains("go run github.com/google/go-licenses@v1.6.0 check"), + contains("👻 go mod tidy"), + contains("👻 go run github.com/google/go-licenses@v1.6.0 check"), + contains("👻 go mod download -x"), }, }, { name: "go_update_deps --upgrade", stdout: []check{ - contains("go run knative.dev/toolbox/buoy@latest float ./go.mod " + - "--release v9000.1 --domain knative.dev"), + contains("👻 go run knative.dev/toolbox/buoy@latest float " + + "./go.mod --release v9000.1 --domain knative.dev"), }, }, { name: "go_update_deps --upgrade --release 1.25 --module-release 0.28", stdout: []check{ - contains("go run knative.dev/toolbox/buoy@latest float ./go.mod " + - "--release 1.25 --domain knative.dev --module-release 0.28"), + contains("👻 go run knative.dev/toolbox/buoy@latest float " + + "./go.mod --release 1.25 --domain knative.dev " + + "--module-release 0.28"), }, }} - for _, tc := range tcs { - tc := tc + for i := range tcs { + tc := tcs[i] t.Run(tc.name, tc.test(sc)) } }