| 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 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 import '../lib/src/entrypoint.dart'; | 24 import '../lib/src/entrypoint.dart'; |
| 25 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides | 25 // TODO(rnystrom): Using "gitlib" as the prefix here is ugly, but "git" collides |
| 26 // with the git descriptor method. Maybe we should try to clean up the top level | 26 // with the git descriptor method. Maybe we should try to clean up the top level |
| 27 // scope a bit? | 27 // scope a bit? |
| 28 import '../lib/src/git.dart' as gitlib; | 28 import '../lib/src/git.dart' as gitlib; |
| 29 import '../lib/src/http.dart'; | 29 import '../lib/src/http.dart'; |
| 30 import '../lib/src/io.dart'; | 30 import '../lib/src/io.dart'; |
| 31 import '../lib/src/lock_file.dart'; | 31 import '../lib/src/lock_file.dart'; |
| 32 import '../lib/src/log.dart' as log; | 32 import '../lib/src/log.dart' as log; |
| 33 import '../lib/src/package.dart'; | 33 import '../lib/src/package.dart'; |
| 34 import '../lib/src/safe_http_server.dart'; | |
| 35 import '../lib/src/source/hosted.dart'; | 34 import '../lib/src/source/hosted.dart'; |
| 36 import '../lib/src/source/path.dart'; | 35 import '../lib/src/source/path.dart'; |
| 37 import '../lib/src/source_registry.dart'; | 36 import '../lib/src/source_registry.dart'; |
| 38 import '../lib/src/system_cache.dart'; | 37 import '../lib/src/system_cache.dart'; |
| 39 import '../lib/src/utils.dart'; | 38 import '../lib/src/utils.dart'; |
| 40 import '../lib/src/validator.dart'; | 39 import '../lib/src/validator.dart'; |
| 41 import '../lib/src/version.dart'; | 40 import '../lib/src/version.dart'; |
| 42 import 'descriptor.dart' as d; | 41 import 'descriptor.dart' as d; |
| 43 | 42 |
| 44 /// This should be called at the top of a test file to set up an appropriate | 43 /// This should be called at the top of a test file to set up an appropriate |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 /// exist only for the duration of the pub run. | 95 /// exist only for the duration of the pub run. |
| 97 /// | 96 /// |
| 98 /// Subsequent calls to [serve] will replace the previous server. | 97 /// Subsequent calls to [serve] will replace the previous server. |
| 99 void serve([List<d.Descriptor> contents]) { | 98 void serve([List<d.Descriptor> contents]) { |
| 100 var baseDir = d.dir("serve-dir", contents); | 99 var baseDir = d.dir("serve-dir", contents); |
| 101 | 100 |
| 102 _hasServer = true; | 101 _hasServer = true; |
| 103 | 102 |
| 104 schedule(() { | 103 schedule(() { |
| 105 return _closeServer().then((_) { | 104 return _closeServer().then((_) { |
| 106 return SafeHttpServer.bind("127.0.0.1", 0).then((server) { | 105 return HttpServer.bind("127.0.0.1", 0).then((server) { |
| 107 _server = server; | 106 _server = server; |
| 108 server.listen((request) { | 107 server.listen((request) { |
| 109 currentSchedule.heartbeat(); | 108 currentSchedule.heartbeat(); |
| 110 var response = request.response; | 109 var response = request.response; |
| 111 try { | 110 try { |
| 112 var path = request.uri.path.replaceFirst("/", ""); | 111 var path = request.uri.path.replaceFirst("/", ""); |
| 113 _requestedPaths.add(path); | 112 _requestedPaths.add(path); |
| 114 | 113 |
| 115 response.persistentConnection = false; | 114 response.persistentConnection = false; |
| 116 var stream = baseDir.load(path); | 115 var stream = baseDir.load(path); |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 bool matches(item, Map matchState) { | 858 bool matches(item, Map matchState) { |
| 860 if (item is! Pair) return false; | 859 if (item is! Pair) return false; |
| 861 return _firstMatcher.matches(item.first, matchState) && | 860 return _firstMatcher.matches(item.first, matchState) && |
| 862 _lastMatcher.matches(item.last, matchState); | 861 _lastMatcher.matches(item.last, matchState); |
| 863 } | 862 } |
| 864 | 863 |
| 865 Description describe(Description description) { | 864 Description describe(Description description) { |
| 866 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); | 865 description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); |
| 867 } | 866 } |
| 868 } | 867 } |
| OLD | NEW |