Skip to content

Commit 37b6a8c

Browse files
jensjohaCommit Queue
authored andcommitted
[CFE] Fix timeout on crash in dartdoctest
The test uses the incremental compiler, and saves the previous one to avoid compiling more than it has to. If a compile crashes though, the incremental compiler will be left in a state where it thinks it's currently compiling, and will have to wait for the previous compile to finish. As it had crashed it won't, and we'll thus get a timeout on the bot. Here it's fixed by only saving it for next time once we're done. Change-Id: I20a5ab20438a125487a95147e7a092f2129796a4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373501 Commit-Queue: Jens Johansen <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent 217cabd commit 37b6a8c

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

pkg/front_end/tool/dart_doctest_impl.dart

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const _portMessageDone = "done";
6161
// the part declares what file it's part of and if we've compiled other stuff
6262
// first so we know more stuff).
6363
class DartDocTest {
64-
DocTestIncrementalCompiler? incrementalCompiler;
64+
DocTestIncrementalCompiler? savedIncrementalCompiler;
6565
late CompilerOptions options;
6666
late ProcessedOptions processedOpts;
6767
bool errors = false;
@@ -132,9 +132,12 @@ class DartDocTest {
132132
sb.writeln("}");
133133
}
134134

135-
if (incrementalCompiler == null) {
136-
setupIncrementalCompiler(uri);
137-
}
135+
// Setup the incremental compiler.
136+
// We only want to reuse it if it didn't crash as that will make it wait
137+
// for the crashed compile to finish (and it won't).
138+
DocTestIncrementalCompiler incrementalCompiler =
139+
savedIncrementalCompiler ?? createIncrementalCompiler(uri);
140+
savedIncrementalCompiler = null;
138141

139142
processedOpts.inputs.clear();
140143
processedOpts.inputs.add(uri);
@@ -145,11 +148,11 @@ class DartDocTest {
145148
processedOpts.clearFileSystemCache();
146149
// Invalidate package uri to force re-finding of packages
147150
// (e.g. if we're now compiling somewhere else).
148-
incrementalCompiler!.invalidate(processedOpts.packagesUri);
151+
incrementalCompiler.invalidate(processedOpts.packagesUri);
149152

150153
Stopwatch stopwatch = new Stopwatch()..start();
151154
IncrementalCompilerResult compilerResult =
152-
await incrementalCompiler!.computeDelta(entryPoints: [uri]);
155+
await incrementalCompiler.computeDelta(entryPoints: [uri]);
153156
kernel.Component component = compilerResult.component;
154157
if (errors) {
155158
_print("Got errors in ${stopwatch.elapsedMilliseconds} ms.");
@@ -161,16 +164,16 @@ class DartDocTest {
161164
_print("Compiled (1) in ${stopwatch.elapsedMilliseconds} ms.");
162165
stopwatch.reset();
163166

164-
await incrementalCompiler!.compileDartDocTestLibrary(
167+
await incrementalCompiler.compileDartDocTestLibrary(
165168
sb.toString(), component.uriToSource[uri]?.importUri ?? uri);
166169

167170
final Uri dartDocMainUri = new Uri(scheme: "dartdoctest", path: "main");
168171
fileSystem.memory
169172
.entityForUri(dartDocMainUri)
170173
.writeAsStringSync(mainFileContent);
171174

172-
incrementalCompiler!.invalidate(dartDocMainUri);
173-
IncrementalCompilerResult compilerMainResult = await incrementalCompiler!
175+
incrementalCompiler.invalidate(dartDocMainUri);
176+
IncrementalCompilerResult compilerMainResult = await incrementalCompiler
174177
.computeDelta(entryPoints: [dartDocMainUri], fullComponent: true);
175178
kernel.Component componentMain = compilerMainResult.component;
176179
if (errors) {
@@ -270,6 +273,9 @@ class DartDocTest {
270273
await completer.future;
271274
tmpDir.deleteSync(recursive: true);
272275

276+
// We finished successfully. Save the incremental compiler.
277+
savedIncrementalCompiler = incrementalCompiler;
278+
273279
if (error) {
274280
_print("Completed with an error in ${stopwatch.elapsedMilliseconds} ms.");
275281
return [new TestResult(null, TestOutcome.RuntimeError)];
@@ -300,7 +306,7 @@ class DartDocTest {
300306
}
301307
}
302308

303-
void setupIncrementalCompiler(Uri uri) {
309+
DocTestIncrementalCompiler createIncrementalCompiler(Uri uri) {
304310
options = getOptions();
305311
TargetFlags targetFlags = new TargetFlags();
306312
// TODO: Target could possible be something else...
@@ -318,7 +324,7 @@ class DartDocTest {
318324
};
319325
processedOpts = new ProcessedOptions(options: options, inputs: [uri]);
320326
CompilerContext compilerContext = new CompilerContext(processedOpts);
321-
this.incrementalCompiler = new DocTestIncrementalCompiler(compilerContext);
327+
return new DocTestIncrementalCompiler(compilerContext);
322328
}
323329
}
324330

0 commit comments

Comments
 (0)