| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 import 'package:scheduled_test/scheduled_test.dart'; | |
| 6 | |
| 7 import '../descriptor.dart' as d; | |
| 8 import '../serve/utils.dart'; | |
| 9 import '../test_pub.dart'; | |
| 10 | |
| 11 main() { | |
| 12 initConfig(); | |
| 13 group("passes environment constants to dart2js", () { | |
| 14 setUp(() { | |
| 15 // Dart2js can take a long time to compile dart code, so we increase the | |
| 16 // timeout to cope with that. | |
| 17 currentSchedule.timeout *= 3; | |
| 18 | |
| 19 d.dir(appPath, [ | |
| 20 d.appPubspec(), | |
| 21 d.dir('web', [ | |
| 22 d.file('file.dart', | |
| 23 'void main() => print(const String.fromEnvironment("name"));') | |
| 24 ]) | |
| 25 ]).create(); | |
| 26 }); | |
| 27 | |
| 28 integration('from "pub build"', () { | |
| 29 schedulePub(args: ["build", "--define", "name=fblthp"], | |
| 30 output: new RegExp(r'Built 1 file to "build".')); | |
| 31 | |
| 32 d.dir(appPath, [ | |
| 33 d.dir('build', [ | |
| 34 d.dir('web', [ | |
| 35 d.matcherFile('file.dart.js', contains('fblthp')), | |
| 36 ]) | |
| 37 ]) | |
| 38 ]).validate(); | |
| 39 }); | |
| 40 | |
| 41 integration('from "pub serve"', () { | |
| 42 pubServe(args: ["--define", "name=fblthp"]); | |
| 43 requestShouldSucceed("file.dart.js", contains("fblthp")); | |
| 44 endPubServe(); | |
| 45 }); | |
| 46 | |
| 47 integration('which takes precedence over the pubspec', () { | |
| 48 d.dir(appPath, [ | |
| 49 d.pubspec({ | |
| 50 "name": "myapp", | |
| 51 "transformers": [ | |
| 52 {"\$dart2js": {"environment": {"name": "slartibartfast"}}} | |
| 53 ] | |
| 54 }) | |
| 55 ]).create(); | |
| 56 | |
| 57 pubServe(args: ["--define", "name=fblthp"]); | |
| 58 requestShouldSucceed("file.dart.js", allOf([ | |
| 59 contains("fblthp"), | |
| 60 isNot(contains("slartibartfast")) | |
| 61 ])); | |
| 62 endPubServe(); | |
| 63 }); | |
| 64 }); | |
| 65 } | |
| OLD | NEW |