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

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

Issue 163273002: Add signal test for each supported signal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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/signal_test_script.dart ('k') | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "dart:io"; 5 import "dart:io";
6 import "dart:convert";
6 7
7 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
8 import "package:async_helper/async_helper.dart"; 9 import "package:async_helper/async_helper.dart";
9 10
10 void testSignals(int usr1Expect, 11 void testSignals(int usr1Expect,
11 int usr2Expect, 12 int usr2Expect,
12 [int usr1Send, 13 [int usr1Send,
13 int usr2Send, 14 int usr2Send,
14 bool shouldFail = false]) { 15 bool shouldFail = false]) {
15 if (usr1Send == null) usr1Send = usr1Expect; 16 if (usr1Send == null) usr1Send = usr1Expect;
(...skipping 19 matching lines...) Expand all
35 v++; 36 v++;
36 } 37 }
37 }); 38 });
38 process.exitCode.then((exitCode) { 39 process.exitCode.then((exitCode) {
39 Expect.equals(shouldFail, exitCode != 0); 40 Expect.equals(shouldFail, exitCode != 0);
40 asyncEnd(); 41 asyncEnd();
41 }); 42 });
42 }); 43 });
43 } 44 }
44 45
46 void testSignal(ProcessSignal signal) {
47 asyncStart();
48 Process.start(Platform.executable,
49 [Platform.script.resolve('signal_test_script.dart').toFilePath(),
50 signal.toString()])
51 .then((process) {
52 process.stdin.close();
53 process.stderr.transform(UTF8.decoder).listen(print);
Søren Gjesse 2014/02/13 10:54:27 Debug print?
Anders Johnsen 2014/02/13 12:08:03 Done.
54
55 var output = "";
56 process.stdout.transform(UTF8.decoder)
57 .listen((str) {
58 output += str;
59 if (output == 'ready\n') {
60 process.kill(signal);
61 }
62 }, onDone: () {
63 Expect.equals('ready\ngot signal\n', output);
64 });
65 process.exitCode.then((exitCode) {
66 Expect.equals(0, exitCode);
67 asyncEnd();
68 });
69 });
70 }
71
45 72
46 void testListenCancel() { 73 void testListenCancel() {
47 for (int i = 0; i < 10; i++) { 74 for (int i = 0; i < 10; i++) {
48 ProcessSignal.SIGINT.watch().listen(null).cancel(); 75 ProcessSignal.SIGINT.watch().listen(null).cancel();
49 } 76 }
50 } 77 }
51 78
52 void main() { 79 void main() {
53 testListenCancel(); 80 testListenCancel();
54 if (Platform.isWindows) return; 81 if (Platform.isWindows) return;
55 testSignals(0, 0); 82 testSignals(0, 0);
56 testSignals(1, 0); 83 testSignals(1, 0);
57 testSignals(0, 1); 84 testSignals(0, 1);
58 testSignals(1, 1); 85 testSignals(1, 1);
59 testSignals(10, 10); 86 testSignals(10, 10);
60 testSignals(10, 1); 87 testSignals(10, 1);
61 testSignals(1, 10); 88 testSignals(1, 10);
62 testSignals(1, 0, 0, 1, true); 89 testSignals(1, 0, 0, 1, true);
63 testSignals(0, 1, 1, 0, true); 90 testSignals(0, 1, 1, 0, true);
91
Søren Gjesse 2014/02/13 10:54:27 Don't you need to skip some of these on Windows?
Anders Johnsen 2014/02/13 12:08:03 Already filtered out, see 10 lines above.
92 testSignal(ProcessSignal.SIGHUP);
93 testSignal(ProcessSignal.SIGINT);
94 testSignal(ProcessSignal.SIGTERM);
95 testSignal(ProcessSignal.SIGUSR1);
96 testSignal(ProcessSignal.SIGUSR2);
97 testSignal(ProcessSignal.SIGWINCH);
64 } 98 }
OLDNEW
« no previous file with comments | « tests/standalone/io/signal_test_script.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698