12
12
13
13
import ReactVersion from 'shared/ReactVersion' ;
14
14
15
- function normalizeCodeLocInfo ( str ) {
16
- return (
17
- str &&
18
- str . replace ( / \n + (?: a t | i n ) ( [ \S ] + ) [ ^ \n ] * / g, function ( m , name ) {
19
- return '\n in ' + name + ' (at **)' ;
20
- } )
21
- ) ;
22
- }
23
-
24
- // TODO (enableSchedulingProfilerComponentStacks) Clean this up once the feature flag has been removed.
25
- function toggleComponentStacks ( mark ) {
26
- let expectedMark = mark ;
27
- gate ( ( { enableSchedulingProfilerComponentStacks} ) => {
28
- if ( ! enableSchedulingProfilerComponentStacks ) {
29
- const index = mark . indexOf ( '\n ' ) ;
30
- if ( index >= 0 ) {
31
- expectedMark = mark . substr ( 0 , index ) ;
32
- }
33
- }
34
- } ) ;
35
- return expectedMark ;
36
- }
37
-
38
15
describe ( 'SchedulingProfiler' , ( ) => {
39
16
let React ;
40
17
let ReactTestRenderer ;
@@ -162,9 +139,7 @@ describe('SchedulingProfiler', () => {
162
139
`--react-init-${ ReactVersion } ` ,
163
140
'--schedule-render-1' ,
164
141
'--render-start-1' ,
165
- toggleComponentStacks (
166
- '--suspense-suspend-0-Example-\n at Example\n at Suspense' ,
167
- ) ,
142
+ '--suspense-suspend-0-Example' ,
168
143
'--render-stop' ,
169
144
'--commit-start-1' ,
170
145
'--layout-effects-start-1' ,
@@ -175,11 +150,7 @@ describe('SchedulingProfiler', () => {
175
150
marks . splice ( 0 ) ;
176
151
177
152
await fakeSuspensePromise ;
178
- expect ( marks ) . toEqual ( [
179
- toggleComponentStacks (
180
- '--suspense-resolved-0-Example-\n at Example\n at Suspense' ,
181
- ) ,
182
- ] ) ;
153
+ expect ( marks ) . toEqual ( [ '--suspense-resolved-0-Example' ] ) ;
183
154
} ) ;
184
155
185
156
// @gate enableSchedulingProfiler
@@ -199,9 +170,7 @@ describe('SchedulingProfiler', () => {
199
170
`--react-init-${ ReactVersion } ` ,
200
171
'--schedule-render-1' ,
201
172
'--render-start-1' ,
202
- toggleComponentStacks (
203
- '--suspense-suspend-0-Example-\n at Example\n at Suspense' ,
204
- ) ,
173
+ '--suspense-suspend-0-Example' ,
205
174
'--render-stop' ,
206
175
'--commit-start-1' ,
207
176
'--layout-effects-start-1' ,
@@ -212,11 +181,7 @@ describe('SchedulingProfiler', () => {
212
181
marks . splice ( 0 ) ;
213
182
214
183
await expect ( fakeSuspensePromise ) . rejects . toThrow ( ) ;
215
- expect ( marks ) . toEqual ( [
216
- toggleComponentStacks (
217
- '--suspense-rejected-0-Example-\n at Example\n at Suspense' ,
218
- ) ,
219
- ] ) ;
184
+ expect ( marks ) . toEqual ( [ '--suspense-rejected-0-Example' ] ) ;
220
185
} ) ;
221
186
222
187
// @gate enableSchedulingProfiler
@@ -244,9 +209,7 @@ describe('SchedulingProfiler', () => {
244
209
245
210
expect ( marks ) . toEqual ( [
246
211
'--render-start-512' ,
247
- toggleComponentStacks (
248
- '--suspense-suspend-0-Example-\n at Example\n at Suspense' ,
249
- ) ,
212
+ '--suspense-suspend-0-Example' ,
250
213
'--render-stop' ,
251
214
'--commit-start-512' ,
252
215
'--layout-effects-start-512' ,
@@ -257,11 +220,7 @@ describe('SchedulingProfiler', () => {
257
220
marks . splice ( 0 ) ;
258
221
259
222
await fakeSuspensePromise ;
260
- expect ( marks ) . toEqual ( [
261
- toggleComponentStacks (
262
- '--suspense-resolved-0-Example-\n at Example\n at Suspense' ,
263
- ) ,
264
- ] ) ;
223
+ expect ( marks ) . toEqual ( [ '--suspense-resolved-0-Example' ] ) ;
265
224
} ) ;
266
225
267
226
// @gate enableSchedulingProfiler
@@ -289,9 +248,7 @@ describe('SchedulingProfiler', () => {
289
248
290
249
expect ( marks ) . toEqual ( [
291
250
'--render-start-512' ,
292
- toggleComponentStacks (
293
- '--suspense-suspend-0-Example-\n at Example\n at Suspense' ,
294
- ) ,
251
+ '--suspense-suspend-0-Example' ,
295
252
'--render-stop' ,
296
253
'--commit-start-512' ,
297
254
'--layout-effects-start-512' ,
@@ -302,11 +259,7 @@ describe('SchedulingProfiler', () => {
302
259
marks . splice ( 0 ) ;
303
260
304
261
await expect ( fakeSuspensePromise ) . rejects . toThrow ( ) ;
305
- expect ( marks ) . toEqual ( [
306
- toggleComponentStacks (
307
- '--suspense-rejected-0-Example-\n at Example\n at Suspense' ,
308
- ) ,
309
- ] ) ;
262
+ expect ( marks ) . toEqual ( [ '--suspense-rejected-0-Example' ] ) ;
310
263
} ) ;
311
264
312
265
// @gate enableSchedulingProfiler
@@ -332,14 +285,12 @@ describe('SchedulingProfiler', () => {
332
285
333
286
expect ( Scheduler ) . toFlushUntilNextPaint ( [ ] ) ;
334
287
335
- expect ( marks . map ( normalizeCodeLocInfo ) ) . toEqual ( [
288
+ expect ( marks ) . toEqual ( [
336
289
'--render-start-512' ,
337
290
'--render-stop' ,
338
291
'--commit-start-512' ,
339
292
'--layout-effects-start-512' ,
340
- toggleComponentStacks (
341
- '--schedule-state-update-1-Example-\n in Example (at **)' ,
342
- ) ,
293
+ '--schedule-state-update-1-Example' ,
343
294
'--layout-effects-stop' ,
344
295
'--render-start-1' ,
345
296
'--render-stop' ,
@@ -371,14 +322,12 @@ describe('SchedulingProfiler', () => {
371
322
372
323
expect ( Scheduler ) . toFlushUntilNextPaint ( [ ] ) ;
373
324
374
- expect ( marks . map ( normalizeCodeLocInfo ) ) . toEqual ( [
325
+ expect ( marks ) . toEqual ( [
375
326
'--render-start-512' ,
376
327
'--render-stop' ,
377
328
'--commit-start-512' ,
378
329
'--layout-effects-start-512' ,
379
- toggleComponentStacks (
380
- '--schedule-forced-update-1-Example-\n in Example (at **)' ,
381
- ) ,
330
+ '--schedule-forced-update-1-Example' ,
382
331
'--layout-effects-stop' ,
383
332
'--render-start-1' ,
384
333
'--render-stop' ,
@@ -415,16 +364,8 @@ describe('SchedulingProfiler', () => {
415
364
416
365
gate ( ( { old} ) =>
417
366
old
418
- ? expect ( marks . map ( normalizeCodeLocInfo ) ) . toContain (
419
- toggleComponentStacks (
420
- '--schedule-state-update-1024-Example-\n in Example (at **)' ,
421
- ) ,
422
- )
423
- : expect ( marks . map ( normalizeCodeLocInfo ) ) . toContain (
424
- toggleComponentStacks (
425
- '--schedule-state-update-512-Example-\n in Example (at **)' ,
426
- ) ,
427
- ) ,
367
+ ? expect ( marks ) . toContain ( '--schedule-state-update-1024-Example' )
368
+ : expect ( marks ) . toContain ( '--schedule-state-update-512-Example' ) ,
428
369
) ;
429
370
} ) ;
430
371
@@ -455,16 +396,8 @@ describe('SchedulingProfiler', () => {
455
396
456
397
gate ( ( { old} ) =>
457
398
old
458
- ? expect ( marks . map ( normalizeCodeLocInfo ) ) . toContain (
459
- toggleComponentStacks (
460
- '--schedule-forced-update-1024-Example-\n in Example (at **)' ,
461
- ) ,
462
- )
463
- : expect ( marks . map ( normalizeCodeLocInfo ) ) . toContain (
464
- toggleComponentStacks (
465
- '--schedule-forced-update-512-Example-\n in Example (at **)' ,
466
- ) ,
467
- ) ,
399
+ ? expect ( marks ) . toContain ( '--schedule-forced-update-1024-Example' )
400
+ : expect ( marks ) . toContain ( '--schedule-forced-update-512-Example' ) ,
468
401
) ;
469
402
} ) ;
470
403
@@ -489,14 +422,12 @@ describe('SchedulingProfiler', () => {
489
422
490
423
expect ( Scheduler ) . toFlushUntilNextPaint ( [ ] ) ;
491
424
492
- expect ( marks . map ( normalizeCodeLocInfo ) ) . toEqual ( [
425
+ expect ( marks ) . toEqual ( [
493
426
'--render-start-512' ,
494
427
'--render-stop' ,
495
428
'--commit-start-512' ,
496
429
'--layout-effects-start-512' ,
497
- toggleComponentStacks (
498
- '--schedule-state-update-1-Example-\n in Example (at **)' ,
499
- ) ,
430
+ '--schedule-state-update-1-Example' ,
500
431
'--layout-effects-stop' ,
501
432
'--render-start-1' ,
502
433
'--render-stop' ,
@@ -522,7 +453,7 @@ describe('SchedulingProfiler', () => {
522
453
523
454
gate ( ( { old} ) => {
524
455
if ( old ) {
525
- expect ( marks . map ( normalizeCodeLocInfo ) ) . toEqual ( [
456
+ expect ( marks ) . toEqual ( [
526
457
`--react-init-${ ReactVersion } ` ,
527
458
'--schedule-render-512' ,
528
459
'--render-start-512' ,
@@ -532,17 +463,15 @@ describe('SchedulingProfiler', () => {
532
463
'--layout-effects-stop' ,
533
464
'--commit-stop' ,
534
465
'--passive-effects-start-512' ,
535
- toggleComponentStacks (
536
- '--schedule-state-update-1024-Example-\n in Example (at **)' ,
537
- ) ,
466
+ '--schedule-state-update-1024-Example' ,
538
467
'--passive-effects-stop' ,
539
468
'--render-start-1024' ,
540
469
'--render-stop' ,
541
470
'--commit-start-1024' ,
542
471
'--commit-stop' ,
543
472
] ) ;
544
473
} else {
545
- expect ( marks . map ( normalizeCodeLocInfo ) ) . toEqual ( [
474
+ expect ( marks ) . toEqual ( [
546
475
`--react-init-${ ReactVersion } ` ,
547
476
'--schedule-render-512' ,
548
477
'--render-start-512' ,
@@ -552,9 +481,7 @@ describe('SchedulingProfiler', () => {
552
481
'--layout-effects-stop' ,
553
482
'--commit-stop' ,
554
483
'--passive-effects-start-512' ,
555
- toggleComponentStacks (
556
- '--schedule-state-update-1024-Example-\n in Example (at **)' ,
557
- ) ,
484
+ '--schedule-state-update-1024-Example' ,
558
485
'--passive-effects-stop' ,
559
486
'--render-start-1024' ,
560
487
'--render-stop' ,
@@ -583,16 +510,8 @@ describe('SchedulingProfiler', () => {
583
510
584
511
gate ( ( { old} ) =>
585
512
old
586
- ? expect ( marks . map ( normalizeCodeLocInfo ) ) . toContain (
587
- toggleComponentStacks (
588
- '--schedule-state-update-1024-Example-\n in Example (at **)' ,
589
- ) ,
590
- )
591
- : expect ( marks . map ( normalizeCodeLocInfo ) ) . toContain (
592
- toggleComponentStacks (
593
- '--schedule-state-update-512-Example-\n in Example (at **)' ,
594
- ) ,
595
- ) ,
513
+ ? expect ( marks ) . toContain ( '--schedule-state-update-1024-Example' )
514
+ : expect ( marks ) . toContain ( '--schedule-state-update-512-Example' ) ,
596
515
) ;
597
516
} ) ;
598
517
} ) ;
0 commit comments