| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 // |
| 5 // Process working directory test. |
| 6 |
| 7 #library("ProcessWorkingDirectoryTest"); |
| 8 #source("ProcessTestUtil.dart"); |
| 9 |
| 10 class ProcessWorkingDirectoryTest { |
| 11 static String get fullTestFilePath() { |
| 12 // Extract full path, since we run processes from another directory. |
| 13 File path = new File(getProcessTestFileName()); |
| 14 Expect.isTrue(path.existsSync()); |
| 15 return path.fullPathSync(); |
| 16 } |
| 17 |
| 18 static void testValidDirectory() { |
| 19 Directory directory = new Directory(""); |
| 20 directory.createTempSync(); |
| 21 Expect.isTrue(directory.existsSync()); |
| 22 |
| 23 print(fullTestFilePath); |
| 24 |
| 25 Process process = new Process.start(fullTestFilePath, |
| 26 const ["0", "0", "99", "0"], |
| 27 directory.path); |
| 28 |
| 29 process.exitHandler = (int exitCode) { |
| 30 Expect.equals(exitCode, 99); |
| 31 process.close(); |
| 32 directory.deleteSync(); |
| 33 }; |
| 34 |
| 35 process.errorHandler = (error) { |
| 36 Expect.fail("error running process $error"); |
| 37 directory.deleteSync(); |
| 38 }; |
| 39 } |
| 40 |
| 41 static void testInvalidDirectory() { |
| 42 Directory directory = new Directory(""); |
| 43 directory.createTempSync(); |
| 44 Expect.isTrue(directory.existsSync()); |
| 45 |
| 46 Process process = new Process.start(fullTestFilePath, |
| 47 const ["0", "0", "99", "0"], |
| 48 directory.path + "/subPath"); |
| 49 |
| 50 process.exitHandler = (int exitCode) { |
| 51 Expect.fail("bad process completed"); |
| 52 process.close(); |
| 53 directory.deleteSync(); |
| 54 }; |
| 55 |
| 56 process.errorHandler = (error) { |
| 57 Expect.isNotNull(error); |
| 58 directory.deleteSync(); |
| 59 }; |
| 60 } |
| 61 } |
| 62 |
| 63 |
| 64 |
| 65 main() { |
| 66 ProcessWorkingDirectoryTest.testValidDirectory(); |
| 67 ProcessWorkingDirectoryTest.testInvalidDirectory(); |
| 68 } |
| OLD | NEW |