Skip to content

Commit

Permalink
🌱 Tests: Fix data race failures (#2262)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
raghavkaul authored Sep 19, 2022
1 parent 2231d1f commit 482a59e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 ./...
###############################################################################
3 changes: 1 addition & 2 deletions attestor/attestation_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 482a59e

Please sign in to comment.