| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // Windows doesn't support sending signals. | 5 // Windows doesn't support sending signals. |
| 6 @TestOn("vm && !windows") | 6 @TestOn("vm && !windows") |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 group("during test running", () { | 76 group("during test running", () { |
| 77 test("waits for a VM test to finish running", () { | 77 test("waits for a VM test to finish running", () { |
| 78 d.file("test.dart", """ | 78 d.file("test.dart", """ |
| 79 import 'dart:async'; | 79 import 'dart:async'; |
| 80 import 'dart:io'; | 80 import 'dart:io'; |
| 81 | 81 |
| 82 import 'package:test/test.dart'; | 82 import 'package:test/test.dart'; |
| 83 | 83 |
| 84 void main() { | 84 void main() { |
| 85 tearDown(() => new File("output").writeAsStringSync("ran teardown")); | 85 tearDownAll(() { |
| 86 new File("output_all").writeAsStringSync("ran tearDownAll"); |
| 87 }); |
| 88 |
| 89 tearDown(() => new File("output").writeAsStringSync("ran tearDown")); |
| 86 | 90 |
| 87 test("test", () { | 91 test("test", () { |
| 88 print("running test"); | 92 print("running test"); |
| 89 return new Future.delayed(new Duration(seconds: 1)); | 93 return new Future.delayed(new Duration(seconds: 1)); |
| 90 }); | 94 }); |
| 91 } | 95 } |
| 92 """).create(); | 96 """).create(); |
| 93 | 97 |
| 94 var test = _runTest(["test.dart"]); | 98 var test = _runTest(["test.dart"]); |
| 95 test.stdout.expect(consumeThrough("running test")); | 99 test.stdout.expect(consumeThrough("running test")); |
| 96 signalAndQuit(test); | 100 signalAndQuit(test); |
| 97 | 101 |
| 98 d.file("output", "ran teardown").validate(); | 102 d.file("output", "ran tearDown").validate(); |
| 103 d.file("output_all", "ran tearDownAll").validate(); |
| 99 expectTempDirEmpty(); | 104 expectTempDirEmpty(); |
| 100 }); | 105 }); |
| 101 | 106 |
| 107 test("waits for an active tearDownAll to finish running", () { |
| 108 d.file("test.dart", """ |
| 109 import 'dart:async'; |
| 110 import 'dart:io'; |
| 111 |
| 112 import 'package:test/test.dart'; |
| 113 |
| 114 void main() { |
| 115 tearDownAll(() async { |
| 116 print("running tearDownAll"); |
| 117 await new Future.delayed(new Duration(seconds: 1)); |
| 118 new File("output").writeAsStringSync("ran tearDownAll"); |
| 119 }); |
| 120 |
| 121 test("test", () {}); |
| 122 } |
| 123 """).create(); |
| 124 |
| 125 var test = _runTest(["test.dart"]); |
| 126 test.stdout.expect(consumeThrough("running tearDownAll")); |
| 127 signalAndQuit(test); |
| 128 |
| 129 d.file("output", "ran tearDownAll").validate(); |
| 130 expectTempDirEmpty(); |
| 131 }); |
| 132 |
| 102 test("kills a browser test immediately", () { | 133 test("kills a browser test immediately", () { |
| 103 d.file("test.dart", """ | 134 d.file("test.dart", """ |
| 104 import 'dart:async'; | 135 import 'dart:async'; |
| 105 | 136 |
| 106 import 'package:test/test.dart'; | 137 import 'package:test/test.dart'; |
| 107 | 138 |
| 108 void main() { | 139 void main() { |
| 109 test("test", () { | 140 test("test", () { |
| 110 print("running test"); | 141 print("running test"); |
| 111 | 142 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 257 |
| 227 void signalAndQuit(ScheduledProcess test) { | 258 void signalAndQuit(ScheduledProcess test) { |
| 228 test.signal(ProcessSignal.SIGTERM); | 259 test.signal(ProcessSignal.SIGTERM); |
| 229 test.shouldExit(); | 260 test.shouldExit(); |
| 230 test.stderr.expect(isDone); | 261 test.stderr.expect(isDone); |
| 231 } | 262 } |
| 232 | 263 |
| 233 void expectTempDirEmpty() { | 264 void expectTempDirEmpty() { |
| 234 schedule(() => expect(new Directory(_tempDir).listSync(), isEmpty)); | 265 schedule(() => expect(new Directory(_tempDir).listSync(), isEmpty)); |
| 235 } | 266 } |
| OLD | NEW |