rename stats tool and setup internals for extensibility
diff --git a/pkgs/markdown/README.md b/pkgs/markdown/README.md index e128357..3358d9d 100644 --- a/pkgs/markdown/README.md +++ b/pkgs/markdown/README.md
@@ -101,7 +101,7 @@ #### Updating CommonMark stats when changing the implementation 1. Update the library and test code, making sure that tests still pass. - 2. Run `dart tool/common_mark_stats.dart --update-files` to update the + 2. Run `dart tool/stats.dart --update-files` to update the per-test results `tool/common_mark_stats.json` and the test summary `tool/common_mark_stats.txt`. 3. Verify that more tests now pass – or at least, no more tests fail.
diff --git a/pkgs/markdown/tool/README.md b/pkgs/markdown/tool/README.md index f2daa84..cd0e563 100644 --- a/pkgs/markdown/tool/README.md +++ b/pkgs/markdown/tool/README.md
@@ -47,5 +47,5 @@ runs the package through the CommonMark specs. To run it, simply run: ```bash -$ dart tool/common_mark_stats.dart +$ dart tool/stats.dart ```
diff --git a/pkgs/markdown/tool/common_mark_stats.dart b/pkgs/markdown/tool/stats.dart similarity index 93% rename from pkgs/markdown/tool/common_mark_stats.dart rename to pkgs/markdown/tool/stats.dart index d380237..ab970f9 100644 --- a/pkgs/markdown/tool/common_mark_stats.dart +++ b/pkgs/markdown/tool/stats.dart
@@ -11,8 +11,6 @@ import 'package:markdown/markdown.dart' show markdownToHtml; import 'package:path/path.dart' as p; -const _commonMarkTests = 'common_mark_tests.json'; - // Locate the "tool" directory. Use mirrors so that this works with the test // package, which loads this suite into an isolate. String get _currentDir => p @@ -60,7 +58,9 @@ return; } - var sections = _loadCommonMarkSections(); + final testPrefix = 'common_mark'; + + var sections = _loadCommonMarkSections(testPrefix); var scores = new SplayTreeMap<String, SplayTreeMap<int, CompareLevel>>( compareAsciiLowerCaseNatural); @@ -78,11 +78,11 @@ }); if (raw || updateFiles) { - await _printRaw(scores, updateFiles); + await _printRaw(testPrefix, scores, updateFiles); } if (!raw || updateFiles) { - await _printFriendly(scores, updateFiles); + await _printFriendly(testPrefix, scores, updateFiles); } } @@ -158,10 +158,10 @@ return obj; } -Future _printRaw(Map scores, bool updateFiles) async { +Future _printRaw(String testPrefix, Map scores, bool updateFiles) async { IOSink sink; if (updateFiles) { - var path = p.join(_currentDir, 'common_mark_stats.json'); + var path = p.join(_currentDir, '${testPrefix}_stats.json'); print('Updating $path'); var file = new File(path); sink = file.openWrite(); @@ -183,6 +183,7 @@ } Future _printFriendly( + String testPrefix, SplayTreeMap<String, SplayTreeMap<int, CompareLevel>> scores, bool updateFiles) async { const countWidth = 4; @@ -192,7 +193,7 @@ IOSink sink; if (updateFiles) { - var path = p.join(_currentDir, 'common_mark_stats.txt'); + var path = p.join(_currentDir, '${testPrefix}_stats.txt'); print('Updating $path'); var file = new File(path); sink = file.openWrite(); @@ -284,8 +285,9 @@ return true; } -Map<String, List<CommonMarkTestCase>> _loadCommonMarkSections() { - var testFile = new File(p.join(_currentDir, _commonMarkTests)); +Map<String, List<CommonMarkTestCase>> _loadCommonMarkSections( + String testPrefix) { + var testFile = new File(p.join(_currentDir, '${testPrefix}_tests.json')); var testsJson = testFile.readAsStringSync(); var testArray = JSON.decode(testsJson) as List<Map<String, dynamic>>;