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

Unified Diff: pkg/analyzer/test/utils.dart

Issue 1266923004: More fixes for failures on the Windows bot (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/test/test_all.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/utils.dart
diff --git a/pkg/analyzer/test/utils.dart b/pkg/analyzer/test/utils.dart
index 2a9ba8113d1b82d33141338af43b63d8162d339d..7c9fbe01d274542be37c6747da69fa145036ff6b 100644
--- a/pkg/analyzer/test/utils.dart
+++ b/pkg/analyzer/test/utils.dart
@@ -2,46 +2,13 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-library utils;
+library analyzer.test.utils;
-import 'dart:io';
+import 'package:analyzer/src/generated/java_io.dart';
+import 'package:path/path.dart' as path;
+import 'package:unittest/unittest.dart';
-import 'package:analyzer/analyzer.dart';
-import 'package:path/path.dart' as pathos;
-
-/// Returns the string representation of the [AnalyzerErrorGroup] thrown when
-/// parsing [contents] as a Dart file. If [contents] doesn't throw any errors,
-/// this will return null.
-///
-/// This replaces the filename in the error string with its basename, since the
-/// full path will vary from machine to machine. It also replaces the exception
-/// message with "..." to decouple these tests from the specific exception
-/// messages.
-String errorsForFile(String contents) {
- return withTempDir((temp) {
- var path = pathos.join(temp, 'test.dart');
- new File(path).writeAsStringSync(contents);
- try {
- parseDartFile(path);
- } on AnalyzerErrorGroup catch (e) {
- return e.toString().replaceAllMapped(new RegExp(
- r"^(Error on line \d+ of )((?:[A-Z]+:)?[^:]+): .*$",
- multiLine: true),
- (match) => match[1] + pathos.basename(match[2]) + ': ...');
- }
- return null;
- });
-}
-
-/// Creates a temporary directory and passes its path to [fn]. Once [fn]
-/// completes, the temporary directory and all its contents will be deleted.
-///
-/// Returns the return value of [fn].
-dynamic withTempDir(fn(String path)) {
- var tempDir = Directory.systemTemp.createTempSync('analyzer_').path;
- try {
- return fn(tempDir);
- } finally {
- new Directory(tempDir).deleteSync(recursive: true);
- }
+void initializeTestEnvironment() {
+ groupSep = ' | ';
+ JavaFile.pathContext = path.posix;
}
« no previous file with comments | « pkg/analyzer/test/test_all.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698