| 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 /** | 5 /** |
| 6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub | 6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub |
| 7 * tests are integration tests that stage some stuff on the file system, run | 7 * tests are integration tests that stage some stuff on the file system, run |
| 8 * pub, and then validate the results. This library provides an API to build | 8 * pub, and then validate the results. This library provides an API to build |
| 9 * tests like that. | 9 * tests like that. |
| 10 */ | 10 */ |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 case "hosted": | 390 case "hosted": |
| 391 source = new HostedSource(); | 391 source = new HostedSource(); |
| 392 break; | 392 break; |
| 393 case "sdk": | 393 case "sdk": |
| 394 source = new SdkSource(''); | 394 source = new SdkSource(''); |
| 395 break; | 395 break; |
| 396 default: | 396 default: |
| 397 throw 'Unknown source "$sourceName"'; | 397 throw 'Unknown source "$sourceName"'; |
| 398 } | 398 } |
| 399 | 399 |
| 400 result[source.packageName(dependency[sourceName])] = dependency; | 400 result[_packageName(sourceName, dependency[sourceName])] = dependency; |
| 401 } | 401 } |
| 402 return result; | 402 return result; |
| 403 }); | 403 }); |
| 404 } | 404 } |
| 405 | 405 |
| 406 /// Return the name for the package described by [description] and from |
| 407 /// [sourceName]. |
| 408 String _packageName(String sourceName, description) { |
| 409 switch (sourceName) { |
| 410 case "git": |
| 411 var url = description is String ? description : description['url']; |
| 412 return basename(url.replaceFirst(const RegExp(@"(\.git)?/?$"), "")); |
| 413 case "hosted": |
| 414 if (description is String) return description; |
| 415 return description['name']; |
| 416 default: |
| 417 return description; |
| 418 } |
| 419 } |
| 420 |
| 406 /** | 421 /** |
| 407 * The path of the package cache directory used for tests. Relative to the | 422 * The path of the package cache directory used for tests. Relative to the |
| 408 * sandbox directory. | 423 * sandbox directory. |
| 409 */ | 424 */ |
| 410 final String cachePath = "cache"; | 425 final String cachePath = "cache"; |
| 411 | 426 |
| 412 /** | 427 /** |
| 413 * The path of the mock SDK directory used for tests. Relative to the sandbox | 428 * The path of the mock SDK directory used for tests. Relative to the sandbox |
| 414 * directory. | 429 * directory. |
| 415 */ | 430 */ |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 } | 1136 } |
| 1122 | 1137 |
| 1123 /** | 1138 /** |
| 1124 * Schedules a callback to be called after Pub is run with [runPub], even if it | 1139 * Schedules a callback to be called after Pub is run with [runPub], even if it |
| 1125 * fails. | 1140 * fails. |
| 1126 */ | 1141 */ |
| 1127 void _scheduleCleanup(_ScheduledEvent event) { | 1142 void _scheduleCleanup(_ScheduledEvent event) { |
| 1128 if (_scheduledCleanup == null) _scheduledCleanup = []; | 1143 if (_scheduledCleanup == null) _scheduledCleanup = []; |
| 1129 _scheduledCleanup.add(event); | 1144 _scheduledCleanup.add(event); |
| 1130 } | 1145 } |
| OLD | NEW |