@@ -8,6 +8,7 @@ import 'package:args/command_runner.dart';
88import 'package:file/file.dart' ;
99import 'package:file/memory.dart' ;
1010import 'package:flutter_plugin_tools/src/common/core.dart' ;
11+ import 'package:flutter_plugin_tools/src/common/file_utils.dart' ;
1112import 'package:flutter_plugin_tools/src/format_command.dart' ;
1213import 'package:path/path.dart' as p;
1314import 'package:test/test.dart' ;
@@ -85,6 +86,7 @@ void main() {
8586 'lib/src/b.dart' ,
8687 'lib/src/c.dart' ,
8788 ];
89+ const String fileWithOptOut = 'lib/src/d.dart' ;
8890 final Directory pluginDir = createFakePlugin (
8991 'a_plugin' ,
9092 packagesDir,
@@ -106,6 +108,42 @@ void main() {
106108 ]));
107109 });
108110
111+ test ('does not format .dart files with pragma' , () async {
112+ const List <String > formattedFiles = < String > [
113+ 'lib/a.dart' ,
114+ 'lib/src/b.dart' ,
115+ 'lib/src/c.dart' ,
116+ ];
117+ const String unformattedFile = 'lib/src/d.dart' ;
118+ final Directory pluginDir = createFakePlugin (
119+ 'a_plugin' ,
120+ packagesDir,
121+ extraFiles: < String > [
122+ ...formattedFiles,
123+ unformattedFile,
124+ ],
125+ );
126+
127+ final p.Context posixContext = p.posix;
128+ childFileWithSubcomponents (pluginDir, posixContext.split (unformattedFile))
129+ .writeAsStringSync (
130+ '// copyright bla bla\n // This file is hand-formatted.\n code...' );
131+
132+ await runCapturingPrint (runner, < String > ['format' ]);
133+
134+ expect (
135+ processRunner.recordedCalls,
136+ orderedEquals (< ProcessCall > [
137+ ProcessCall (
138+ getFlutterCommand (mockPlatform),
139+ < String > [
140+ 'format' ,
141+ ..._getPackagesDirRelativePaths (pluginDir, formattedFiles)
142+ ],
143+ packagesDir.path),
144+ ]));
145+ });
146+
109147 test ('fails if flutter format fails' , () async {
110148 const List <String > files = < String > [
111149 'lib/a.dart' ,
0 commit comments