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

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

Issue 2993683002: Fix flake in code_collection_test. (Closed)
Patch Set: . Created 3 years, 4 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
« no previous file with comments | « no previous file | 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 // 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 19 matching lines...) Expand all
30 var t = new Timer.periodic(ms, (timer) { 30 var t = new Timer.periodic(ms, (timer) {
31 i++; 31 i++;
32 // Calling bar will trigger GC without foo being on the stack. This way 32 // Calling bar will trigger GC without foo being on the stack. This way
33 // the method can be collected. 33 // the method can be collected.
34 bar(); 34 bar();
35 if (i > 1) { 35 if (i > 1) {
36 timer.cancel(); 36 timer.cancel();
37 // foo is called again to make sure we can still run it even after 37 // foo is called again to make sure we can still run it even after
38 // its code has been detached. 38 // its code has been detached.
39 var ret = foo(2); 39 var ret = foo(2);
40 // GC after here may collect the second compilation of foo.
40 } 41 }
41 }); 42 });
42 } 43 }
43 44
44 List<String> packageOptions() { 45 List<String> packageOptions() {
45 if (Platform.packageRoot != null) { 46 if (Platform.packageRoot != null) {
46 return <String>['--package-root=${Platform.packageRoot}']; 47 return <String>['--package-root=${Platform.packageRoot}'];
47 } else if (Platform.packageConfig != null) { 48 } else if (Platform.packageConfig != null) {
48 return <String>['--packages=${Platform.packageConfig}']; 49 return <String>['--packages=${Platform.packageConfig}'];
49 } else { 50 } else {
(...skipping 17 matching lines...) Expand all
67 Platform.script.toFilePath(), 68 Platform.script.toFilePath(),
68 "--run" 69 "--run"
69 ]); 70 ]);
70 var pr = Process.runSync(Platform.executable, args); 71 var pr = Process.runSync(Platform.executable, args);
71 72
72 Expect.equals(0, pr.exitCode); 73 Expect.equals(0, pr.exitCode);
73 74
74 // Code drops are logged with --log-code-drop. Look through stdout for the 75 // Code drops are logged with --log-code-drop. Look through stdout for the
75 // message that foo's code was dropped. 76 // message that foo's code was dropped.
76 print(pr.stdout); 77 print(pr.stdout);
77 var count = 0; 78 bool saw_foo2 = false;
79 bool saw_detaching_foo = false;
80 bool saw_foo3 = false;
78 pr.stdout.split("\n").forEach((line) { 81 pr.stdout.split("\n").forEach((line) {
79 if (line.contains("foo=2")) { 82 if (line.contains("foo=2")) {
80 Expect.equals(0, count); 83 Expect.isFalse(saw_foo2, "foo=2 ran twice");
81 count++; 84 saw_foo2 = true;
82 } 85 }
83 if (line.contains("Detaching code") && line.contains("foo")) { 86 if (line.contains("Detaching code") && line.contains("foo")) {
84 Expect.equals(1, count); 87 Expect.isTrue(saw_foo2, "foo detached before running");
85 count++; 88 // May detach twice.
89 saw_detaching_foo = true;
86 } 90 }
87 if (line.contains("foo=3")) { 91 if (line.contains("foo=3")) {
88 Expect.equals(2, count); 92 Expect.isFalse(saw_foo3, "foo=3 ran twice");
89 count++; 93 Expect.isTrue(saw_detaching_foo, "foo should have been collected");
94 saw_foo3 = true;
90 } 95 }
91 }); 96 });
92 Expect.equals(3, count); 97
98 Expect.isTrue(saw_foo2, "Missing foo=2");
99 Expect.isTrue(saw_detaching_foo, "Missing code collection for foo");
100 Expect.isTrue(saw_foo3, "Missing foo=3");
93 } 101 }
94 } 102 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698