File tree Expand file tree Collapse file tree 2 files changed +9
-15
lines changed Expand file tree Collapse file tree 2 files changed +9
-15
lines changed Original file line number Diff line number Diff line change 1
1
package allure
2
2
3
3
import (
4
- "github.com/jtolds/gls"
5
4
"sync"
5
+
6
+ "github.com/jtolds/gls"
6
7
)
7
8
8
9
var (
11
12
resultsPath string
12
13
createFolderOnce sync.Once
13
14
copyEnvFileOnce sync.Once
14
- testPhaseObjects map [ string ] * testPhaseContainer
15
+ testPhaseObjects sync. Map
15
16
)
16
17
17
18
const (
@@ -25,5 +26,5 @@ const (
25
26
26
27
func init () {
27
28
ctxMgr = gls .NewContextManager ()
28
- testPhaseObjects = make ( map [ string ] * testPhaseContainer )
29
+ testPhaseObjects = sync. Map {}
29
30
}
Original file line number Diff line number Diff line change @@ -112,18 +112,11 @@ func (sc *subContainer) getStatus() string {
112
112
}
113
113
114
114
func getCurrentTestPhaseObject (t * testing.T ) * testPhaseContainer {
115
- var currentPhaseObject * testPhaseContainer
116
- if phaseContainer , ok := testPhaseObjects [t .Name ()]; ok {
117
- currentPhaseObject = phaseContainer
118
- } else {
119
- currentPhaseObject = & testPhaseContainer {
120
- Befores : make ([]* container , 0 ),
121
- Afters : make ([]* container , 0 ),
122
- }
123
- testPhaseObjects [t .Name ()] = currentPhaseObject
124
- }
125
-
126
- return currentPhaseObject
115
+ phaseContainer , _ := testPhaseObjects .LoadOrStore (t .Name (), & testPhaseContainer {
116
+ Befores : make ([]* container , 0 ),
117
+ Afters : make ([]* container , 0 ),
118
+ })
119
+ return phaseContainer .(* testPhaseContainer )
127
120
}
128
121
129
122
func (c container ) writeResultsFile () error {
You can’t perform that action at this time.
0 commit comments