Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Side by Side Diff: test/utils.dart

Issue 945583004: If no paths are provided, read source from stdin. Fix #165. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/command_line_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.command_line;
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 ScheduledProcess runFormatter([List<String> args]) { 19 ScheduledProcess runFormatter([List<String> args]) {
19 if (args == null) args = []; 20 if (args == null) args = [];
20 21
21 var formatterPath = p.join( 22 var formatterPath = p.join(
22 p.dirname(p.fromUri(Platform.script)), "..", "bin", "format.dart"); 23 p.dirname(p.fromUri(Platform.script)), "..", "bin", "format.dart");
23 24
24 args.insertAll(0, [formatterPath, d.defaultRoot]); 25 args.insert(0, formatterPath);
25 return new ScheduledProcess.start(Platform.executable, args); 26 return new ScheduledProcess.start(Platform.executable, args);
26 } 27 }
27 28
29 /// Runs the command line formatter, passing it the test directory followed by
30 /// [args].
31 ScheduledProcess runFormatterOnDir([List<String> args]) {
32 if (args == null) args = [];
33 return runFormatter([d.defaultRoot]..addAll(args));
34 }
35
28 /// Set up the scheduled test suite. 36 /// Set up the scheduled test suite.
29 /// 37 ///
30 /// Configures the unit test output and makes a sandbox directory for the 38 /// Configures the unit test output and makes a sandbox directory for the
31 /// scheduled tests to run in. 39 /// scheduled tests to run in.
32 void setUpTestSuite() { 40 void setUpTestSuite() {
33 // Tidy up the unittest output. 41 // Tidy up the unittest output.
34 filterStacks = true; 42 filterStacks = true;
35 formatStacks = true; 43 formatStacks = true;
36 useCompactVMConfiguration(); 44 useCompactVMConfiguration();
37 45
38 // Make a sandbox directory for the scheduled tests to run in. 46 // Make a sandbox directory for the scheduled tests to run in.
39 setUp(() { 47 setUp(() {
40 var tempDir = Directory.systemTemp.createTempSync('dart_style.test.'); 48 var tempDir = Directory.systemTemp.createTempSync('dart_style.test.');
41 d.defaultRoot = tempDir.path; 49 d.defaultRoot = tempDir.path;
42 50
43 currentSchedule.onComplete.schedule(() { 51 currentSchedule.onComplete.schedule(() {
44 d.defaultRoot = null; 52 d.defaultRoot = null;
45 return tempDir.delete(recursive: true); 53 return tempDir.delete(recursive: true);
46 }); 54 });
47 }); 55 });
48 } 56 }
OLDNEW
« no previous file with comments | « test/command_line_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698