Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:async'; | ||
import 'dart:io'; | ||
|
||
import 'package:test/test.dart'; | ||
|
||
main() { | ||
group('check for copyright headers', () { | ||
test('... in lib', () async { | ||
await validate('lib'); | ||
}); | ||
test('... in tool', () async { | ||
await validate('tool'); | ||
}); | ||
}); | ||
} | ||
|
||
Future validate(String dir) async { | ||
List<String> violations = <String>[]; | ||
await for (FileSystemEntity entity | ||
in new Directory(dir).list(recursive: true, followLinks: false)) { | ||
if (entity is File && entity.path.endsWith('.dart')) { | ||
RandomAccessFile file = await entity.open(); | ||
List<int> bytes = await file.read(40); | ||
String header = new String.fromCharCodes(bytes); | ||
if (!header.startsWith( | ||
new RegExp('// Copyright \\(c\\) 20[0-9][0-9], the Dart project'))) { | ||
violations.add(entity.path); | ||
} | ||
} | ||
} | ||
expect(violations, isEmpty, reason: '''Files missing copyright headers. | ||
See CONTRIBUTING.md for format details.'''); | ||
} |