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

Side by Side Diff: packages/dart_style/test/utils.dart

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years 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
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.utils; 5 library dart_style.test.utils;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:mirrors';
8 9
9 import 'package:path/path.dart' as p; 10 import 'package:path/path.dart' as p;
10 import 'package:scheduled_test/descriptor.dart' as d; 11 import 'package:scheduled_test/descriptor.dart' as d;
11 import 'package:scheduled_test/scheduled_process.dart'; 12 import 'package:scheduled_test/scheduled_process.dart';
12 import 'package:scheduled_test/scheduled_test.dart'; 13 import 'package:scheduled_test/scheduled_test.dart';
13 14
14 const unformattedSource = 'void main() => print("hello") ;'; 15 const unformattedSource = 'void main() => print("hello") ;';
15 const formattedSource = 'void main() => print("hello");\n'; 16 const formattedSource = 'void main() => print("hello");\n';
16 17
17 /// Runs the command line formatter, passing it [args]. 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("bin", "format.dart"); 22 // Locate the "test" directory. Use mirrors so that this works with the test
23 // package, which loads this suite into an isolate.
24 var testDir = p.dirname(
25 currentMirrorSystem().findLibrary(#dart_style.test.utils).uri.path);
26
27 var formatterPath = p.normalize(p.join(testDir, "../bin/format.dart"));
22 28
23 args.insert(0, formatterPath); 29 args.insert(0, formatterPath);
24 30
25 // Use the same package root, if there is one. 31 // Use the same package root, if there is one.
26 if (Platform.packageRoot.isNotEmpty) { 32 if (Platform.packageRoot.isNotEmpty) {
27 args.insert(0, "--package-root=${Platform.packageRoot}"); 33 args.insert(0, "--package-root=${Platform.packageRoot}");
28 } 34 }
29 35
30 return new ScheduledProcess.start(Platform.executable, args); 36 return new ScheduledProcess.start(Platform.executable, args);
31 } 37 }
(...skipping 14 matching lines...) Expand all
46 setUp(() { 52 setUp(() {
47 var tempDir = Directory.systemTemp.createTempSync('dart_style.test.'); 53 var tempDir = Directory.systemTemp.createTempSync('dart_style.test.');
48 d.defaultRoot = tempDir.path; 54 d.defaultRoot = tempDir.path;
49 55
50 currentSchedule.onComplete.schedule(() { 56 currentSchedule.onComplete.schedule(() {
51 d.defaultRoot = null; 57 d.defaultRoot = null;
52 return tempDir.delete(recursive: true); 58 return tempDir.delete(recursive: true);
53 }); 59 });
54 }); 60 });
55 } 61 }
OLDNEW
« no previous file with comments | « packages/dart_style/test/splitting/mixed.stmt ('k') | packages/dart_style/test/whitespace/._blocks.stmt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698