@@ -48,12 +48,14 @@ void main() {
48
48
'Use of this source code is governed by a BSD-style license that can be' ,
49
49
'found in the LICENSE file.' ,
50
50
],
51
+ bool useCrlf = false ,
51
52
}) {
52
53
final List <String > lines = < String > ['$prefix $comment $copyright ' ];
53
54
for (final String line in license) {
54
55
lines.add ('$comment $line ' );
55
56
}
56
- file.writeAsStringSync (lines.join ('\n ' ) + suffix + '\n ' );
57
+ final String newline = useCrlf ? '\r\n ' : '\n ' ;
58
+ file.writeAsStringSync (lines.join (newline) + suffix + newline);
57
59
}
58
60
59
61
test ('looks at only expected extensions' , () async {
@@ -140,6 +142,23 @@ void main() {
140
142
]));
141
143
});
142
144
145
+ test ('passes correct license blocks on Windows' , () async {
146
+ final File checked = root.childFile ('checked.cc' );
147
+ checked.createSync ();
148
+ _writeLicense (checked, useCrlf: true );
149
+
150
+ final List <String > output =
151
+ await runCapturingPrint (runner, < String > ['license-check' ]);
152
+
153
+ // Sanity check that the test did actually check a file.
154
+ expect (
155
+ output,
156
+ containsAllInOrder (< Matcher > [
157
+ contains ('Checking checked.cc' ),
158
+ contains ('All files passed validation!' ),
159
+ ]));
160
+ });
161
+
143
162
test ('handles the comment styles for all supported languages' , () async {
144
163
final File fileA = root.childFile ('file_a.cc' );
145
164
fileA.createSync ();
@@ -406,6 +425,24 @@ void main() {
406
425
]));
407
426
});
408
427
428
+ test ('passes correct LICENSE files on Windows' , () async {
429
+ final File license = root.childFile ('LICENSE' );
430
+ license.createSync ();
431
+ license
432
+ .writeAsStringSync (_correctLicenseFileText.replaceAll ('\n ' , '\r\n ' ));
433
+
434
+ final List <String > output =
435
+ await runCapturingPrint (runner, < String > ['license-check' ]);
436
+
437
+ // Sanity check that the test did actually check the file.
438
+ expect (
439
+ output,
440
+ containsAllInOrder (< Matcher > [
441
+ contains ('Checking LICENSE' ),
442
+ contains ('All files passed validation!' ),
443
+ ]));
444
+ });
445
+
409
446
test ('fails if any first-party LICENSE files are incorrectly formatted' ,
410
447
() async {
411
448
final File license = root.childFile ('LICENSE' );
0 commit comments