🌱 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>
This commit is contained in:
raghavkaul 2022-09-19 11:26:13 -04:00 committed by GitHub
parent 2231d1f722
commit 482a59ec9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 6 deletions

2
.gitignore vendored
View File

@ -26,7 +26,7 @@ results.json
# Output of the go coverage tool, specifically when used with LiteIDE.
*.coverprofile*
unit-coverage.out
**/unit-coverage.out
e2e-coverage.out

View File

@ -288,7 +288,7 @@ unit-test: ## Runs unit test without e2e
SKIP_GINKGO=1 go test -race -covermode=atomic -coverprofile=unit-coverage.out `go list ./...`
unit-test-attestor: ## Runs unit tests on scorecard-attestor
cd attestor; SKIP_GINKGO=1 go test -covermode=atomic -coverprofile=unit-coverage-attestor.out `go list ./...`; cd ..;
cd attestor; SKIP_GINKGO=1 go test -covermode=atomic -coverprofile=unit-coverage.out `go list ./...`; cd ..;
$(GINKGO): install
@ -300,10 +300,10 @@ endif
e2e-pat: ## Runs e2e tests. Requires GITHUB_AUTH_TOKEN env var to be set to GitHub personal access token
e2e-pat: build-scorecard check-env | $(GINKGO)
# Run e2e tests. GITHUB_AUTH_TOKEN with personal access token must be exported to run this
TOKEN_TYPE="PAT" $(GINKGO) --race -p -v -cover -coverprofile=e2e-coverage.out ./...
TOKEN_TYPE="PAT" $(GINKGO) --race -p -v -cover -coverprofile=e2e-coverage.out --keep-separate-coverprofiles ./...
e2e-gh-token: ## Runs e2e tests. Requires GITHUB_AUTH_TOKEN env var to be set to default GITHUB_TOKEN
e2e-gh-token: build-scorecard check-env | $(GINKGO)
# Run e2e tests. GITHUB_AUTH_TOKEN set to secrets.GITHUB_TOKEN must be used to run this.
TOKEN_TYPE="GITHUB_TOKEN" $(GINKGO) --race -p -v -cover -coverprofile=e2e-coverage.out ./...
TOKEN_TYPE="GITHUB_TOKEN" $(GINKGO) --race -p -v -cover -coverprofile=e2e-coverage.out --keep-separate-coverprofiles ./...
###############################################################################

View File

@ -36,8 +36,6 @@ func (a AttestationPolicy) ToJSON() string {
func TestCheckPreventBinaryArtifacts(t *testing.T) {
t.Parallel()
dl := scut.TestDetailLogger{}
tests := []struct {
name string
raw *checker.RawResults
@ -107,6 +105,7 @@ func TestCheckPreventBinaryArtifacts(t *testing.T) {
tt := &tests[i]
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
dl := scut.TestDetailLogger{}
actual, err := CheckPreventBinaryArtifacts(tt.allowedBinaryArtifacts, tt.raw, &dl)
if !errors.Is(err, tt.err) {