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

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

Issue 15883003: Remove ProcessOptions and make the options named arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Comments cleanup. Created 7 years, 7 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
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 "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import "dart:io"; 9 import "dart:io";
10 import "process_test_util.dart"; 10 import "process_test_util.dart";
11 11
12 class ProcessWorkingDirectoryTest { 12 class ProcessWorkingDirectoryTest {
13 static String get fullTestFilePath { 13 static String get fullTestFilePath {
14 // Extract full path, since we run processes from another directory. 14 // Extract full path, since we run processes from another directory.
15 File path = new File(getProcessTestFileName()); 15 File path = new File(getProcessTestFileName());
16 Expect.isTrue(path.existsSync()); 16 Expect.isTrue(path.existsSync());
17 return path.fullPathSync(); 17 return path.fullPathSync();
18 } 18 }
19 19
20 static void testValidDirectory() { 20 static void testValidDirectory() {
21 Directory directory = new Directory("").createTempSync(); 21 Directory directory = new Directory("").createTempSync();
22 Expect.isTrue(directory.existsSync()); 22 Expect.isTrue(directory.existsSync());
23 23
24 var options = new ProcessOptions(); 24 Process.start(fullTestFilePath,
25 options.workingDirectory = directory.path; 25 const ["0", "0", "99", "0"],
26 var processFuture = 26 workingDirectory: directory.path)
27 Process.start(fullTestFilePath, const ["0", "0", "99", "0"], options); 27 .then((process) {
28 processFuture.then((process) { 28 process.exitCode.then((int exitCode) {
29 process.exitCode.then((int exitCode) { 29 Expect.equals(exitCode, 99);
30 Expect.equals(exitCode, 99); 30 directory.deleteSync();
31 directory.deleteSync(); 31 });
32 }); 32 process.stdout.listen((_) {});
33 process.stdout.listen((_) {}); 33 process.stderr.listen((_) {});
34 process.stderr.listen((_) {}); 34 }).catchError((error) {
35 }).catchError((error) { 35 directory.deleteSync();
36 directory.deleteSync(); 36 Expect.fail("Couldn't start process");
37 Expect.fail("Couldn't start process"); 37 });
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 Process.start(fullTestFilePath,
46 options.workingDirectory = directory.path + "/subPath"; 45 const ["0", "0", "99", "0"],
47 var future = Process.start(fullTestFilePath, 46 workingDirectory: directory.path + "/subPath")
48 const ["0", "0", "99", "0"], 47 .then((process) {
49 options); 48 Expect.fail("bad process completed");
50 future.then((process) { 49 directory.deleteSync();
51 Expect.fail("bad process completed"); 50 }).catchError((e) {
52 directory.deleteSync(); 51 Expect.isNotNull(e);
53 }).catchError((e) { 52 directory.deleteSync();
54 Expect.isNotNull(e); 53 });
55 directory.deleteSync();
56 });
57 } 54 }
58 } 55 }
59 56
60 57
61 58
62 main() { 59 main() {
63 ProcessWorkingDirectoryTest.testValidDirectory(); 60 ProcessWorkingDirectoryTest.testValidDirectory();
64 ProcessWorkingDirectoryTest.testInvalidDirectory(); 61 ProcessWorkingDirectoryTest.testInvalidDirectory();
65 } 62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698