OLD | NEW |
(Empty) | |
| 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 |
| 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 '../test_pub.dart'; |
| 9 |
| 10 main() { |
| 11 // This test is a bit shaky. Since dart2js is free to inline things, it's |
| 12 // not precise as to which source libraries will actually be referenced in |
| 13 // the source map. But this tries to use a type from a package and validate |
| 14 // that its source ends up in the source map with a valid URI. |
| 15 integration("Source maps URIs for files in packages are self-contained", () { |
| 16 d.dir("foo", [ |
| 17 d.libPubspec("foo", "0.0.1"), |
| 18 d.dir("lib", [ |
| 19 d.file("foo.dart", |
| 20 """ |
| 21 library foo; |
| 22 foo() { |
| 23 // As of today dart2js will not inline this code. |
| 24 if ('\${new DateTime.now()}' == 'abc') return 1; |
| 25 return 2; |
| 26 } |
| 27 """) |
| 28 ]) |
| 29 ]).create(); |
| 30 |
| 31 d.dir(appPath, [ |
| 32 d.appPubspec({ |
| 33 "foo": {"path": "../foo"} |
| 34 }), |
| 35 d.dir("web", [ |
| 36 d.file("main.dart", |
| 37 """ |
| 38 import 'package:foo/foo.dart'; |
| 39 main() => foo(); |
| 40 """), |
| 41 d.dir("sub", [ |
| 42 d.file("main2.dart", |
| 43 """ |
| 44 import 'package:foo/foo.dart'; |
| 45 main() => foo(); |
| 46 """), |
| 47 ]) |
| 48 ]) |
| 49 ]).create(); |
| 50 |
| 51 |
| 52 pubGet(); |
| 53 schedulePub(args: ["build", "--mode", "debug"], |
| 54 output: new RegExp(r'Built \d+ files to "build".'), |
| 55 exitCode: 0); |
| 56 |
| 57 d.dir(appPath, [ |
| 58 d.dir("build", [ |
| 59 d.dir("web", [ |
| 60 d.matcherFile("main.dart.js.map", |
| 61 // Note: we include the quotes to ensure this is the full URL path |
| 62 // in the source map |
| 63 contains(r'"packages/foo/foo.dart"')), |
| 64 d.dir("sub", [ |
| 65 d.matcherFile("main2.dart.js.map", |
| 66 contains(r'"../packages/foo/foo.dart"')) |
| 67 ]), |
| 68 d.dir("packages", [ |
| 69 d.dir(r"foo", [ |
| 70 d.matcherFile("foo.dart", |
| 71 contains("foo() {")) |
| 72 ]) |
| 73 ]) |
| 74 ]) |
| 75 ]) |
| 76 ]).validate(); |
| 77 }); |
| 78 } |
OLD | NEW |