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

Side by Side Diff: test/kernel/kernel_test.dart

Issue 2194163002: Change default binary file extension to .dill (Closed) Base URL: git@github.com:dart-lang/rasta.git@private_names
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « submodules.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 rasta.dart2js_test; 5 library rasta.dart2js_test;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Future, 8 Future,
9 Stream; 9 Stream;
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 import 'package:rasta/src/options.dart' show 44 import 'package:rasta/src/options.dart' show
45 Options; 45 Options;
46 46
47 const bool generateExpectations = 47 const bool generateExpectations =
48 const bool.fromEnvironment("generateExpectations"); 48 const bool.fromEnvironment("generateExpectations");
49 49
50 Future<Null> addRegressions(Map<Uri, Uri> tests, Uri temp) async { 50 Future<Null> addRegressions(Map<Uri, Uri> tests, Uri temp) async {
51 Stream<TestDescription> regressions = listTests( 51 Stream<TestDescription> regressions = listTests(
52 <Uri>[Uri.base.resolve("test/kernel/regression/")], pattern: ".dart"); 52 <Uri>[Uri.base.resolve("test/kernel/regression/")], pattern: ".dart");
53 await for (TestDescription regression in regressions) { 53 await for (TestDescription regression in regressions) {
54 tests[regression.uri] = temp.resolve("${regression.shortName}.bart"); 54 tests[regression.uri] = temp.resolve("${regression.shortName}.dill");
kasperl 2016/08/02 06:26:12 It's almost like you should put the extension in a
ahe 2016/08/02 11:36:47 Done. I'm not sure its nicer.
55 } 55 }
56 } 56 }
57 57
58 Future<Null> main() async { 58 Future<Null> main() async {
59 Stopwatch wallClock = new Stopwatch()..start(); 59 Stopwatch wallClock = new Stopwatch()..start();
60 Rastask task = await Rastask.create( 60 Rastask task = await Rastask.create(
61 wallClock, <String>["--library", "${Platform.script}"]); 61 wallClock, <String>["--library", "${Platform.script}"]);
62 await task.measureSubtask("runTests", () => runTests(task)); 62 await task.measureSubtask("runTests", () => runTests(task));
63 } 63 }
64 64
65 Future<Null> runTests(Rastask task) async { 65 Future<Null> runTests(Rastask task) async {
66 await task.setup(); 66 await task.setup();
67 67
68 // When running via `testa.dart`, [Platform.script] is located in a temporary 68 // When running via `testa.dart`, [Platform.script] is located in a temporary
69 // directory. 69 // directory.
70 Uri temp = Platform.script; 70 Uri temp = Platform.script;
71 Map<Uri, Uri> tests = <Uri, Uri>{ 71 Map<Uri, Uri> tests = <Uri, Uri>{
72 Uri.parse("dart:core"): temp.resolve("core.bart"), 72 Uri.parse("dart:core"): temp.resolve("core.dill"),
73 73
74 Uri.parse("package:compiler/src/dart2js.dart"): 74 Uri.parse("package:compiler/src/dart2js.dart"):
75 temp.resolve("dart2js.bart"), 75 temp.resolve("dart2js.dill"),
76 }; 76 };
77 77
78 await addRegressions(tests, temp); 78 await addRegressions(tests, temp);
79 79
80 Uri statusFile = Uri.base.resolve("test/rasta.status"); 80 Uri statusFile = Uri.base.resolve("test/rasta.status");
81 TestExpectations expectations = 81 TestExpectations expectations =
82 await ReadTestExpectations(<String>[statusFile.toFilePath()], {}); 82 await ReadTestExpectations(<String>[statusFile.toFilePath()], {});
83 83
84 List<Uri> fails = <Uri>[]; 84 List<Uri> fails = <Uri>[];
85 85
86 for (Uri source in tests.keys) { 86 for (Uri source in tests.keys) {
87 assert(task.kernel.isInternalStateConsistent); 87 assert(task.kernel.isInternalStateConsistent);
88 88
89 bool isRegression = source.path.contains("/regression/"); 89 bool isRegression = source.path.contains("/regression/");
90 90
91 print("Rastarizing $source"); 91 print("Rastarizing $source");
92 Uri bart = tests[source]; 92 Uri dill = tests[source];
93 File output = new File.fromUri(bart); 93 File output = new File.fromUri(dill);
94 await output.parent.create(recursive: true); 94 await output.parent.create(recursive: true);
95 95
96 Options options = new Options( 96 Options options = new Options(
97 source, bart, dependenciesFile: null, 97 source, dill, dependenciesFile: null,
98 generateLibrary: isRegression ? isRegression : null, 98 generateLibrary: isRegression ? isRegression : null,
99 isVerbose: true, isBatch: false, pattern: null); 99 isVerbose: true, isBatch: false, pattern: null);
100 100
101 ir.TreeNode node; 101 ir.TreeNode node;
102 Expectation outcome = Expectation.PASS; 102 Expectation outcome = Expectation.PASS;
103 var error; 103 var error;
104 StackTrace trace; 104 StackTrace trace;
105 try { 105 try {
106 node = await task.runOne(options); 106 node = await task.runOne(options);
107 } catch (e, t) { 107 } catch (e, t) {
108 outcome = Expectation.CRASH; 108 outcome = Expectation.CRASH;
109 task.kernel.recoverFromCrash(); 109 task.kernel.recoverFromCrash();
110 error = e; 110 error = e;
111 trace = t; 111 trace = t;
112 } 112 }
113 113
114 if (isRegression && outcome == Expectation.PASS) { 114 if (isRegression && outcome == Expectation.PASS) {
115 outcome = await checkAgainstExpectations(node); 115 outcome = await checkAgainstExpectations(node);
116 } 116 }
117 if (outcome == Expectation.PASS) { 117 if (outcome == Expectation.PASS) {
118 outcome = checkRoundTrip(bart); 118 outcome = checkRoundTrip(dill);
119 } 119 }
120 120
121 Set<Expectation> expectedOutcomes = isRegression 121 Set<Expectation> expectedOutcomes = isRegression
122 ? expectations.expectations( 122 ? expectations.expectations(
123 relativize(statusFile.resolve("."), source, false)) 123 relativize(statusFile.resolve("."), source, false))
124 : <Expectation>[Expectation.PASS].toSet(); 124 : <Expectation>[Expectation.PASS].toSet();
125 125
126 if (!expectedOutcomes.contains(outcome)) { 126 if (!expectedOutcomes.contains(outcome)) {
127 print("$source: '$outcome' isn't one of '$expectedOutcomes'."); 127 print("$source: '$outcome' isn't one of '$expectedOutcomes'.");
128 if (error != null) print(error); 128 if (error != null) print(error);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 ir.TreeNode programOrLibrary = 181 ir.TreeNode programOrLibrary =
182 new BinaryLoader(repository).loadProgramOrLibrary("$uri"); 182 new BinaryLoader(repository).loadProgramOrLibrary("$uri");
183 Printer printer = new Printer(new StringBuffer()); 183 Printer printer = new Printer(new StringBuffer());
184 if (programOrLibrary is ir.Program) { 184 if (programOrLibrary is ir.Program) {
185 printer.writeProgramFile(programOrLibrary); 185 printer.writeProgramFile(programOrLibrary);
186 } else { 186 } else {
187 printer.writeLibraryFile(programOrLibrary); 187 printer.writeLibraryFile(programOrLibrary);
188 } 188 }
189 return Expectation.PASS; 189 return Expectation.PASS;
190 } 190 }
OLDNEW
« no previous file with comments | « submodules.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698