Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace map on testPhaseObjects to sync.Map #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions init.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package allure

import (
"github.com/jtolds/gls"
"sync"

"github.com/jtolds/gls"
)

var (
Expand All @@ -11,7 +12,7 @@ var (
resultsPath string
createFolderOnce sync.Once
copyEnvFileOnce sync.Once
testPhaseObjects map[string]*testPhaseContainer
testPhaseObjects sync.Map
)

const (
Expand All @@ -25,5 +26,5 @@ const (

func init() {
ctxMgr = gls.NewContextManager()
testPhaseObjects = make(map[string]*testPhaseContainer)
testPhaseObjects = sync.Map{}
}
17 changes: 5 additions & 12 deletions test_phase_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,11 @@ func (sc *subContainer) getStatus() string {
}

func getCurrentTestPhaseObject(t *testing.T) *testPhaseContainer {
var currentPhaseObject *testPhaseContainer
if phaseContainer, ok := testPhaseObjects[t.Name()]; ok {
currentPhaseObject = phaseContainer
} else {
currentPhaseObject = &testPhaseContainer{
Befores: make([]*container, 0),
Afters: make([]*container, 0),
}
testPhaseObjects[t.Name()] = currentPhaseObject
}

return currentPhaseObject
phaseContainer, _ := testPhaseObjects.LoadOrStore(t.Name(), &testPhaseContainer{
Befores: make([]*container, 0),
Afters: make([]*container, 0),
})
return phaseContainer.(*testPhaseContainer)
}

func (c container) writeResultsFile() error {
Expand Down