@@ -48,12 +48,14 @@ void main() {
4848 'Use of this source code is governed by a BSD-style license that can be' ,
4949 'found in the LICENSE file.' ,
5050 ],
51+ bool useCrlf = false ,
5152 }) {
5253 final List <String > lines = < String > ['$prefix $comment $copyright ' ];
5354 for (final String line in license) {
5455 lines.add ('$comment $line ' );
5556 }
56- file.writeAsStringSync (lines.join ('\n ' ) + suffix + '\n ' );
57+ final String newline = useCrlf ? '\r\n ' : '\n ' ;
58+ file.writeAsStringSync (lines.join (newline) + suffix + newline);
5759 }
5860
5961 test ('looks at only expected extensions' , () async {
@@ -140,6 +142,23 @@ void main() {
140142 ]));
141143 });
142144
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+
143162 test ('handles the comment styles for all supported languages' , () async {
144163 final File fileA = root.childFile ('file_a.cc' );
145164 fileA.createSync ();
@@ -406,6 +425,24 @@ void main() {
406425 ]));
407426 });
408427
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+
409446 test ('fails if any first-party LICENSE files are incorrectly formatted' ,
410447 () async {
411448 final File license = root.childFile ('LICENSE' );
0 commit comments