| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub | 5 /// Test infrastructure for testing pub. Unlike typical unit tests, most pub |
| 6 /// tests are integration tests that stage some stuff on the file system, run | 6 /// tests are integration tests that stage some stuff on the file system, run |
| 7 /// pub, and then validate the results. This library provides an API to build | 7 /// pub, and then validate the results. This library provides an API to build |
| 8 /// tests like that. | 8 /// tests like that. |
| 9 library test_pub; | 9 library test_pub; |
| 10 | 10 |
| 11 import 'dart:async'; | 11 import 'dart:async'; |
| 12 import 'dart:collection' show Queue; | 12 import 'dart:collection' show Queue; |
| 13 import 'dart:io'; | 13 import 'dart:io'; |
| 14 import 'dart:json' as json; | 14 import 'dart:json' as json; |
| 15 import 'dart:math'; | 15 import 'dart:math'; |
| 16 import 'dart:uri'; | 16 import 'dart:uri'; |
| 17 import 'dart:utf'; | 17 import 'dart:utf'; |
| 18 | 18 |
| 19 import '../../../pkg/http/lib/testing.dart'; | 19 import 'package:http/testing.dart'; |
| 20 import '../../../pkg/oauth2/lib/oauth2.dart' as oauth2; | 20 import 'package:oauth2/oauth2.dart' as oauth2; |
| 21 import '../../../pkg/pathos/lib/path.dart' as path; | 21 import 'package:pathos/path.dart' as path; |
| 22 import '../../../pkg/scheduled_test/lib/scheduled_process.dart'; | 22 import 'package:scheduled_test/scheduled_process.dart'; |
| 23 import '../../../pkg/scheduled_test/lib/scheduled_server.dart'; | 23 import 'package:scheduled_test/scheduled_server.dart'; |
| 24 import '../../../pkg/scheduled_test/lib/scheduled_test.dart'; | 24 import 'package:scheduled_test/scheduled_test.dart'; |
| 25 import '../../../pkg/yaml/lib/yaml.dart'; | 25 import 'package:yaml/yaml.dart'; |
| 26 | 26 |
| 27 import '../../lib/file_system.dart' as fs; | |
| 28 import '../../pub/entrypoint.dart'; | 27 import '../../pub/entrypoint.dart'; |
| 29 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides | 28 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides |
| 30 // with the git descriptor method. Maybe we should try to clean up the top level | 29 // with the git descriptor method. Maybe we should try to clean up the top level |
| 31 // scope a bit? | 30 // scope a bit? |
| 32 import '../../pub/git.dart' as gitlib; | 31 import '../../pub/git.dart' as gitlib; |
| 33 import '../../pub/git_source.dart'; | 32 import '../../pub/git_source.dart'; |
| 34 import '../../pub/hosted_source.dart'; | 33 import '../../pub/hosted_source.dart'; |
| 35 import '../../pub/http.dart'; | 34 import '../../pub/http.dart'; |
| 36 import '../../pub/io.dart'; | 35 import '../../pub/io.dart'; |
| 37 import '../../pub/path_source.dart'; | 36 import '../../pub/path_source.dart'; |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 // used to run this script itself. | 333 // used to run this script itself. |
| 335 var dartBin = new Options().executable; | 334 var dartBin = new Options().executable; |
| 336 | 335 |
| 337 // If the executable looks like a path, get its full path. That way we | 336 // If the executable looks like a path, get its full path. That way we |
| 338 // can still find it when we spawn it with a different working directory. | 337 // can still find it when we spawn it with a different working directory. |
| 339 if (dartBin.contains(Platform.pathSeparator)) { | 338 if (dartBin.contains(Platform.pathSeparator)) { |
| 340 dartBin = new File(dartBin).fullPathSync(); | 339 dartBin = new File(dartBin).fullPathSync(); |
| 341 } | 340 } |
| 342 | 341 |
| 343 // Find the main pub entrypoint. | 342 // Find the main pub entrypoint. |
| 344 var pubPath = fs.joinPaths(testDirectory, '../../pub/pub.dart'); | 343 var pubPath = path.join(testDirectory, '..', '..', 'pub', 'pub.dart'); |
| 345 | 344 |
| 346 var dartArgs = ['--checked', pubPath, '--trace']; | 345 var dartArgs = ['--package-root=$packageRoot/', '--checked', pubPath, |
| 346 '--trace']; |
| 347 dartArgs.addAll(args); | 347 dartArgs.addAll(args); |
| 348 | 348 |
| 349 if (tokenEndpoint == null) tokenEndpoint = new Future.immediate(null); | 349 if (tokenEndpoint == null) tokenEndpoint = new Future.immediate(null); |
| 350 var optionsFuture = tokenEndpoint.then((tokenEndpoint) { | 350 var optionsFuture = tokenEndpoint.then((tokenEndpoint) { |
| 351 var options = new ProcessOptions(); | 351 var options = new ProcessOptions(); |
| 352 options.workingDirectory = pathInSandbox(appPath); | 352 options.workingDirectory = pathInSandbox(appPath); |
| 353 // TODO(nweiz): remove this when issue 9294 is fixed. | 353 // TODO(nweiz): remove this when issue 9294 is fixed. |
| 354 options.environment = new Map.from(Platform.environment); | 354 options.environment = new Map.from(Platform.environment); |
| 355 options.environment['PUB_CACHE'] = pathInSandbox(cachePath); | 355 options.environment['PUB_CACHE'] = pathInSandbox(cachePath); |
| 356 options.environment['DART_SDK'] = pathInSandbox(sdkPath); | 356 options.environment['DART_SDK'] = pathInSandbox(sdkPath); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 bool matches(item, MatchState matchState) { | 584 bool matches(item, MatchState matchState) { |
| 585 if (item is! Pair) return false; | 585 if (item is! Pair) return false; |
| 586 return _firstMatcher.matches(item.first, matchState) && | 586 return _firstMatcher.matches(item.first, matchState) && |
| 587 _lastMatcher.matches(item.last, matchState); | 587 _lastMatcher.matches(item.last, matchState); |
| 588 } | 588 } |
| 589 | 589 |
| 590 Description describe(Description description) { | 590 Description describe(Description description) { |
| 591 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 591 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
| 592 } | 592 } |
| 593 } | 593 } |
| OLD | NEW |