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

Side by Side Diff: lib/testing/rasta_chain.dart

Issue 2408333006: Add support for not generating a .dill file. (Closed)
Patch Set: Created 4 years, 2 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 | « lib/src/rastask.dart ('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.testing.rasta_chain; 5 library rasta.testing.rasta_chain;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 Future; 8 Future;
9 9
10 import 'dart:io' show 10 import 'dart:io' show
11 File, 11 File,
12 Platform; 12 Platform;
13 13
14 import 'package:kernel/ast.dart' show 14 import 'package:kernel/ast.dart' show
15 Program; 15 Program;
16 16
17 import 'package:kernel/repository.dart' show
18 Repository;
19
20 import 'package:kernel/binary/loader.dart' show
21 BinaryLoader;
22
23 import 'package:testing/testing.dart' show 17 import 'package:testing/testing.dart' show
24 ChainContext, 18 ChainContext,
25 Result, 19 Result,
26 Step, 20 Step,
27 TestDescription; 21 TestDescription;
28 22
29 import 'package:rasta/src/rastask.dart' show 23 import 'package:rasta/src/rastask.dart' show
30 Rastask; 24 Rastask;
31 25
32 import 'package:rasta/src/options.dart' show 26 import 'package:rasta/src/options.dart' show
(...skipping 15 matching lines...) Expand all
48 } 42 }
49 43
50 abstract class RastaContext extends ChainContext { 44 abstract class RastaContext extends ChainContext {
51 Rastask get task; 45 Rastask get task;
52 Uri get temp; 46 Uri get temp;
53 } 47 }
54 48
55 class RastaStep extends Step<TestDescription, Program, RastaContext> { 49 class RastaStep extends Step<TestDescription, Program, RastaContext> {
56 final String prefix; 50 final String prefix;
57 51
58 /// When true, return a copy of the program (by loading it from serialized 52 const RastaStep(this.prefix);
59 /// .dill file).
60 final bool reload;
61
62 const RastaStep(this.prefix, {this.reload: false});
63 53
64 String get name => "rasta"; 54 String get name => "rasta";
65 55
66 Future<Result<Program>> run( 56 Future<Result<Program>> run(
67 TestDescription description, RastaContext context) async { 57 TestDescription description, RastaContext context) async {
68 Uri source = description.uri; 58 Uri source = description.uri;
69 Rastask task = context.task; 59 Rastask task = context.task;
70 60
71 assert(task.kernel.isInternalStateConsistent); 61 assert(task.kernel.isInternalStateConsistent);
72 62
73 print("Rastarizing $source"); 63 print("Rastarizing $source");
74 Uri dill = context.temp.resolve( 64 Uri dill = context.temp.resolve(
75 "$prefix/${description.shortName}$kernelExtension"); 65 "$prefix/${description.shortName}$kernelExtension");
76 66
77 File output = new File.fromUri(dill); 67 File output = new File.fromUri(dill);
78 await output.parent.create(recursive: true); 68 await output.parent.create(recursive: true);
79 69
80 Options options = new Options( 70 Options options = new Options(
81 source, dill, dependenciesFile: null, 71 source, dill, dependenciesFile: null,
82 generateLibrary: false, 72 generateLibrary: false,
83 isVerbose: true, isBatch: false, pattern: null); 73 isVerbose: true, isBatch: false, pattern: null,
74 noOutput: task.globalOptions.noOutput);
84 75
85 Program program;
86 try { 76 try {
87 program = await task.runOne(options); 77 return pass(await task.runOne(options));
88 } catch (e, t) { 78 } catch (e, t) {
89 task.kernel.recoverFromCrash(); 79 task.kernel.recoverFromCrash();
90 return crash(e, t); 80 return crash(e, t);
91 } 81 }
92
93 if (reload) {
94 // TODO(ahe): We need to load the serialized form as we otherwise
95 // attempt to modify an unmodifiable list.
96 Repository repository = new Repository();
97 program = new BinaryLoader(repository).loadProgram(dill.toFilePath());
98 }
99
100 return pass(program);
101 } 82 }
102 } 83 }
OLDNEW
« no previous file with comments | « lib/src/rastask.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698