OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analyzer_cli.test.utils; | 5 library analyzer_cli.test.utils; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
9 | 9 |
10 import 'package:analyzer/analyzer.dart'; | 10 import 'package:analyzer/analyzer.dart'; |
11 import 'package:analyzer/src/generated/java_io.dart'; | |
12 import 'package:path/path.dart' as pathos; | 11 import 'package:path/path.dart' as pathos; |
13 import 'package:path/path.dart' as path; | |
14 import 'package:unittest/unittest.dart'; | 12 import 'package:unittest/unittest.dart'; |
15 | 13 |
16 /// Gets the test directory in a way that works with | 14 /// Gets the test directory in a way that works with |
17 /// package:test and package:unittest. | 15 /// package:test and package:unittest. |
18 /// See <https://github.com/dart-lang/test/issues/110> for more info. | 16 /// See <https://github.com/dart-lang/test/issues/110> for more info. |
19 final String testDirectory = pathos.dirname( | 17 final String testDirectory = pathos.dirname( |
20 pathos.fromUri((reflectClass(_TestUtils).owner as LibraryMirror).uri)); | 18 pathos.fromUri((reflectClass(_TestUtils).owner as LibraryMirror).uri)); |
21 | 19 |
22 /// Returns the string representation of the [AnalyzerErrorGroup] thrown when | 20 /// Returns the string representation of the [AnalyzerErrorGroup] thrown when |
23 /// parsing [contents] as a Dart file. If [contents] doesn't throw any errors, | 21 /// parsing [contents] as a Dart file. If [contents] doesn't throw any errors, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 dynamic withTempDir(fn(String path)) { | 53 dynamic withTempDir(fn(String path)) { |
56 var tempDir = Directory.systemTemp.createTempSync('analyzer_').path; | 54 var tempDir = Directory.systemTemp.createTempSync('analyzer_').path; |
57 try { | 55 try { |
58 return fn(tempDir); | 56 return fn(tempDir); |
59 } finally { | 57 } finally { |
60 new Directory(tempDir).deleteSync(recursive: true); | 58 new Directory(tempDir).deleteSync(recursive: true); |
61 } | 59 } |
62 } | 60 } |
63 | 61 |
64 class _TestUtils {} | 62 class _TestUtils {} |
OLD | NEW |