@@ -14,33 +14,24 @@ import 'package:pub_semver/pub_semver.dart';
14
14
import 'package:pubspec_parse/pubspec_parse.dart' ;
15
15
import 'package:test/test.dart' ;
16
16
17
+ import 'package:sass/src/util/map.dart' ;
18
+
17
19
import '../tool/grind/generate_deprecations.dart' as deprecations;
18
20
import '../tool/grind/synchronize.dart' as synchronize;
19
21
20
22
/// Tests that double-check that everything in the repo looks sensible.
21
23
void main () {
22
24
group ("up-to-date generated" , () {
23
25
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));
42
28
}
43
29
});
30
+
31
+ test (
32
+ "deprecations" ,
33
+ () => _assertChecksumMatches (
34
+ deprecations.yamlPath, deprecations.dartPath));
44
35
},
45
36
// Windows sees different bytes than other OSes, possibly because of
46
37
// newline normalization issues.
@@ -182,3 +173,15 @@ void _checkVersionIncrementsAlong(
182
173
"at its major version as well" );
183
174
}
184
175
}
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