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

Side by Side Diff: tests/standalone/io/process_working_directory_test.dart

Issue 11091070: Change Process.start to return a future that completes with a (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Restructure to get rid of _onStart and _onError Created 8 years, 2 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 | « tests/standalone/io/process_stdout_test.dart ('k') | tools/testing/dart/co19_test.dart » ('j') | 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 // Process working directory test. 5 // Process working directory test.
6 6
7 #library("ProcessWorkingDirectoryTest"); 7 #library("ProcessWorkingDirectoryTest");
8 #import("dart:io"); 8 #import("dart:io");
9 #source("process_test_util.dart"); 9 #source("process_test_util.dart");
10 10
11 class ProcessWorkingDirectoryTest { 11 class ProcessWorkingDirectoryTest {
12 static String get fullTestFilePath { 12 static String get fullTestFilePath {
13 // Extract full path, since we run processes from another directory. 13 // Extract full path, since we run processes from another directory.
14 File path = new File(getProcessTestFileName()); 14 File path = new File(getProcessTestFileName());
15 Expect.isTrue(path.existsSync()); 15 Expect.isTrue(path.existsSync());
16 return path.fullPathSync(); 16 return path.fullPathSync();
17 } 17 }
18 18
19 static void testValidDirectory() { 19 static void testValidDirectory() {
20 Directory directory = new Directory("").createTempSync(); 20 Directory directory = new Directory("").createTempSync();
21 Expect.isTrue(directory.existsSync()); 21 Expect.isTrue(directory.existsSync());
22 22
23 var options = new ProcessOptions(); 23 var options = new ProcessOptions();
24 options.workingDirectory = directory.path; 24 options.workingDirectory = directory.path;
25 Process process = Process.start(fullTestFilePath, 25 var processFuture =
26 const ["0", "0", "99", "0"], 26 Process.start(fullTestFilePath, const ["0", "0", "99", "0"], options);
27 options); 27 processFuture.then((process) {
28 28 process.onExit = (int exitCode) {
29 process.onExit = (int exitCode) { 29 Expect.equals(exitCode, 99);
30 Expect.equals(exitCode, 99); 30 process.close();
31 process.close(); 31 directory.deleteSync();
32 };
33 });
34 processFuture.handleException((error) {
32 directory.deleteSync(); 35 directory.deleteSync();
33 }; 36 Expect.fails("Couldn't start process");
34 37 });
35 process.onError = (error) {
36 Expect.fail("error running process $error");
37 directory.deleteSync();
38 };
39 } 38 }
40 39
41 static void testInvalidDirectory() { 40 static void testInvalidDirectory() {
42 Directory directory = new Directory("").createTempSync(); 41 Directory directory = new Directory("").createTempSync();
43 Expect.isTrue(directory.existsSync()); 42 Expect.isTrue(directory.existsSync());
44 43
45 var options = new ProcessOptions(); 44 var options = new ProcessOptions();
46 options.workingDirectory = directory.path.concat("/subPath"); 45 options.workingDirectory = directory.path.concat("/subPath");
47 Process process = Process.start(fullTestFilePath, 46 var future = Process.start(fullTestFilePath,
48 const ["0", "0", "99", "0"], 47 const ["0", "0", "99", "0"],
49 options); 48 options);
50 49 future.then((process) {
51 process.onExit = (int exitCode) {
52 Expect.fail("bad process completed"); 50 Expect.fail("bad process completed");
53 process.close(); 51 process.close();
54 directory.deleteSync(); 52 directory.deleteSync();
55 }; 53 });
56 54
57 process.onError = (error) { 55 future.handleException((e) {
58 Expect.isNotNull(error); 56 Expect.isNotNull(e);
59 directory.deleteSync(); 57 directory.deleteSync();
60 }; 58 return true;
59 });
61 } 60 }
62 } 61 }
63 62
64 63
65 64
66 main() { 65 main() {
67 ProcessWorkingDirectoryTest.testValidDirectory(); 66 ProcessWorkingDirectoryTest.testValidDirectory();
68 ProcessWorkingDirectoryTest.testInvalidDirectory(); 67 ProcessWorkingDirectoryTest.testInvalidDirectory();
69 } 68 }
OLDNEW
« no previous file with comments | « tests/standalone/io/process_stdout_test.dart ('k') | tools/testing/dart/co19_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698