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

Unified Diff: test/io.dart

Issue 1101773002: Add Windows support. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Unused import Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/util/path_handler.dart ('k') | test/runner/browser/chrome_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/io.dart
diff --git a/test/io.dart b/test/io.dart
index d9e419d3e11d975cf4c3b87389b721555bb04c36..f3b174ce8228f3592223df13d817f464b6221222 100644
--- a/test/io.dart
+++ b/test/io.dart
@@ -18,6 +18,11 @@ final _pubPath = p.absolute(p.join(
p.dirname(Platform.executable),
Platform.isWindows ? 'pub.bat' : 'pub'));
+/// The platform-specific message emitted when a nonexistent file is loaded.
+final String noSuchFileMessage = Platform.isWindows
+ ? "The system cannot find the file specified."
+ : "No such file or directory";
+
/// Runs the test executable with the package root set properly.
ProcessResult runTest(List<String> args, {String workingDirectory,
Map<String, String> environment}) {
@@ -46,16 +51,18 @@ ProcessResult runDart(List<String> args, {String workingDirectory,
}).toList()..addAll(args);
// TODO(nweiz): Use ScheduledProcess once it's compatible.
- return Process.runSync(p.absolute(Platform.executable), allArgs,
- workingDirectory: workingDirectory, environment: environment);
+ return new _NormalizedProcessResult(Process.runSync(
+ p.absolute(Platform.executable), allArgs,
+ workingDirectory: workingDirectory, environment: environment));
}
/// Runs Pub.
ProcessResult runPub(List<String> args, {String workingDirectory,
Map<String, String> environment}) {
// TODO(nweiz): Use ScheduledProcess once it's compatible.
- return Process.runSync(_pubPath, args,
- workingDirectory: workingDirectory, environment: environment);
+ return new _NormalizedProcessResult(Process.runSync(
+ _pubPath, args,
+ workingDirectory: workingDirectory, environment: environment));
}
/// Starts the test executable with the package root set properly.
@@ -90,3 +97,24 @@ Future<Process> startPub(List<String> args, {String workingDirectory,
return Process.start(_pubPath, args,
workingDirectory: workingDirectory, environment: environment);
}
+
+/// A wrapper around [ProcessResult] that normalizes the newline format across
+/// operating systems.
+class _NormalizedProcessResult implements ProcessResult {
+ final ProcessResult _inner;
+
+ int get exitCode => _inner.exitCode;
+ int get pid => _inner.pid;
+
+ final String stdout;
+ final String stderr;
+
+ _NormalizedProcessResult(ProcessResult inner)
+ : _inner = inner,
+ stdout = Platform.isWindows
+ ? inner.stdout.replaceAll("\r\n", "\n")
+ : inner.stdout,
+ stderr = Platform.isWindows
+ ? inner.stderr.replaceAll("\r\n", "\n")
+ : inner.stderr;
+}
« no previous file with comments | « lib/src/util/path_handler.dart ('k') | test/runner/browser/chrome_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698