@@ -394,7 +394,7 @@ void _sanityCheckExample(String fileString, String regExpString) {
394
394
final RegExp regExp = RegExp (regExpString, dotAll: true );
395
395
final String contents = file.readAsStringSync ();
396
396
if (! regExp.hasMatch (contents)) {
397
- throw Exception ("Missing example code in ${file .path }. Either it didn't get published, publishing has changed, or the example no longer exists ." );
397
+ throw Exception ("Missing example code matching '$ regExpString ' in ${file .path }." );
398
398
}
399
399
} else {
400
400
throw Exception (
@@ -403,7 +403,7 @@ void _sanityCheckExample(String fileString, String regExpString) {
403
403
}
404
404
405
405
/// Runs a sanity check by running a test.
406
- void sanityCheckDocs () {
406
+ void sanityCheckDocs ([ Platform platform = const LocalPlatform ()] ) {
407
407
final List <String > canaries = < String > [
408
408
'$kPublishRoot /assets/overrides.css' ,
409
409
'$kPublishRoot /api/dart-io/File-class.html' ,
@@ -414,6 +414,7 @@ void sanityCheckDocs() {
414
414
'$kPublishRoot /api/material/Material-class.html' ,
415
415
'$kPublishRoot /api/material/Tooltip-class.html' ,
416
416
'$kPublishRoot /api/widgets/Widget-class.html' ,
417
+ '$kPublishRoot /api/widgets/Listener-class.html' ,
417
418
];
418
419
for (final String canary in canaries) {
419
420
if (! File (canary).existsSync ()) {
@@ -434,11 +435,28 @@ void sanityCheckDocs() {
434
435
r'\s*<pre.*id="sample-code">.*Color\s+get\s+barrierColor.*</pre>' ,
435
436
);
436
437
437
- // Check a "dartpad" example, any one will do.
438
- _sanityCheckExample (
439
- '$kPublishRoot /api/widgets/PhysicalShape-class.html' ,
440
- r'\s*<iframe\s+class="snippet-dartpad"\s+src="https://dartpad\.dev.*sample_id=widgets\.PhysicalShape\.\d+.*">\s*</iframe>' ,
441
- );
438
+ // Check a "dartpad" example, any one will do, and check for the correct URL
439
+ // arguments.
440
+ // Just use "master" for any branch other than the LUCH_BRANCH.
441
+ final String ? luciBranch = platform.environment['LUCI_BRANCH' ]? .trim ();
442
+ final String expectedBranch = luciBranch != null && luciBranch.isNotEmpty ? luciBranch : 'master' ;
443
+ final List <String > argumentRegExps = < String > [
444
+ r'split=\d+' ,
445
+ r'run=true' ,
446
+ r'null_safety=true' ,
447
+ r'sample_id=widgets\.Listener\.\d+' ,
448
+ 'sample_channel=$expectedBranch ' ,
449
+ 'channel=$expectedBranch ' ,
450
+ ];
451
+ for (final String argumentRegExp in argumentRegExps) {
452
+ _sanityCheckExample (
453
+ '$kPublishRoot /api/widgets/Listener-class.html' ,
454
+ r'\s*<iframe\s+class="snippet-dartpad"\s+src="'
455
+ r'https:\/\/dartpad.dev\/embed-flutter.html\?.*?\b'
456
+ '$argumentRegExp '
457
+ r'\b.*">\s*<\/iframe>' ,
458
+ );
459
+ }
442
460
}
443
461
444
462
/// Creates a custom index.html because we try to maintain old
0 commit comments