OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 test.test.io; | 5 library test.test.io; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:path/path.dart' as p; | 10 import 'package:path/path.dart' as p; |
11 import 'package:scheduled_test/descriptor.dart' as d; | 11 import 'package:scheduled_test/descriptor.dart' as d; |
12 import 'package:scheduled_test/scheduled_process.dart'; | 12 import 'package:scheduled_test/scheduled_process.dart'; |
13 import 'package:scheduled_test/scheduled_stream.dart'; | 13 import 'package:scheduled_test/scheduled_stream.dart'; |
14 import 'package:scheduled_test/scheduled_test.dart'; | 14 import 'package:scheduled_test/scheduled_test.dart'; |
15 import 'package:test/src/util/io.dart'; | 15 import 'package:test/src/util/io.dart'; |
16 | 16 |
17 /// The path to the root directory of the `test` package. | 17 /// The path to the root directory of the `test` package. |
18 final String packageDir = p.dirname(p.dirname(libraryPath(#test.test.io))); | 18 final String packageDir = p.dirname(p.dirname(libraryPath(#test.test.io))); |
19 | 19 |
20 /// The path to the `pub` executable in the current Dart SDK. | 20 /// The path to the `pub` executable in the current Dart SDK. |
21 final _pubPath = p.absolute(p.join( | 21 final _pubPath = p.absolute(p.join( |
22 p.dirname(Platform.executable), | 22 p.dirname(Platform.resolvedExecutable), |
23 Platform.isWindows ? 'pub.bat' : 'pub')); | 23 Platform.isWindows ? 'pub.bat' : 'pub')); |
24 | 24 |
25 /// The platform-specific message emitted when a nonexistent file is loaded. | 25 /// The platform-specific message emitted when a nonexistent file is loaded. |
26 final String noSuchFileMessage = Platform.isWindows | 26 final String noSuchFileMessage = Platform.isWindows |
27 ? "The system cannot find the file specified." | 27 ? "The system cannot find the file specified." |
28 : "No such file or directory"; | 28 : "No such file or directory"; |
29 | 29 |
30 /// A regular expression that matches the output of "pub serve". | 30 /// A regular expression that matches the output of "pub serve". |
31 final _servingRegExp = | 31 final _servingRegExp = |
32 new RegExp(r'^Serving myapp [a-z]+ on http://localhost:(\d+)$'); | 32 new RegExp(r'^Serving myapp [a-z]+ on http://localhost:(\d+)$'); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 String description}) { | 120 String description}) { |
121 var allArgs = Platform.executableArguments.map((arg) { | 121 var allArgs = Platform.executableArguments.map((arg) { |
122 // The package root might be relative, so we need to make it absolute if | 122 // The package root might be relative, so we need to make it absolute if |
123 // we're going to run in a different working directory. | 123 // we're going to run in a different working directory. |
124 if (!arg.startsWith("--package-root=")) return arg; | 124 if (!arg.startsWith("--package-root=")) return arg; |
125 return "--package-root=" + | 125 return "--package-root=" + |
126 p.absolute(p.fromUri(arg.substring("--package-root=".length))); | 126 p.absolute(p.fromUri(arg.substring("--package-root=".length))); |
127 }).toList()..addAll(args); | 127 }).toList()..addAll(args); |
128 | 128 |
129 return new ScheduledProcess.start( | 129 return new ScheduledProcess.start( |
130 p.absolute(Platform.executable), allArgs, | 130 p.absolute(Platform.resolvedExecutable), allArgs, |
131 workingDirectory: _sandbox, | 131 workingDirectory: _sandbox, |
132 environment: environment, | 132 environment: environment, |
133 description: description); | 133 description: description); |
134 } | 134 } |
135 | 135 |
136 /// Runs Pub. | 136 /// Runs Pub. |
137 ScheduledProcess runPub(List args, {Map<String, String> environment}) { | 137 ScheduledProcess runPub(List args, {Map<String, String> environment}) { |
138 return new ScheduledProcess.start( | 138 return new ScheduledProcess.start( |
139 _pubPath, args, | 139 _pubPath, args, |
140 workingDirectory: _sandbox, | 140 workingDirectory: _sandbox, |
(...skipping 19 matching lines...) Expand all Loading... |
160 var match; | 160 var match; |
161 while (match == null) { | 161 while (match == null) { |
162 var line = await pub.stdout.next(); | 162 var line = await pub.stdout.next(); |
163 match = _servingRegExp.firstMatch(line); | 163 match = _servingRegExp.firstMatch(line); |
164 } | 164 } |
165 _pubServePortCompleter.complete(int.parse(match[1])); | 165 _pubServePortCompleter.complete(int.parse(match[1])); |
166 }, "waiting for pub serve to emit its port number"); | 166 }, "waiting for pub serve to emit its port number"); |
167 | 167 |
168 return pub; | 168 return pub; |
169 } | 169 } |
OLD | NEW |