Chromium Code Reviews| 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 24 matching lines...) Expand all Loading... | |
| 35 timer.cancel(); | 35 timer.cancel(); |
| 36 // foo is called again to make sure we can still run it even after | 36 // foo is called again to make sure we can still run it even after |
| 37 // its code has been detached. | 37 // its code has been detached. |
| 38 var ret = foo(2); | 38 var ret = foo(2); |
| 39 print("foo=$ret"); | 39 print("foo=$ret"); |
| 40 } | 40 } |
| 41 }); | 41 }); |
| 42 } | 42 } |
| 43 | 43 |
| 44 | 44 |
| 45 main(List<String> arguments) { | 45 main(List<String> arguments) async { |
| 46 if (arguments.contains("--run")) { | 46 if (arguments.contains("--run")) { |
| 47 doTest(); | 47 doTest(); |
| 48 } else { | 48 } else { |
|
Lasse Reichstein Nielsen
2015/09/22 09:48:25
Add TODO: support .packages.
| |
| 49 // Run the test and capture stdout. | 49 // Run the test and capture stdout. |
| 50 var packageRoot = await Platform.packageRoot; | |
| 50 var pr = Process.runSync(Platform.executable, | 51 var pr = Process.runSync(Platform.executable, |
| 51 ["--collect-code", | 52 ["--collect-code", |
| 52 "--code-collection-interval-in-us=0", | 53 "--code-collection-interval-in-us=0", |
| 53 "--old_gen_growth_rate=10", | 54 "--old_gen_growth_rate=10", |
| 54 "--log-code-drop", | 55 "--log-code-drop", |
| 55 "--optimization-counter-threshold=-1", | 56 "--optimization-counter-threshold=-1", |
| 56 "--package-root=${Platform.packageRoot}", | 57 "--package-root=$packageRoot", |
| 57 Platform.script.toFilePath(), | 58 Platform.script.toFilePath(), |
| 58 "--run"]); | 59 "--run"]); |
| 59 | 60 |
| 60 Expect.equals(0, pr.exitCode); | 61 Expect.equals(0, pr.exitCode); |
| 61 | 62 |
| 62 // Code drops are logged with --log-code-drop. Look through stdout for the | 63 // Code drops are logged with --log-code-drop. Look through stdout for the |
| 63 // message that foo's code was dropped. | 64 // message that foo's code was dropped. |
| 64 var count = 0; | 65 var count = 0; |
| 65 pr.stdout.split("\n").forEach((line) { | 66 pr.stdout.split("\n").forEach((line) { |
| 66 if (line.contains("foo=2")) { | 67 if (line.contains("foo=2")) { |
| 67 Expect.equals(0, count); | 68 Expect.equals(0, count); |
| 68 count++; | 69 count++; |
| 69 } | 70 } |
| 70 if (line.contains("Detaching code") && line.contains("foo")) { | 71 if (line.contains("Detaching code") && line.contains("foo")) { |
| 71 Expect.equals(1, count); | 72 Expect.equals(1, count); |
| 72 count++; | 73 count++; |
| 73 } | 74 } |
| 74 if (line.contains("foo=3")) { | 75 if (line.contains("foo=3")) { |
| 75 Expect.equals(2, count); | 76 Expect.equals(2, count); |
| 76 count++; | 77 count++; |
| 77 } | 78 } |
| 78 }); | 79 }); |
| 79 Expect.equals(3, count); | 80 Expect.equals(3, count); |
| 80 } | 81 } |
| 81 } | 82 } |
| OLD | NEW |