From f8f8badb9ac883f99f5d4e60837f505a86d0e0f2 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Thu, 9 Jan 2025 12:01:57 -0800 Subject: [PATCH 1/2] Reduce the expected number of categorized libraries in Dart SDK --- tool/task.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tool/task.dart b/tool/task.dart index 8244570015..ef009544eb 100644 --- a/tool/task.dart +++ b/tool/task.dart @@ -937,8 +937,8 @@ Not all files are formatted: Future validateSdkDocs() async { await docSdk(); const expectedLibCount = 0; - const expectedSubLibCounts = {19, 20, 21}; - const expectedTotalCounts = {19, 20, 21}; + const expectedSubLibCount = 13; + const expectedTotalCount = 20; var indexHtml = File(path.join(_sdkDocsDir.path, 'index.html')); if (!indexHtml.existsSync()) { throw StateError("No 'index.html' found for the SDK docs"); @@ -955,8 +955,8 @@ Future validateSdkDocs() async { var foundSubLibCount = _findCount(indexContents, '
  • validateSdkDocs() async { var libraries = _sdkDocsDir.listSync().where((fs) => fs.path.contains('dart-')); var libraryCount = libraries.length; - if (!expectedTotalCounts.contains(libraryCount)) { + if (expectedTotalCount != libraryCount) { var libraryNames = libraries.map((l) => "'${path.basename(l.path)}'").join(', '); throw StateError('Unexpected docs generated for SDK libraries; expected ' - '$expectedTotalCounts directories, but $libraryCount directories were ' + '$expectedTotalCount directories, but $libraryCount directories were ' 'generated: $libraryNames'); } print("Found $libraryCount 'dart:' libraries"); From d969955d5a1475a49edfc2cfc102394965b3ef41 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Thu, 9 Jan 2025 15:12:06 -0800 Subject: [PATCH 2/2] fix-regexp --- tool/task.dart | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tool/task.dart b/tool/task.dart index ef009544eb..e0a843c473 100644 --- a/tool/task.dart +++ b/tool/task.dart @@ -937,7 +937,7 @@ Not all files are formatted: Future validateSdkDocs() async { await docSdk(); const expectedLibCount = 0; - const expectedSubLibCount = 13; + const expectedSubLibCount = 20; const expectedTotalCount = 20; var indexHtml = File(path.join(_sdkDocsDir.path, 'index.html')); if (!indexHtml.existsSync()) { @@ -953,8 +953,9 @@ Future validateSdkDocs() async { } print("Found $foundLibCount 'dart:' entries in 'index.html'"); - var foundSubLibCount = - _findCount(indexContents, '
  • ]*href="dart-'); + var foundSubLibCount = _findCount(indexContents, libLinkPattern); if (expectedSubLibCount != foundSubLibCount) { throw StateError("Expected $expectedSubLibCount 'dart:' entries in " "'index.html' to be in categories, but found $foundSubLibCount"); @@ -987,12 +988,12 @@ final Directory _sdkDocsDir = Directory.systemTemp.createTempSync('sdkdocs').absolute; /// Returns the number of (perhaps overlapping) occurrences of [str] in [match]. -int _findCount(String str, String match) { +int _findCount(String str, Pattern match) { var count = 0; var index = str.indexOf(match); while (index != -1) { count++; - index = str.indexOf(match, index + match.length); + index = str.indexOf(match, index + 1); } return count; }