Skip to content

Commit 482a59e

Browse files
authored
🌱 Tests: Fix data race failures (#2262)
* Fix data race failures in tests Signed-off-by: Raghav Kaul <raghavkaul@google.com> * Keep coverprofiles for the attestor separate Signed-off-by: Raghav Kaul <raghavkaul@google.com> Signed-off-by: Raghav Kaul <raghavkaul@google.com>
1 parent 2231d1f commit 482a59e

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ results.json
2626

2727
# Output of the go coverage tool, specifically when used with LiteIDE.
2828
*.coverprofile*
29-
unit-coverage.out
29+
**/unit-coverage.out
3030
e2e-coverage.out
3131

3232

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ unit-test: ## Runs unit test without e2e
288288
SKIP_GINKGO=1 go test -race -covermode=atomic -coverprofile=unit-coverage.out `go list ./...`
289289

290290
unit-test-attestor: ## Runs unit tests on scorecard-attestor
291-
cd attestor; SKIP_GINKGO=1 go test -covermode=atomic -coverprofile=unit-coverage-attestor.out `go list ./...`; cd ..;
291+
cd attestor; SKIP_GINKGO=1 go test -covermode=atomic -coverprofile=unit-coverage.out `go list ./...`; cd ..;
292292

293293
$(GINKGO): install
294294

@@ -300,10 +300,10 @@ endif
300300
e2e-pat: ## Runs e2e tests. Requires GITHUB_AUTH_TOKEN env var to be set to GitHub personal access token
301301
e2e-pat: build-scorecard check-env | $(GINKGO)
302302
# Run e2e tests. GITHUB_AUTH_TOKEN with personal access token must be exported to run this
303-
TOKEN_TYPE="PAT" $(GINKGO) --race -p -v -cover -coverprofile=e2e-coverage.out ./...
303+
TOKEN_TYPE="PAT" $(GINKGO) --race -p -v -cover -coverprofile=e2e-coverage.out --keep-separate-coverprofiles ./...
304304

305305
e2e-gh-token: ## Runs e2e tests. Requires GITHUB_AUTH_TOKEN env var to be set to default GITHUB_TOKEN
306306
e2e-gh-token: build-scorecard check-env | $(GINKGO)
307307
# Run e2e tests. GITHUB_AUTH_TOKEN set to secrets.GITHUB_TOKEN must be used to run this.
308-
TOKEN_TYPE="GITHUB_TOKEN" $(GINKGO) --race -p -v -cover -coverprofile=e2e-coverage.out ./...
308+
TOKEN_TYPE="GITHUB_TOKEN" $(GINKGO) --race -p -v -cover -coverprofile=e2e-coverage.out --keep-separate-coverprofiles ./...
309309
###############################################################################

attestor/attestation_policy_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ func (a AttestationPolicy) ToJSON() string {
3636
func TestCheckPreventBinaryArtifacts(t *testing.T) {
3737
t.Parallel()
3838

39-
dl := scut.TestDetailLogger{}
40-
4139
tests := []struct {
4240
name string
4341
raw *checker.RawResults
@@ -107,6 +105,7 @@ func TestCheckPreventBinaryArtifacts(t *testing.T) {
107105
tt := &tests[i]
108106
t.Run(tt.name, func(t *testing.T) {
109107
t.Parallel()
108+
dl := scut.TestDetailLogger{}
110109
actual, err := CheckPreventBinaryArtifacts(tt.allowedBinaryArtifacts, tt.raw, &dl)
111110

112111
if !errors.Is(err, tt.err) {

0 commit comments

Comments
 (0)