@@ -135,20 +135,20 @@ func Clean(m *testing.M, opts ...CleanOpts) (bool, error) {
135135}
136136
137137// getTestID will return the testID if the line is in the form of [Test... - number]
138- func getTestID (b []byte ) (string , bool ) {
138+ func getTestID (b []byte ) (string , string , bool ) {
139139 if len (b ) == 0 {
140- return "" , false
140+ return "" , "" , false
141141 }
142142
143143 // needs to start with [Test and end with ]
144144 if ! bytes .HasPrefix (b , []byte ("[Test" )) || b [len (b )- 1 ] != ']' {
145- return "" , false
145+ return "" , "" , false
146146 }
147147
148148 // needs to contain at least one ' - ' seperator
149149 firstSeparator := bytes .Index (b , []byte (" - " ))
150150 if firstSeparator == - 1 {
151- return "" , false
151+ return "" , "" , false
152152 }
153153
154154 // if there is a label, there will be a second seperator
@@ -160,10 +160,10 @@ func getTestID(b []byte) (string, bool) {
160160
161161 // needs to have a number after the first separator
162162 if ! isNumber (b [firstSeparator + 3 : secondSeparator ]) {
163- return "" , false
163+ return "" , "" , false
164164 }
165165
166- return string (b [1 : len (b )- 1 ]), true
166+ return string (b [1 : len (b )- 1 ]), string ( b [ 1 : secondSeparator ]), true
167167}
168168
169169func isNumber (b []byte ) bool {
@@ -266,14 +266,14 @@ func examineSnaps(
266266 for s .Scan () {
267267 b := s .Bytes ()
268268 // Check if line is a test id
269- testID , match := getTestID (b )
269+ testIDWithLabel , testIDWithoutLabel , match := getTestID (b )
270270 if ! match {
271271 continue
272272 }
273- testIDs = append (testIDs , testID )
273+ testIDs = append (testIDs , testIDWithLabel )
274274
275- if ! registeredTests .Has (testID ) && ! testSkipped (testID , runOnly ) {
276- obsoleteTests = append (obsoleteTests , testID )
275+ if ! registeredTests .Has (testIDWithoutLabel ) && ! testSkipped (testIDWithoutLabel , runOnly ) {
276+ obsoleteTests = append (obsoleteTests , testIDWithoutLabel )
277277 needsUpdating = true
278278
279279 removeSnapshot (s )
@@ -284,7 +284,7 @@ func examineSnaps(
284284 line := s .Bytes ()
285285
286286 if bytes .Equal (line , endSequenceByteSlice ) {
287- tests [testID ] = data .String ()
287+ tests [testIDWithLabel ] = data .String ()
288288
289289 data .Reset ()
290290 break
0 commit comments