Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS d.file | 1 // Copyright (c) 2015, 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 d.file. | 3 // BSD-style license that can be found in the LICENSE d.file. |
| 4 | 4 |
| 5 import 'descriptor.dart' as d; | 5 import 'descriptor.dart' as d; |
| 6 import 'test_pub.dart'; | 6 import 'test_pub.dart'; |
| 7 | 7 |
| 8 main() { | 8 main() { |
| 9 forBothPubGetAndUpgrade((command) { | 9 forBothPubGetAndUpgrade((command) { |
| 10 integration('.packages file is created', () { | 10 integration('.packages file is created', () { |
| 11 servePackages((builder) { | 11 servePackages((builder) { |
| 12 builder.serve("foo", "1.2.3", | 12 builder.serve("foo", "1.2.3", |
| 13 deps: {'baz': '2.2.2'}, contents: [d.dir("lib", [])]); | 13 deps: {'baz': '2.2.2'}, contents: [d.dir("lib", [])]); |
| 14 builder.serve("bar", "3.2.1", contents: [d.dir("lib", [])]); | 14 builder.serve("bar", "3.2.1", contents: [d.dir("lib", [])]); |
| 15 builder.serve("baz", "2.2.2", | 15 builder.serve("baz", "2.2.2", |
| 16 deps: {"bar": "3.2.1"}, contents: [d.dir("lib", [])]); | 16 deps: {"bar": "3.2.1"}, contents: [d.dir("lib", [])]); |
| 17 }); | 17 }); |
| 18 | 18 |
| 19 d.appDir({"foo": "1.2.3"}).create(); | 19 d.dir(appPath, [ |
| 20 d.appPubspec({"foo": "1.2.3"}), | |
| 21 d.dir('lib') | |
| 22 ]).create(); | |
| 20 | 23 |
| 21 pubCommand(command); | 24 pubCommand(command); |
| 22 | 25 |
| 23 d.dir(appPath, [d.packagesFile({ | 26 d.dir(appPath, [d.packagesFile({ |
| 24 "foo": "1.2.3", "bar": "3.2.1", "baz": "2.2.2", "myapp": "0.0.0"})]) | 27 "foo": "1.2.3", "bar": "3.2.1", "baz": "2.2.2", "myapp": "."})]) |
| 25 .validate(); | 28 .validate(); |
| 26 }); | 29 }); |
| 27 | 30 |
| 28 integration('.packages file is overwritten', () { | 31 integration('.packages file is overwritten', () { |
| 29 servePackages((builder) { | 32 servePackages((builder) { |
| 30 builder.serve("foo", "1.2.3", | 33 builder.serve("foo", "1.2.3", |
| 31 deps: {'baz': '2.2.2'}, contents: [d.dir("lib", [])]); | 34 deps: {'baz': '2.2.2'}, contents: [d.dir("lib", [])]); |
| 32 builder.serve("bar", "3.2.1", contents: [d.dir("lib", [])]); | 35 builder.serve("bar", "3.2.1", contents: [d.dir("lib", [])]); |
| 33 builder.serve("baz", "2.2.2", | 36 builder.serve("baz", "2.2.2", |
| 34 deps: {"bar": "3.2.1"}, contents: [d.dir("lib", [])]); | 37 deps: {"bar": "3.2.1"}, contents: [d.dir("lib", [])]); |
| 35 }); | 38 }); |
| 36 | 39 |
| 37 d.appDir({"foo": "1.2.3"}).create(); | 40 d.dir(appPath, [ |
| 41 d.appPubspec({"foo": "1.2.3"}), | |
| 42 d.dir('lib') | |
| 43 ]).create(); | |
| 38 | 44 |
| 39 var oldFile = d.dir(appPath, [d.packagesFile({"notFoo": "9.9.9"})]); | 45 var oldFile = d.dir(appPath, [d.packagesFile({"notFoo": "9.9.9"})]); |
| 40 oldFile.create(); | 46 oldFile.create(); |
| 41 oldFile.validate(); // Sanity-check that file was created correctly. | 47 oldFile.validate(); // Sanity-check that file was created correctly. |
| 42 | 48 |
| 43 pubCommand(command); | 49 pubCommand(command); |
| 44 | 50 |
| 45 d.dir(appPath, [d.packagesFile({ | 51 d.dir(appPath, [d.packagesFile({ |
| 46 "foo": "1.2.3", "bar": "3.2.1", "baz": "2.2.2", "myapp": "0.0.0"})]) | 52 "foo": "1.2.3", "bar": "3.2.1", "baz": "2.2.2", "myapp": "."})]) |
| 47 .validate(); | 53 .validate(); |
| 48 }); | 54 }); |
| 49 | 55 |
| 50 integration('.packages file is not created if pub command fails', () { | 56 integration('.packages file is not created if pub command fails', () { |
| 51 d.appDir({"foo": "1.2.3"}).create(); | 57 d.dir(appPath, [ |
| 58 d.appPubspec({"foo": "1.2.3"}), | |
| 59 d.dir('lib') | |
| 60 ]).create(); | |
| 52 | 61 |
| 53 pubCommand(command, args: ['--offline'], | 62 pubCommand(command, args: ['--offline'], |
| 54 error: "Could not find package foo in cache.\n"); | 63 error: "Could not find package foo in cache.\n"); |
| 55 | 64 |
| 56 d.dir(appPath, [d.nothing('.packages')]).validate(); | 65 d.dir(appPath, [d.nothing('.packages')]).validate(); |
| 57 }); | 66 }); |
| 58 | 67 |
| 59 integration('.packages file has relative path to path dependency', () { | 68 integration('.packages file has relative path to path dependency', () { |
| 60 servePackages((builder) { | 69 servePackages((builder) { |
| 61 builder.serve("foo", "1.2.3", | 70 builder.serve("foo", "1.2.3", |
| 62 deps: {'baz': 'any'}, contents: [d.dir("lib", [])]); | 71 deps: {'baz': 'any'}, contents: [d.dir("lib", [])]); |
| 63 builder.serve("baz", "9.9.9", | 72 builder.serve("baz", "9.9.9", |
| 64 deps: {}, contents: [d.dir("lib", [])]); | 73 deps: {}, contents: [d.dir("lib", [])]); |
| 65 }); | 74 }); |
| 66 | 75 |
| 67 d.dir("local_baz", [ | 76 d.dir("local_baz", [ |
| 68 d.libDir("baz", 'baz 3.2.1'), | 77 d.libDir("baz", 'baz 3.2.1'), |
| 69 d.libPubspec("baz", "3.2.1") | 78 d.libPubspec("baz", "3.2.1") |
| 70 ]).create(); | 79 ]).create(); |
| 71 | 80 |
| 72 d.dir(appPath, [ | 81 d.dir(appPath, [ |
| 73 d.pubspec({ | 82 d.pubspec({ |
| 74 "name": "myapp", | 83 "name": "myapp", |
| 75 "dependencies": {}, | 84 "dependencies": {}, |
| 76 "dependency_overrides": { | 85 "dependency_overrides": { |
| 77 "baz": {"path": "../local_baz"}, | 86 "baz": {"path": "../local_baz"}, |
| 78 } | 87 } |
| 79 }) | 88 }), |
| 89 d.dir('lib') | |
| 80 ]).create(); | 90 ]).create(); |
| 81 | 91 |
| 82 pubCommand(command); | 92 pubCommand(command); |
| 83 | 93 |
| 84 d.dir(appPath, [d.packagesFile({"myapp": "0.0.0", | 94 d.dir(appPath, [d.packagesFile({"myapp": ".", |
| 85 "baz": "../local_baz"})]).validate(); | 95 "baz": "../local_baz"})]).validate(); |
|
Bob Nystrom
2015/07/09 19:42:56
Format this.
nweiz
2015/07/09 19:46:05
Done.
| |
| 86 }); | 96 }); |
| 87 | |
| 88 }); | 97 }); |
| 89 } | 98 } |
| OLD | NEW |