@@ -32,7 +32,7 @@ buildbot() => null;
3232Future buildSdkDocs () async {
3333 delete (docsDir);
3434 log ('building SDK docs' );
35- var process = await Process .start (Platform .resolvedExecutable, [
35+ Process process = await Process .start (Platform .resolvedExecutable, [
3636 'bin/dartdoc.dart' ,
3737 '--output' ,
3838 '${docsDir .path }' ,
@@ -41,6 +41,11 @@ Future buildSdkDocs() async {
4141 ]);
4242 stdout.addStream (process.stdout);
4343 stderr.addStream (process.stderr);
44+
45+ int exitCode = await process.exitCode;
46+ if (exitCode != 0 ) {
47+ fail ("exitCode: $exitCode " );
48+ }
4449}
4550
4651@Task ('Checks that CHANGELOG mentions current version' )
@@ -202,29 +207,47 @@ updateTestPackageDocs() {
202207}
203208
204209@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)
210211validateSdkDocs () {
211212 const expectedLibCount = 18 ;
212- var indexHtml = joinFile (docsDir, ['index.html' ]);
213+
214+ File indexHtml = joinFile (docsDir, ['index.html' ]);
213215 if (! indexHtml.existsSync ()) {
214216 fail ('no index.html found for SDK docs' );
215217 }
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+
216226 // check for the existence of certain files/dirs
217227 var libsLength =
218228 docsDir.listSync ().where ((fs) => fs.path.contains ('dart-' )).length;
219- if (libsLength != expectedLibCount && libsLength != 17 ) {
229+ if (libsLength != expectedLibCount) {
220230 fail ('docs not generated for all the SDK libraries, '
221231 'expected $expectedLibCount directories, generated $libsLength directories' );
222232 }
233+ log ('$libsLength dart: libraries found' );
234+
223235 var futureConstFile =
224236 joinFile (docsDir, [path.join ('dart-async' , 'Future' , 'Future.html' )]);
225237 if (! futureConstFile.existsSync ()) {
226238 fail ('no Future.html found for dart:async Future constructor' );
227239 }
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;
228251}
229252
230253_doCheck (String origin, Set <String > visited, String pathToCheck, bool error,
0 commit comments