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

Side by Side Diff: sdk/lib/_internal/pub_generated/test/transformer/cache_test.dart

Issue 559833004: Cache snapshots of (mostly) immutable transformer phases. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 library pub_tests;
2 import 'package:scheduled_test/scheduled_test.dart';
3 import '../descriptor.dart' as d;
4 import '../test_pub.dart';
5 import '../serve/utils.dart';
6 void setUp() {
7 servePackages((builder) {
8 builder.serveRepoPackage('barback');
9 builder.serve("foo", "1.2.3", deps: {
10 'barback': 'any'
11 },
12 contents: [
13 d.dir(
14 "lib",
15 [d.file("transformer.dart", replaceTransformer("Hello", "Goodbye "))])]);
16 builder.serve("bar", "1.2.3", deps: {
17 'barback': 'any'
18 },
19 contents: [
20 d.dir(
21 "lib",
22 [d.file("transformer.dart", replaceTransformer("Goodbye", "See y a"))])]);
23 });
24 d.dir(appPath, [d.pubspec({
25 "name": "myapp",
26 "dependencies": {
27 "foo": "1.2.3",
28 "bar": "1.2.3"
29 },
30 "transformers": ["foo"]
31 }),
32 d.dir("bin", [d.file("myapp.dart", "main() => print('Hello!');")])]).cre ate();
33 pubGet();
34 }
35 main() {
36 initConfig();
37 integration("caches a transformer snapshot", () {
38 setUp();
39 var process = pubRun(args: ['myapp']);
40 process.stdout.expect("Goodbye!");
41 process.shouldExit();
42 d.dir(
43 appPath,
44 [
45 d.dir(
46 ".pub/transformers/release",
47 [
48 d.file("manifest.txt", "0.1.2+3\nfoo"),
49 d.matcherFile("phase1.snapshot", isNot(isEmpty))])]).validat e();
50 process = pubRun(args: ['myapp']);
51 process.stdout.expect("Goodbye!");
52 process.shouldExit();
53 });
54 integration("recaches if the SDK version is out-of-date", () {
55 setUp();
56 d.dir(
57 appPath,
58 [
59 d.dir(
60 ".pub/transformers/release",
61 [
62 d.file("manifest.txt", "0.0.1\nfoo"),
63 d.file("phase1.snapshot", "junk")])]).create();
64 var process = pubRun(args: ['myapp']);
65 process.stdout.expect("Goodbye!");
66 process.shouldExit();
67 d.dir(
68 appPath,
69 [
70 d.dir(
71 ".pub/transformers/release",
72 [
73 d.file("manifest.txt", "0.1.2+3\nfoo"),
74 d.matcherFile("phase1.snapshot", isNot(isEmpty))])]).validat e();
75 process = pubRun(args: ['myapp']);
76 process.stdout.expect("Goodbye!");
77 process.shouldExit();
78 });
79 integration("recaches if the phase changes", () {
80 setUp();
81 var process = pubRun(args: ['myapp']);
82 process.stdout.expect("Goodbye!");
83 process.shouldExit();
84 d.dir(
85 appPath,
86 [
87 d.dir(
88 ".pub/transformers/release",
89 [
90 d.file("manifest.txt", "0.1.2+3\nfoo"),
91 d.matcherFile("phase1.snapshot", isNot(isEmpty))])]).validat e();
92 d.dir(appPath, [d.pubspec({
93 "name": "myapp",
94 "dependencies": {
95 "foo": "1.2.3",
96 "bar": "1.2.3"
97 },
98 "transformers": ["foo", "bar"]
99 }),
100 d.dir("bin", [d.file("myapp.dart", "main() => print('Hello!');")])]).c reate();
101 process = pubRun(args: ['myapp']);
102 process.stdout.expect("See ya!");
103 process.shouldExit();
104 d.dir(
105 appPath,
106 [
107 d.dir(
108 ".pub/transformers/release",
109 [
110 d.file("manifest.txt", "0.1.2+3\nbar,foo"),
111 d.matcherFile("phase1.snapshot", isNot(isEmpty))])]).validat e();
112 });
113 integration("URL-escapes a custom mode", () {
114 setUp();
115 pubServe(args: ["--mode", "weird/custom mode", "bin"]);
116 requestShouldSucceed(
117 "myapp.dart",
118 "main() => print('Goodbye!');",
119 root: 'bin');
120 endPubServe();
121 d.dir(
122 appPath,
123 [
124 d.dir(
125 ".pub/transformers/weird%2Fcustom%20mode",
126 [
127 d.file("manifest.txt", "0.1.2+3\nfoo"),
128 d.matcherFile("phase1.snapshot", isNot(isEmpty))])]).validat e();
129 });
130 solo_integration("removes an unused phase snapshot", () {
131 setUp();
132 var process = pubRun(args: ['myapp']);
133 process.stdout.expect("Goodbye!");
134 process.shouldExit();
135 d.dir(
136 appPath,
137 [
138 d.dir(
139 ".pub/transformers/release",
140 [
141 d.file("manifest.txt", "0.1.2+3\nfoo\nbar"),
142 d.file("phase2.snapshot", "junk")])]).create();
143 process = pubRun(args: ['myapp']);
144 process.stdout.expect("Goodbye!");
145 process.shouldExit();
146 d.dir(
147 appPath,
148 [
149 d.dir(".pub/transformers/release", [d.nothing("phase2.snapshot")])]) .validate();
150 });
151 }
152 String replaceTransformer(String input, String output) {
153 return """
154 import 'dart:async';
155
156 import 'package:barback/barback.dart';
157
158 class ReplaceTransformer extends Transformer {
159 ReplaceTransformer.asPlugin();
160
161 String get allowedExtensions => '.dart';
162
163 Future apply(Transform transform) {
164 return transform.primaryInput.readAsString().then((contents) {
165 transform.addOutput(new Asset.fromString(
166 transform.primaryInput.id,
167 contents.replaceAll("$input", "$output")));
168 });
169 }
170 }
171 """;
172 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698