Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: utils/tests/pub/test_pub.dart

Issue 10873003: Actually hook server creation into the pub test schedule. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 * 62 *
63 * Subsequent calls to [serve] will replace the previous server. 63 * Subsequent calls to [serve] will replace the previous server.
64 */ 64 */
65 void serve(String host, int port, [List<Descriptor> contents]) { 65 void serve(String host, int port, [List<Descriptor> contents]) {
66 var baseDir = dir("serve-dir", contents); 66 var baseDir = dir("serve-dir", contents);
67 if (host == 'localhost') { 67 if (host == 'localhost') {
68 host = '127.0.0.1'; 68 host = '127.0.0.1';
69 } 69 }
70 70
71 _schedule((_) { 71 _schedule((_) {
72 _closeServer().transform((_) { 72 return _closeServer().transform((_) {
73 _server = new HttpServer(); 73 _server = new HttpServer();
74 _server.defaultRequestHandler = (request, response) { 74 _server.defaultRequestHandler = (request, response) {
75 var path = request.uri.replaceFirst("/", "").split("/"); 75 var path = request.uri.replaceFirst("/", "").split("/");
76 response.persistentConnection = false; 76 response.persistentConnection = false;
77 var stream; 77 var stream;
78 try { 78 try {
79 stream = baseDir.load(path); 79 stream = baseDir.load(path);
80 } catch (var e) { 80 } catch (var e) {
81 response.statusCode = 404; 81 response.statusCode = 404;
82 response.contentLength = 0; 82 response.contentLength = 0;
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 811 }
812 812
813 /** 813 /**
814 * Schedules a callback to be called after Pub is run with [runPub], even if it 814 * Schedules a callback to be called after Pub is run with [runPub], even if it
815 * fails. 815 * fails.
816 */ 816 */
817 void _scheduleCleanup(_ScheduledEvent event) { 817 void _scheduleCleanup(_ScheduledEvent event) {
818 if (_scheduledCleanup == null) _scheduledCleanup = []; 818 if (_scheduledCleanup == null) _scheduledCleanup = [];
819 _scheduledCleanup.add(event); 819 _scheduledCleanup.add(event);
820 } 820 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698