Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS 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('dart:io'); | 7 #import('dart:io'); |
| 8 | 8 |
| 9 #import('test_pub.dart'); | 9 #import('test_pub.dart'); |
| 10 #import('../../../lib/unittest/unittest.dart'); | 10 #import('../../../lib/unittest/unittest.dart'); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 test('adds a dependent package', () { | 85 test('adds a dependent package', () { |
| 86 dir(sdkPath, [ | 86 dir(sdkPath, [ |
| 87 dir('lib', [ | 87 dir('lib', [ |
| 88 dir('foo', [ | 88 dir('foo', [ |
| 89 file('foo.dart', 'main() => "foo";') | 89 file('foo.dart', 'main() => "foo";') |
| 90 ]) | 90 ]) |
| 91 ]) | 91 ]) |
| 92 ]).scheduleCreate(); | 92 ]).scheduleCreate(); |
| 93 | 93 |
| 94 dir(appPath, [ | 94 dir(appPath, [ |
| 95 file('pubspec', 'dependencies:\n- foo') | 95 file('pubspec', 'dependencies:\n foo:') |
| 96 ]).scheduleCreate(); | 96 ]).scheduleCreate(); |
| 97 | 97 |
| 98 dir(packagesPath, [ | 98 dir(packagesPath, [ |
| 99 dir('foo', [ | 99 dir('foo', [ |
| 100 file('foo.dart', 'main() => "foo";') | 100 file('foo.dart', 'main() => "foo";') |
| 101 ]) | 101 ]) |
| 102 ]).scheduleValidate(); | 102 ]).scheduleValidate(); |
| 103 | 103 |
| 104 runPub(args: ['install'], | 104 runPub(args: ['install'], |
| 105 output: ''' | 105 output: ''' |
| 106 Dependencies installed! | 106 Dependencies installed! |
| 107 '''); | 107 '''); |
| 108 }); | 108 }); |
| 109 | 109 |
| 110 test('adds a transitively dependent package', () { | 110 test('adds a transitively dependent package', () { |
| 111 dir(sdkPath, [ | 111 dir(sdkPath, [ |
| 112 dir('lib', [ | 112 dir('lib', [ |
| 113 dir('foo', [ | 113 dir('foo', [ |
| 114 file('foo.dart', 'main() => "foo";'), | 114 file('foo.dart', 'main() => "foo";'), |
| 115 file('pubspec', 'dependencies:\n- bar') | 115 file('pubspec', 'dependencies:\n bar:') |
| 116 ]), | 116 ]), |
| 117 dir('bar', [ | 117 dir('bar', [ |
| 118 file('bar.dart', 'main() => "bar";'), | 118 file('bar.dart', 'main() => "bar";'), |
| 119 ]) | 119 ]) |
| 120 ]) | 120 ]) |
| 121 ]).scheduleCreate(); | 121 ]).scheduleCreate(); |
| 122 | 122 |
| 123 dir(appPath, [ | 123 dir(appPath, [ |
| 124 file('pubspec', 'dependencies:\n- foo') | 124 file('pubspec', 'dependencies:\n foo:') |
| 125 ]).scheduleCreate(); | 125 ]).scheduleCreate(); |
| 126 | 126 |
| 127 dir(packagesPath, [ | 127 dir(packagesPath, [ |
| 128 dir('foo', [ | 128 dir('foo', [ |
| 129 file('foo.dart', 'main() => "foo";') | 129 file('foo.dart', 'main() => "foo";') |
| 130 ]), | 130 ]), |
| 131 dir('bar', [ | 131 dir('bar', [ |
| 132 file('bar.dart', 'main() => "bar";'), | 132 file('bar.dart', 'main() => "bar";'), |
| 133 ]) | 133 ]) |
| 134 ]).scheduleValidate(); | 134 ]).scheduleValidate(); |
| 135 | 135 |
| 136 runPub(args: ['install'], | 136 runPub(args: ['install'], |
| 137 output: ''' | 137 output: ''' |
| 138 Dependencies installed! | 138 Dependencies installed! |
| 139 '''); | 139 '''); |
| 140 }); | 140 }); |
| 141 | |
| 142 String _gitPubspec(String name) => ''' | |
|
Bob Nystrom
2012/05/14 19:40:02
As much as I like DRY, I think the tests would be
nweiz
2012/05/14 19:53:38
Done.
| |
| 143 dependencies: | |
| 144 $name: | |
| 145 git: ../$name.git | |
| 146 '''; | |
| 147 | |
| 148 test('checks out a package from Git', () { | |
| 149 git('foo.git', [ | |
| 150 file('foo.dart', 'main() => "foo";') | |
| 151 ]).scheduleCreate(); | |
| 152 | |
| 153 dir(appPath, [ | |
| 154 file('pubspec', _gitPubspec('foo')) | |
| 155 ]).scheduleCreate(); | |
| 156 | |
| 157 dir(packagesPath, [ | |
| 158 dir('foo', [ | |
| 159 file('foo.dart', 'main() => "foo";') | |
| 160 ]) | |
| 161 ]).scheduleValidate(); | |
| 162 | |
| 163 runPub(args: ['install'], | |
| 164 output: const RegExp("^Cloning into[\\s\\S]*^Dependencies installed!\$", | |
|
Bob Nystrom
2012/05/14 19:40:02
You can use a raw string instead of escaping \:
@
nweiz
2012/05/14 19:53:38
Done.
| |
| 165 multiLine: true)); | |
| 166 }); | |
| 167 | |
| 168 test('checks out packages transitively from Git', () { | |
| 169 git('foo.git', [ | |
| 170 file('foo.dart', 'main() => "foo";'), | |
| 171 file('pubspec', _gitPubspec('bar')) | |
| 172 ]).scheduleCreate(); | |
| 173 | |
| 174 git('bar.git', [ | |
| 175 file('bar.dart', 'main() => "bar";') | |
| 176 ]).scheduleCreate(); | |
| 177 | |
| 178 dir(appPath, [ | |
| 179 file('pubspec', _gitPubspec('foo')) | |
| 180 ]).scheduleCreate(); | |
| 181 | |
| 182 dir(packagesPath, [ | |
| 183 dir('foo', [ | |
| 184 file('foo.dart', 'main() => "foo";') | |
| 185 ]), | |
| 186 dir('bar', [ | |
| 187 file('bar.dart', 'main() => "bar";') | |
| 188 ]) | |
| 189 ]).scheduleValidate(); | |
| 190 | |
| 191 runPub(args: ['install'], | |
| 192 output: const RegExp("^Cloning into[\\s\\S]*^Dependencies installed!\$", | |
| 193 multiLine: true)); | |
| 194 }); | |
| 141 } | 195 } |
| 142 | 196 |
| 143 versionCommand() { | 197 versionCommand() { |
| 144 test('displays the current version', () => | 198 test('displays the current version', () => |
| 145 runPub(args: ['version'], output: VERSION_STRING)); | 199 runPub(args: ['version'], output: VERSION_STRING)); |
| 146 } | 200 } |
| OLD | NEW |