dart-sass/test/synchronize_test.dart

33 lines
1.1 KiB
Dart
Raw Normal View History

// 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
import 'dart:io';
import 'package:crypto/crypto.dart';
import 'package:test/test.dart';
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);
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];
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.");
});
});
}