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

Side by Side Diff: pkg/kernel/test/closures/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 'package:front_end/physical_file_system.dart';
9 import 'package:testing/testing.dart' 10 import 'package:testing/testing.dart'
10 show Chain, ChainContext, Result, Step, TestDescription, runMe; 11 show Chain, ChainContext, Result, Step, TestDescription, runMe;
11 12
12 import 'package:kernel/ast.dart' show Program; 13 import 'package:kernel/ast.dart' show Program;
13 14
14 import 'package:kernel/transformations/closure_conversion.dart' 15 import 'package:kernel/transformations/closure_conversion.dart'
15 as closure_conversion; 16 as closure_conversion;
16 17
17 import 'package:front_end/src/fasta/testing/kernel_chain.dart' 18 import 'package:front_end/src/fasta/testing/kernel_chain.dart'
18 show Print, MatchExpectation, WriteDill, ReadDill, Verify; 19 show Print, MatchExpectation, WriteDill, ReadDill, Verify;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 Future<Program> loadPlatform() async { 61 Future<Program> loadPlatform() async {
61 Uri sdk = await computePatchedSdk(); 62 Uri sdk = await computePatchedSdk();
62 return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath()); 63 return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath());
63 } 64 }
64 65
65 static Future<ClosureConversionContext> create( 66 static Future<ClosureConversionContext> create(
66 Chain suite, Map<String, String> environment) async { 67 Chain suite, Map<String, String> environment) async {
67 Uri packages = Uri.base.resolve(".packages"); 68 Uri packages = Uri.base.resolve(".packages");
68 bool strongMode = environment.containsKey(STRONG_MODE); 69 bool strongMode = environment.containsKey(STRONG_MODE);
69 bool updateExpectations = environment["updateExpectations"] == "true"; 70 bool updateExpectations = environment["updateExpectations"] == "true";
70 TranslateUri uriTranslator = await TranslateUri.parse(packages); 71 TranslateUri uriTranslator =
72 await TranslateUri.parse(PhysicalFileSystem.instance, packages);
71 return new ClosureConversionContext( 73 return new ClosureConversionContext(
72 strongMode, updateExpectations, uriTranslator); 74 strongMode, updateExpectations, uriTranslator);
73 } 75 }
74 } 76 }
75 77
76 Future<ClosureConversionContext> createContext( 78 Future<ClosureConversionContext> createContext(
77 Chain suite, Map<String, String> environment) async { 79 Chain suite, Map<String, String> environment) async {
78 environment["updateExpectations"] = 80 environment["updateExpectations"] =
79 const String.fromEnvironment("updateExpectations"); 81 const String.fromEnvironment("updateExpectations");
80 return ClosureConversionContext.create(suite, environment); 82 return ClosureConversionContext.create(suite, environment);
81 } 83 }
82 84
83 class FastaCompile 85 class FastaCompile
84 extends Step<TestDescription, Program, ClosureConversionContext> { 86 extends Step<TestDescription, Program, ClosureConversionContext> {
85 const FastaCompile(); 87 const FastaCompile();
86 88
87 String get name => "fasta compilation"; 89 String get name => "fasta compilation";
88 90
89 Future<Result<Program>> run( 91 Future<Result<Program>> run(
90 TestDescription description, ClosureConversionContext context) async { 92 TestDescription description, ClosureConversionContext context) async {
91 Program platform = await context.loadPlatform(); 93 Program platform = await context.loadPlatform();
92 Ticker ticker = new Ticker(); 94 Ticker ticker = new Ticker();
93 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator); 95 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator);
94 dillTarget.loader 96 dillTarget.loader
95 ..input = Uri.parse("org.dartlang:platform") // Make up a name. 97 ..input = Uri.parse("org.dartlang:platform") // Make up a name.
96 ..setProgram(platform); 98 ..setProgram(platform);
97 KernelTarget sourceTarget = 99 KernelTarget sourceTarget = new KernelTarget(PhysicalFileSystem.instance,
98 new KernelTarget(dillTarget, context.uriTranslator, context.strongMode); 100 dillTarget, context.uriTranslator, context.strongMode);
99 101
100 Program p; 102 Program p;
101 try { 103 try {
102 sourceTarget.read(description.uri); 104 sourceTarget.read(description.uri);
103 await dillTarget.writeOutline(null); 105 await dillTarget.writeOutline(null);
104 await sourceTarget.writeOutline(null); 106 await sourceTarget.writeOutline(null);
105 p = await sourceTarget.writeProgram(null); 107 p = await sourceTarget.writeProgram(null);
106 } on InputError catch (e, s) { 108 } on InputError catch (e, s) {
107 return fail(null, e.error, s); 109 return fail(null, e.error, s);
108 } 110 }
(...skipping 12 matching lines...) Expand all
121 try { 123 try {
122 program = closure_conversion.transformProgram(program); 124 program = closure_conversion.transformProgram(program);
123 return pass(program); 125 return pass(program);
124 } catch (e, s) { 126 } catch (e, s) {
125 return crash(e, s); 127 return crash(e, s);
126 } 128 }
127 } 129 }
128 } 130 }
129 131
130 main(List<String> arguments) => runMe(arguments, createContext, "testing.json"); 132 main(List<String> arguments) => runMe(arguments, createContext, "testing.json");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698