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

Unified Diff: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart

Issue 2983703002: Fix analyzer test after making CompilerContext mandatory (Closed)
Patch Set: Created 3 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
index df4d37210a3b7013d25138c70dc747fae9d50ec6..539a7f2a84f3c0bb2319111cfe7f1d7374c681a6 100644
--- a/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
+++ b/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart
@@ -18,6 +18,7 @@ import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/utilities_dart.dart';
import 'package:front_end/src/base/instrumentation.dart' as fasta;
import 'package:front_end/src/fasta/compiler_context.dart' as fasta;
+import 'package:front_end/src/fasta/compiler_command_line.dart' as fasta;
import 'package:front_end/src/fasta/testing/validating_instrumentation.dart'
as fasta;
import 'package:front_end/src/fasta/util/relativize.dart' show relativizeUri;
@@ -133,33 +134,35 @@ class _ElementNamer {
}
class _FrontEndInferenceTest extends BaseAnalysisDriverTest {
- Future<String> runTest(String path, String code) async {
- Uri uri = provider.pathContext.toUri(path);
+ Future<String> runTest(String path, String code) {
+ return fasta.CompilerCommandLine.withGlobalOptions("", [""], (_) async {
+ Uri uri = provider.pathContext.toUri(path);
- List<int> lineStarts = new LineInfo.fromContent(code).lineStarts;
- fasta.CompilerContext.current.uriToSource[relativizeUri(uri).toString()] =
- new fasta.Source(lineStarts, UTF8.encode(code));
+ List<int> lineStarts = new LineInfo.fromContent(code).lineStarts;
+ fasta.CompilerContext.current.uriToSource[relativizeUri(uri).toString()] =
+ new fasta.Source(lineStarts, UTF8.encode(code));
- var validation = new fasta.ValidatingInstrumentation();
- await validation.loadExpectations(uri);
+ var validation = new fasta.ValidatingInstrumentation();
+ await validation.loadExpectations(uri);
- _addFileAndImports(path, code);
+ _addFileAndImports(path, code);
- AnalysisResult result = await driver.getResult(path);
- result.unit.accept(new _InstrumentationVisitor(validation, uri));
+ AnalysisResult result = await driver.getResult(path);
+ result.unit.accept(new _InstrumentationVisitor(validation, uri));
- validation.finish();
+ validation.finish();
- if (validation.hasProblems) {
- if (fixProblems) {
- validation.fixSource(uri, true);
- return null;
+ if (validation.hasProblems) {
+ if (fixProblems) {
+ validation.fixSource(uri, true);
+ return null;
+ } else {
+ return validation.problemsAsString;
+ }
} else {
- return validation.problemsAsString;
+ return null;
}
- } else {
- return null;
- }
+ });
}
void _addFileAndImports(String path, String code) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698