@@ -32,7 +32,7 @@ buildbot() => null;
32
32
Future buildSdkDocs () async {
33
33
delete (docsDir);
34
34
log ('building SDK docs' );
35
- var process = await Process .start (Platform .resolvedExecutable, [
35
+ Process process = await Process .start (Platform .resolvedExecutable, [
36
36
'bin/dartdoc.dart' ,
37
37
'--output' ,
38
38
'${docsDir .path }' ,
@@ -41,6 +41,11 @@ Future buildSdkDocs() async {
41
41
]);
42
42
stdout.addStream (process.stdout);
43
43
stderr.addStream (process.stderr);
44
+
45
+ int exitCode = await process.exitCode;
46
+ if (exitCode != 0 ) {
47
+ fail ("exitCode: $exitCode " );
48
+ }
44
49
}
45
50
46
51
@Task ('Checks that CHANGELOG mentions current version' )
@@ -202,29 +207,47 @@ updateTestPackageDocs() {
202
207
}
203
208
204
209
@Task ('Validate the SDK doc build.' )
205
- //@Depends(buildSdkDocs) unfortunately this doesn't work, because
206
- // I get Uncaught Error: Bad state: StreamSink is bound to a stream
207
- // if I run grind validate-sdk-docs. However, everything works
208
- // if I run grind build-sdk-docs manually.
209
- // See https://github.com/google/grinder.dart/issues/291
210
+ @Depends (buildSdkDocs)
210
211
validateSdkDocs () {
211
212
const expectedLibCount = 18 ;
212
- var indexHtml = joinFile (docsDir, ['index.html' ]);
213
+
214
+ File indexHtml = joinFile (docsDir, ['index.html' ]);
213
215
if (! indexHtml.existsSync ()) {
214
216
fail ('no index.html found for SDK docs' );
215
217
}
218
+ log ('found index.html' );
219
+ String indexContents = indexHtml.readAsStringSync ();
220
+ int foundLibs = _findCount (indexContents, ' <li><a href="dart-' );
221
+ if (foundLibs != expectedLibCount) {
222
+ fail ('expected $expectedLibCount dart: index.html entries, found $foundLibs ' );
223
+ }
224
+ log ('$foundLibs index.html dart: entries found' );
225
+
216
226
// check for the existence of certain files/dirs
217
227
var libsLength =
218
228
docsDir.listSync ().where ((fs) => fs.path.contains ('dart-' )).length;
219
- if (libsLength != expectedLibCount && libsLength != 17 ) {
229
+ if (libsLength != expectedLibCount) {
220
230
fail ('docs not generated for all the SDK libraries, '
221
231
'expected $expectedLibCount directories, generated $libsLength directories' );
222
232
}
233
+ log ('$libsLength dart: libraries found' );
234
+
223
235
var futureConstFile =
224
236
joinFile (docsDir, [path.join ('dart-async' , 'Future' , 'Future.html' )]);
225
237
if (! futureConstFile.existsSync ()) {
226
238
fail ('no Future.html found for dart:async Future constructor' );
227
239
}
240
+ log ('found Future.async ctor' );
241
+ }
242
+
243
+ int _findCount (String str, String match) {
244
+ int count = 0 ;
245
+ int index = str.indexOf (match);
246
+ while (index != - 1 ) {
247
+ count++ ;
248
+ index = str.indexOf (match, index + match.length);
249
+ }
250
+ return count;
228
251
}
229
252
230
253
_doCheck (String origin, Set <String > visited, String pathToCheck, bool error,
0 commit comments