| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart_style.test.command_line; | 5 library dart_style.test.utils; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
| 10 import 'package:scheduled_test/descriptor.dart' as d; | 10 import 'package:scheduled_test/descriptor.dart' as d; |
| 11 import 'package:scheduled_test/scheduled_process.dart'; | 11 import 'package:scheduled_test/scheduled_process.dart'; |
| 12 import 'package:scheduled_test/scheduled_test.dart'; | 12 import 'package:scheduled_test/scheduled_test.dart'; |
| 13 import 'package:unittest/compact_vm_config.dart'; | 13 import 'package:unittest/compact_vm_config.dart'; |
| 14 | 14 |
| 15 const unformattedSource = 'void main() => print("hello") ;'; | 15 const unformattedSource = 'void main() => print("hello") ;'; |
| 16 const formattedSource = 'void main() => print("hello");\n'; | 16 const formattedSource = 'void main() => print("hello");\n'; |
| 17 | 17 |
| 18 /// Runs the command line formatter, passing it [args]. | 18 /// Runs the command line formatter, passing it [args]. |
| 19 ScheduledProcess runFormatter([List<String> args]) { | 19 ScheduledProcess runFormatter([List<String> args]) { |
| 20 if (args == null) args = []; | 20 if (args == null) args = []; |
| 21 | 21 |
| 22 var formatterPath = p.join( | 22 var formatterPath = p.join( |
| 23 p.dirname(p.fromUri(Platform.script)), "..", "bin", "format.dart"); | 23 p.dirname(p.fromUri(Platform.script)), "..", "bin", "format.dart"); |
| 24 | 24 |
| 25 args.insert(0, formatterPath); | 25 args.insertAll(0, ["--package-root=${Platform.packageRoot}", formatterPath]); |
| 26 return new ScheduledProcess.start(Platform.executable, args); | 26 return new ScheduledProcess.start(Platform.executable, args); |
| 27 } | 27 } |
| 28 | 28 |
| 29 /// Runs the command line formatter, passing it the test directory followed by | 29 /// Runs the command line formatter, passing it the test directory followed by |
| 30 /// [args]. | 30 /// [args]. |
| 31 ScheduledProcess runFormatterOnDir([List<String> args]) { | 31 ScheduledProcess runFormatterOnDir([List<String> args]) { |
| 32 if (args == null) args = []; | 32 if (args == null) args = []; |
| 33 return runFormatter([d.defaultRoot]..addAll(args)); | 33 return runFormatter([d.defaultRoot]..addAll(args)); |
| 34 } | 34 } |
| 35 | 35 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 47 setUp(() { | 47 setUp(() { |
| 48 var tempDir = Directory.systemTemp.createTempSync('dart_style.test.'); | 48 var tempDir = Directory.systemTemp.createTempSync('dart_style.test.'); |
| 49 d.defaultRoot = tempDir.path; | 49 d.defaultRoot = tempDir.path; |
| 50 | 50 |
| 51 currentSchedule.onComplete.schedule(() { | 51 currentSchedule.onComplete.schedule(() { |
| 52 d.defaultRoot = null; | 52 d.defaultRoot = null; |
| 53 return tempDir.delete(recursive: true); | 53 return tempDir.delete(recursive: true); |
| 54 }); | 54 }); |
| 55 }); | 55 }); |
| 56 } | 56 } |
| OLD | NEW |