Add the channel
parameter to the Dartpad samples (#115018)
* Add the channel paramter to the Dartpad samples * Add sanity check test * Make sample_id more generic
This commit is contained in:
parent
dccc761e53
commit
d0491dcf15
@ -13,7 +13,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<iframe class="snippet-dartpad"
|
<iframe class="snippet-dartpad"
|
||||||
src="https://dartpad.dev/embed-flutter.html?split=60&run=true&null_safety=true&sample_id={{id}}&sample_channel={{channel}}">
|
src="https://dartpad.dev/embed-flutter.html?split=60&run=true&null_safety=true&sample_id={{id}}&sample_channel={{channel}}&channel={{channel}}">
|
||||||
</iframe>
|
</iframe>
|
||||||
</div>
|
</div>
|
||||||
{@end-inject-html}
|
{@end-inject-html}
|
@ -394,7 +394,7 @@ void _sanityCheckExample(String fileString, String regExpString) {
|
|||||||
final RegExp regExp = RegExp(regExpString, dotAll: true);
|
final RegExp regExp = RegExp(regExpString, dotAll: true);
|
||||||
final String contents = file.readAsStringSync();
|
final String contents = file.readAsStringSync();
|
||||||
if (!regExp.hasMatch(contents)) {
|
if (!regExp.hasMatch(contents)) {
|
||||||
throw Exception("Missing example code in ${file.path}. Either it didn't get published, publishing has changed, or the example no longer exists.");
|
throw Exception("Missing example code matching '$regExpString' in ${file.path}.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
@ -403,7 +403,7 @@ void _sanityCheckExample(String fileString, String regExpString) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Runs a sanity check by running a test.
|
/// Runs a sanity check by running a test.
|
||||||
void sanityCheckDocs() {
|
void sanityCheckDocs([Platform platform = const LocalPlatform()]) {
|
||||||
final List<String> canaries = <String>[
|
final List<String> canaries = <String>[
|
||||||
'$kPublishRoot/assets/overrides.css',
|
'$kPublishRoot/assets/overrides.css',
|
||||||
'$kPublishRoot/api/dart-io/File-class.html',
|
'$kPublishRoot/api/dart-io/File-class.html',
|
||||||
@ -414,6 +414,7 @@ void sanityCheckDocs() {
|
|||||||
'$kPublishRoot/api/material/Material-class.html',
|
'$kPublishRoot/api/material/Material-class.html',
|
||||||
'$kPublishRoot/api/material/Tooltip-class.html',
|
'$kPublishRoot/api/material/Tooltip-class.html',
|
||||||
'$kPublishRoot/api/widgets/Widget-class.html',
|
'$kPublishRoot/api/widgets/Widget-class.html',
|
||||||
|
'$kPublishRoot/api/widgets/Listener-class.html',
|
||||||
];
|
];
|
||||||
for (final String canary in canaries) {
|
for (final String canary in canaries) {
|
||||||
if (!File(canary).existsSync()) {
|
if (!File(canary).existsSync()) {
|
||||||
@ -434,11 +435,28 @@ void sanityCheckDocs() {
|
|||||||
r'\s*<pre.*id="sample-code">.*Color\s+get\s+barrierColor.*</pre>',
|
r'\s*<pre.*id="sample-code">.*Color\s+get\s+barrierColor.*</pre>',
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check a "dartpad" example, any one will do.
|
// Check a "dartpad" example, any one will do, and check for the correct URL
|
||||||
_sanityCheckExample(
|
// arguments.
|
||||||
'$kPublishRoot/api/widgets/PhysicalShape-class.html',
|
// Just use "master" for any branch other than the LUCH_BRANCH.
|
||||||
r'\s*<iframe\s+class="snippet-dartpad"\s+src="https://dartpad\.dev.*sample_id=widgets\.PhysicalShape\.\d+.*">\s*</iframe>',
|
final String? luciBranch = platform.environment['LUCI_BRANCH']?.trim();
|
||||||
);
|
final String expectedBranch = luciBranch != null && luciBranch.isNotEmpty ? luciBranch : 'master';
|
||||||
|
final List<String> argumentRegExps = <String>[
|
||||||
|
r'split=\d+',
|
||||||
|
r'run=true',
|
||||||
|
r'null_safety=true',
|
||||||
|
r'sample_id=widgets\.Listener\.\d+',
|
||||||
|
'sample_channel=$expectedBranch',
|
||||||
|
'channel=$expectedBranch',
|
||||||
|
];
|
||||||
|
for (final String argumentRegExp in argumentRegExps) {
|
||||||
|
_sanityCheckExample(
|
||||||
|
'$kPublishRoot/api/widgets/Listener-class.html',
|
||||||
|
r'\s*<iframe\s+class="snippet-dartpad"\s+src="'
|
||||||
|
r'https:\/\/dartpad.dev\/embed-flutter.html\?.*?\b'
|
||||||
|
'$argumentRegExp'
|
||||||
|
r'\b.*">\s*<\/iframe>',
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a custom index.html because we try to maintain old
|
/// Creates a custom index.html because we try to maintain old
|
||||||
|
Loading…
x
Reference in New Issue
Block a user