OLD | NEW |
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 // Dart test program testing code GC. | 5 // Dart test program testing code GC. |
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 |
(...skipping 22 matching lines...) Expand all Loading... |
33 if (i > 1) { | 33 if (i > 1) { |
34 timer.cancel(); | 34 timer.cancel(); |
35 // foo is called again to make sure we can still run it even after | 35 // foo is called again to make sure we can still run it even after |
36 // its code has been detached. | 36 // its code has been detached. |
37 foo(2); | 37 foo(2); |
38 } | 38 } |
39 }); | 39 }); |
40 } | 40 } |
41 | 41 |
42 | 42 |
43 main() { | 43 main(List<String> arguments) { |
44 var opts = new Options(); | 44 if (arguments.contains("--run")) { |
45 if (opts.arguments.contains("--run")) { | |
46 doTest(); | 45 doTest(); |
47 } else { | 46 } else { |
48 // Run the test and capture stdout. | 47 // Run the test and capture stdout. |
49 var pr = Process.runSync(Platform.executable, | 48 var pr = Process.runSync(Platform.executable, |
50 ["--collect-code", | 49 ["--collect-code", |
51 "--code-collection-interval-in-us=100000", | 50 "--code-collection-interval-in-us=100000", |
52 "--log-code-drop", | 51 "--log-code-drop", |
53 "--optimization-counter-threshold=-1", | 52 "--optimization-counter-threshold=-1", |
54 "--package-root=${Platform.packageRoot}", | 53 "--package-root=${Platform.packageRoot}", |
55 Platform.script, | 54 Platform.script, |
56 "--run"]); | 55 "--run"]); |
57 | 56 |
58 // Code drops are logged with --log-code-drop. Look through stdout for the | 57 // Code drops are logged with --log-code-drop. Look through stdout for the |
59 // message that foo's code was dropped. | 58 // message that foo's code was dropped. |
60 var found = false; | 59 var found = false; |
61 pr.stdout.split("\n").forEach((line) { | 60 pr.stdout.split("\n").forEach((line) { |
62 if (line.contains("Detaching code") && line.contains("foo")) { | 61 if (line.contains("Detaching code") && line.contains("foo")) { |
63 found = true; | 62 found = true; |
64 } | 63 } |
65 }); | 64 }); |
66 Expect.isTrue(found); | 65 Expect.isTrue(found); |
67 } | 66 } |
68 } | 67 } |
OLD | NEW |