2017-11-20 23:30:42 +01:00
|
|
|
// Copyright 2017 Google Inc. Use of this source code is governed by an
|
|
|
|
// MIT-style license that can be found in the LICENSE file or at
|
|
|
|
// https://opensource.org/licenses/MIT.
|
|
|
|
|
2019-04-23 23:48:15 +02:00
|
|
|
// Windows sees different bytes than other OSes, possibly because of newline
|
|
|
|
// normalization issues.
|
|
|
|
@TestOn('vm && !windows')
|
2017-12-02 23:39:53 +01:00
|
|
|
|
2017-11-20 23:30:42 +01:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:crypto/crypto.dart';
|
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
2018-12-21 00:03:28 +01:00
|
|
|
import '../tool/grind/synchronize.dart' as synchronize;
|
|
|
|
|
2019-04-23 23:48:15 +02:00
|
|
|
/// The pattern of a checksum in a generated file.
|
|
|
|
final _checksumPattern = RegExp(r"^// Checksum: (.*)$", multiLine: true);
|
|
|
|
|
2017-11-20 23:30:42 +01:00
|
|
|
void main() {
|
2019-04-23 23:48:15 +02:00
|
|
|
synchronize.sources.forEach((sourcePath, targetPath) {
|
|
|
|
test("synchronized file $targetPath is up-to-date", () {
|
2018-11-16 00:16:24 +01:00
|
|
|
var target = File(targetPath).readAsStringSync();
|
2019-04-23 23:48:15 +02:00
|
|
|
var actualHash = _checksumPattern.firstMatch(target)[1];
|
2017-11-20 23:30:42 +01:00
|
|
|
|
2019-04-23 23:48:15 +02:00
|
|
|
var source = File(sourcePath).readAsBytesSync();
|
|
|
|
var expectedHash = sha1.convert(source).toString();
|
|
|
|
expect(actualHash, equals(expectedHash),
|
|
|
|
reason: "$targetPath is out-of-date.\n"
|
|
|
|
"Run pub run grinder to update it.");
|
2017-11-20 23:30:42 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|