| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.testing.suite; | 5 library fasta.testing.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 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 final ExpectationSet expectationSet = | 86 final ExpectationSet expectationSet = |
| 87 new ExpectationSet.fromJsonList(JSON.decode(EXPECTATIONS)); | 87 new ExpectationSet.fromJsonList(JSON.decode(EXPECTATIONS)); |
| 88 | 88 |
| 89 Future<Program> platform; | 89 Future<Program> platform; |
| 90 | 90 |
| 91 FastaContext( | 91 FastaContext( |
| 92 this.vm, | 92 this.vm, |
| 93 bool strongMode, | 93 bool strongMode, |
| 94 bool updateExpectations, | 94 bool updateExpectations, |
| 95 bool updateComments, | 95 bool updateComments, |
| 96 bool skipVm, |
| 96 this.uriTranslator, | 97 this.uriTranslator, |
| 97 bool fullCompile, | 98 bool fullCompile, |
| 98 AstKind astKind) | 99 AstKind astKind) |
| 99 : steps = <Step>[ | 100 : steps = <Step>[ |
| 100 new Outline(fullCompile, astKind, strongMode, | 101 new Outline(fullCompile, astKind, strongMode, |
| 101 updateComments: updateComments), | 102 updateComments: updateComments), |
| 102 const Print(), | 103 const Print(), |
| 103 new Verify(fullCompile), | 104 new Verify(fullCompile), |
| 104 new MatchExpectation( | 105 new MatchExpectation( |
| 105 fullCompile | 106 fullCompile |
| 106 ? ".${shortenAstKindName(astKind, strongMode)}.expect" | 107 ? ".${shortenAstKindName(astKind, strongMode)}.expect" |
| 107 : ".outline.expect", | 108 : ".outline.expect", |
| 108 updateExpectations: updateExpectations) | 109 updateExpectations: updateExpectations) |
| 109 ] { | 110 ] { |
| 110 if (fullCompile) { | 111 if (fullCompile && !skipVm) { |
| 111 steps.add(const WriteDill()); | 112 steps.add(const WriteDill()); |
| 112 steps.add(const Run()); | 113 steps.add(const Run()); |
| 113 } | 114 } |
| 114 } | 115 } |
| 115 | 116 |
| 116 Future<Program> loadPlatform() { | 117 Future<Program> loadPlatform() { |
| 117 return platform ??= new Future<Program>(() async { | 118 return platform ??= new Future<Program>(() async { |
| 118 Uri sdk = await computePatchedSdk(); | 119 Uri sdk = await computePatchedSdk(); |
| 119 return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath()); | 120 return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath()); |
| 120 }); | 121 }); |
| 121 } | 122 } |
| 122 | 123 |
| 123 static Future<FastaContext> create( | 124 static Future<FastaContext> create( |
| 124 Chain suite, Map<String, String> environment) async { | 125 Chain suite, Map<String, String> environment) async { |
| 125 Uri sdk = await computePatchedSdk(); | 126 Uri sdk = await computePatchedSdk(); |
| 126 Uri vm = computeDartVm(sdk); | 127 Uri vm = computeDartVm(sdk); |
| 127 Uri packages = Uri.base.resolve(".packages"); | 128 Uri packages = Uri.base.resolve(".packages"); |
| 128 TranslateUri uriTranslator = | 129 TranslateUri uriTranslator = |
| 129 await TranslateUri.parse(PhysicalFileSystem.instance, packages); | 130 await TranslateUri.parse(PhysicalFileSystem.instance, packages); |
| 130 bool strongMode = environment.containsKey(STRONG_MODE); | 131 bool strongMode = environment.containsKey(STRONG_MODE); |
| 131 bool updateExpectations = environment["updateExpectations"] == "true"; | 132 bool updateExpectations = environment["updateExpectations"] == "true"; |
| 132 bool updateComments = environment["updateComments"] == "true"; | 133 bool updateComments = environment["updateComments"] == "true"; |
| 134 bool skipVm = environment["skipVm"] == "true"; |
| 133 String astKindString = environment[AST_KIND_INDEX]; | 135 String astKindString = environment[AST_KIND_INDEX]; |
| 134 AstKind astKind = | 136 AstKind astKind = |
| 135 astKindString == null ? null : AstKind.values[int.parse(astKindString)]; | 137 astKindString == null ? null : AstKind.values[int.parse(astKindString)]; |
| 136 return new FastaContext(vm, strongMode, updateExpectations, updateComments, | 138 return new FastaContext( |
| 137 uriTranslator, environment.containsKey(ENABLE_FULL_COMPILE), astKind); | 139 vm, |
| 140 strongMode, |
| 141 updateExpectations, |
| 142 updateComments, |
| 143 skipVm, |
| 144 uriTranslator, |
| 145 environment.containsKey(ENABLE_FULL_COMPILE), |
| 146 astKind); |
| 138 } | 147 } |
| 139 } | 148 } |
| 140 | 149 |
| 141 class Run extends Step<Uri, int, FastaContext> { | 150 class Run extends Step<Uri, int, FastaContext> { |
| 142 const Run(); | 151 const Run(); |
| 143 | 152 |
| 144 String get name => "run"; | 153 String get name => "run"; |
| 145 | 154 |
| 146 bool get isAsync => true; | 155 bool get isAsync => true; |
| 147 | 156 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 return fail(null, instrumentation.problemsAsString); | 222 return fail(null, instrumentation.problemsAsString); |
| 214 } | 223 } |
| 215 } | 224 } |
| 216 } | 225 } |
| 217 } on InputError catch (e, s) { | 226 } on InputError catch (e, s) { |
| 218 return fail(null, e.error, s); | 227 return fail(null, e.error, s); |
| 219 } | 228 } |
| 220 return pass(p); | 229 return pass(p); |
| 221 } | 230 } |
| 222 } | 231 } |
| OLD | NEW |