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

Side by Side Diff: sdk/lib/_internal/pub/test/serve/allows_arbitrary_modes_test.dart

Issue 69043003: Allow user to specify mode for pub build/serve. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Get rid of "--minify" flags. Created 7 years, 1 month 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
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.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 file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library pub_tests; 5 library pub_tests;
6 6
7 import '../descriptor.dart' as d; 7 import '../descriptor.dart' as d;
8 import '../test_pub.dart'; 8 import '../test_pub.dart';
9 import '../serve/utils.dart'; 9 import '../serve/utils.dart';
10 10
11 const TRANSFORMER = """ 11 const TRANSFORMER = """
12 import 'dart:async'; 12 import 'dart:async';
13 13
14 import 'package:barback/barback.dart'; 14 import 'package:barback/barback.dart';
15 import 'package:source_maps/source_maps.dart';
15 16
16 class RewriteTransformer extends Transformer { 17 class ModeTransformer extends Transformer {
17 RewriteTransformer.asPlugin(); 18 final BarbackSettings settings;
19 ModeTransformer.asPlugin(this.settings);
18 20
19 String get allowedExtensions => '.txt'; 21 String get allowedExtensions => '.txt';
20 22
21 Future apply(Transform transform) { 23 Future apply(Transform transform) {
22 return transform.readInputAsString(transform.primaryInput.id) 24 return new Future.value().then((_) {
23 .then((contents) {
24 var id = transform.primaryInput.id.changeExtension(".out"); 25 var id = transform.primaryInput.id.changeExtension(".out");
25 transform.addOutput(new Asset.fromString(id, "\$contents.out")); 26 transform.addOutput(new Asset.fromString(id, settings.mode.toString()));
26 }); 27 });
27 } 28 }
28 } 29 }
29 """; 30 """;
30 31
31 main() { 32 main() {
32 initConfig(); 33 initConfig();
33 integration("a transform can use readInputAsString", () { 34 integration("allows user-defined mode names", () {
34 d.dir(appPath, [ 35 d.dir(appPath, [
35 d.pubspec({ 36 d.pubspec({
36 "name": "myapp", 37 "name": "myapp",
37 "transformers": ["myapp/src/transformer"] 38 "transformers": ["myapp/src/transformer"]
38 }), 39 }),
39 d.dir("lib", [d.dir("src", [ 40 d.dir("lib", [d.dir("src", [
40 d.file("transformer.dart", TRANSFORMER) 41 d.file("transformer.dart", TRANSFORMER)
41 ])]), 42 ])]),
42 d.dir("web", [ 43 d.dir("web", [
43 d.file("foo.txt", "foo") 44 d.file("foo.txt", "foo")
44 ]) 45 ])
45 ]).create(); 46 ]).create();
46 47
47 createLockFile('myapp', pkg: ['barback']); 48 createLockFile('myapp', pkg: ['barback']);
48 49
49 pubServe(); 50 pubServe(args: ["--mode", "depeche"]);
50 requestShouldSucceed("foo.out", "foo.out"); 51 requestShouldSucceed("foo.out", "depeche");
51 endPubServe(); 52 endPubServe();
52 }); 53 });
53 } 54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698