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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 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 unified diff | Download patch
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 test program to errors during startup of the process. 5 // Process test program to errors during startup of the process.
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 10
11 // ENOENT and ERROR_FILE_NOT_FOUND on Windows both have the same value. 11 // ENOENT and ERROR_FILE_NOT_FOUND on Windows both have the same value.
12 // Note: we are setting PATH to an empty string in tests below because on 12 // Note: we are setting PATH to an empty string in tests below because on
13 // POSIX systems if target binary name does not contain `/` then it is 13 // POSIX systems if target binary name does not contain `/` then it is
14 // searched through PATH and if it is not found anywhere in the PATH 14 // searched through PATH and if it is not found anywhere in the PATH
15 // but some folder in PATH is inaccessible then underlying execvp(...) 15 // but some folder in PATH is inaccessible then underlying execvp(...)
16 // call will return EACCES (13) instead of ENOENT. 16 // call will return EACCES (13) instead of ENOENT.
17 // For example on some Android devices PATH would include /sbin with is 17 // For example on some Android devices PATH would include /sbin with is
18 // inaccessible - so this test will fail. 18 // inaccessible - so this test will fail.
19 const ENOENT = 2; 19 const ENOENT = 2;
20 20
21 testStartError() { 21 testStartError() {
22 Future<Process> processFuture = 22 Future<Process> processFuture = Process.start(
23 Process.start("__path_to_something_that_should_not_exist__", 23 "__path_to_something_that_should_not_exist__", const [],
24 const [], 24 environment: {"PATH": ""});
25 environment: {"PATH": ""}); 25 processFuture
26 processFuture.then((p) => Expect.fail('got process despite start error')) 26 .then((p) => Expect.fail('got process despite start error'))
27 .catchError((error) { 27 .catchError((error) {
28 Expect.isTrue(error is ProcessException); 28 Expect.isTrue(error is ProcessException);
29 Expect.equals(ENOENT, error.errorCode, error.toString()); 29 Expect.equals(ENOENT, error.errorCode, error.toString());
30 }); 30 });
31 } 31 }
32 32
33 testRunError() { 33 testRunError() {
34 Future<ProcessResult> processFuture = 34 Future<ProcessResult> processFuture = Process.run(
35 Process.run("__path_to_something_that_should_not_exist__", 35 "__path_to_something_that_should_not_exist__", const [],
36 const [], 36 environment: {"PATH": ""});
37 environment: {"PATH": ""});
38 37
39 processFuture.then((result) => Expect.fail("exit handler called")) 38 processFuture
40 .catchError((error) { 39 .then((result) => Expect.fail("exit handler called"))
40 .catchError((error) {
41 Expect.isTrue(error is ProcessException); 41 Expect.isTrue(error is ProcessException);
42 Expect.equals(ENOENT, error.errorCode, error.toString()); 42 Expect.equals(ENOENT, error.errorCode, error.toString());
43 }); 43 });
44 } 44 }
45 45
46 main() { 46 main() {
47 testStartError(); 47 testStartError();
48 testRunError(); 48 testRunError();
49 } 49 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698