@@ -14,33 +14,24 @@ import 'package:pub_semver/pub_semver.dart';
1414import 'package:pubspec_parse/pubspec_parse.dart' ;
1515import 'package:test/test.dart' ;
1616
17+ import 'package:sass/src/util/map.dart' ;
18+
1719import '../tool/grind/generate_deprecations.dart' as deprecations;
1820import '../tool/grind/synchronize.dart' as synchronize;
1921
2022/// Tests that double-check that everything in the repo looks sensible.
2123void main () {
2224 group ("up-to-date generated" , () {
2325 group ("synchronized file:" , () {
24- synchronize.sources.forEach ((sourcePath, targetPath) {
25- test (targetPath, () {
26- if (File (targetPath).readAsStringSync () !=
27- synchronize.synchronizeFile (sourcePath)) {
28- fail ("$targetPath is out-of-date.\n "
29- "Run `dart run grinder` to update it." );
30- }
31- });
32- });
33- });
34-
35- test ("deprecations" , () {
36- var inputText = File (deprecations.yamlPath).readAsStringSync ();
37- var outputText = File (deprecations.dartPath).readAsStringSync ();
38- var checksum = sha1.convert (utf8.encode (inputText));
39- if (! outputText.contains ('// Checksum: $checksum ' )) {
40- fail ('${deprecations .dartPath } is out-of-date.\n '
41- 'Run `dart run grinder` to update it.' );
26+ for (var (sourcePath, targetPath) in synchronize.sources.pairs) {
27+ test (targetPath, () => _assertChecksumMatches (sourcePath, targetPath));
4228 }
4329 });
30+
31+ test (
32+ "deprecations" ,
33+ () => _assertChecksumMatches (
34+ deprecations.yamlPath, deprecations.dartPath));
4435 },
4536 // Windows sees different bytes than other OSes, possibly because of
4637 // newline normalization issues.
@@ -182,3 +173,15 @@ void _checkVersionIncrementsAlong(
182173 "at its major version as well" );
183174 }
184175}
176+
177+ /// Throws an error if the checksum in [outputPath] doesn't match the hash of
178+ /// the contents of [inputPath] .
179+ void _assertChecksumMatches (String inputPath, String outputPath) {
180+ var inputText = File (inputPath).readAsStringSync ();
181+ var outputText = File (outputPath).readAsStringSync ();
182+ var checksum = sha1.convert (utf8.encode (inputText));
183+ if (! outputText.contains ('// Checksum: $checksum ' )) {
184+ fail ('$outputPath is out-of-date.\n '
185+ 'Run `dart run grinder` to update it.' );
186+ }
187+ }
0 commit comments