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

Side by Side Diff: pkg/kernel/test/interpreter/suite.dart

Issue 2865843002: Use FileSystem to read files in SourceLoader and TranslateUri. (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 library test.kernel.closures.suite; 5 library test.kernel.closures.suite;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:io' show File; 9 import 'dart:io' show File;
10 10
11 import 'package:front_end/physical_file_system.dart';
11 import 'package:testing/testing.dart' 12 import 'package:testing/testing.dart'
12 show Chain, ChainContext, Result, Step, TestDescription, runMe; 13 show Chain, ChainContext, Result, Step, TestDescription, runMe;
13 14
14 import 'package:kernel/ast.dart' show Program, Library; 15 import 'package:kernel/ast.dart' show Program, Library;
15 16
16 import 'package:front_end/src/fasta/testing/kernel_chain.dart' show runDiff; 17 import 'package:front_end/src/fasta/testing/kernel_chain.dart' show runDiff;
17 18
18 import 'package:front_end/src/fasta/ticker.dart' show Ticker; 19 import 'package:front_end/src/fasta/ticker.dart' show Ticker;
19 20
20 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; 21 import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 53
53 Future<Program> loadPlatform() async { 54 Future<Program> loadPlatform() async {
54 Uri sdk = await computePatchedSdk(); 55 Uri sdk = await computePatchedSdk();
55 return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath()); 56 return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath());
56 } 57 }
57 58
58 static Future<InterpreterContext> create( 59 static Future<InterpreterContext> create(
59 Chain suite, Map<String, String> environment) async { 60 Chain suite, Map<String, String> environment) async {
60 Uri packages = Uri.base.resolve(".packages"); 61 Uri packages = Uri.base.resolve(".packages");
61 bool strongMode = environment.containsKey(STRONG_MODE); 62 bool strongMode = environment.containsKey(STRONG_MODE);
62 TranslateUri uriTranslator = await TranslateUri.parse(packages); 63 TranslateUri uriTranslator =
64 await TranslateUri.parse(PhysicalFileSystem.instance, packages);
63 return new InterpreterContext(strongMode, uriTranslator); 65 return new InterpreterContext(strongMode, uriTranslator);
64 } 66 }
65 } 67 }
66 68
67 class FastaCompile extends Step<TestDescription, Program, InterpreterContext> { 69 class FastaCompile extends Step<TestDescription, Program, InterpreterContext> {
68 const FastaCompile(); 70 const FastaCompile();
69 71
70 String get name => "fasta compile"; 72 String get name => "fasta compile";
71 73
72 Future<Result<Program>> run( 74 Future<Result<Program>> run(
73 TestDescription description, InterpreterContext context) async { 75 TestDescription description, InterpreterContext context) async {
74 Program platform = await context.loadPlatform(); 76 Program platform = await context.loadPlatform();
75 Ticker ticker = new Ticker(); 77 Ticker ticker = new Ticker();
76 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator); 78 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator);
77 dillTarget.loader 79 dillTarget.loader
78 ..input = Uri.parse("org.dartlang:platform") // Make up a name. 80 ..input = Uri.parse("org.dartlang:platform") // Make up a name.
79 ..setProgram(platform); 81 ..setProgram(platform);
80 KernelTarget sourceTarget = 82 KernelTarget sourceTarget = new KernelTarget(PhysicalFileSystem.instance,
81 new KernelTarget(dillTarget, context.uriTranslator, context.strongMode); 83 dillTarget, context.uriTranslator, context.strongMode);
82 84
83 Program p; 85 Program p;
84 try { 86 try {
85 sourceTarget.read(description.uri); 87 sourceTarget.read(description.uri);
86 await dillTarget.writeOutline(null); 88 await dillTarget.writeOutline(null);
87 await sourceTarget.writeOutline(null); 89 await sourceTarget.writeOutline(null);
88 p = await sourceTarget.writeProgram(null); 90 p = await sourceTarget.writeProgram(null);
89 } on InputError catch (e, s) { 91 } on InputError catch (e, s) {
90 return fail(null, e.error, s); 92 return fail(null, e.error, s);
91 } 93 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 final Uri uri; 149 final Uri uri;
148 150
149 /// Evaluated program log. 151 /// Evaluated program log.
150 final String log; 152 final String log;
151 153
152 EvaluationLog(this.uri, this.log); 154 EvaluationLog(this.uri, this.log);
153 } 155 }
154 156
155 main(List<String> arguments) => 157 main(List<String> arguments) =>
156 runMe(arguments, InterpreterContext.create, "testing.json"); 158 runMe(arguments, InterpreterContext.create, "testing.json");
OLDNEW
« pkg/front_end/lib/src/fasta/source/source_loader.dart ('K') | « pkg/kernel/test/closures/suite.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698