[ CLI ] Add additional logging to create_integration_test

We've seen runtime errors due to non-zero exit codes when running this
suite of tests, but it's difficult to tell at which command we've
failed. This adds logging to help narrow down which command is causing
the issues.

Related issue: https://github.com/dart-lang/sdk/issues/48992

Change-Id: Ice0ff2ef87c806d108e907bcac84e5cc09b176f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244366
Reviewed-by: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Ben Konyi 2022-05-11 15:54:48 +00:00
parent b4ed709482
commit cae2f4e874

View file

@ -33,6 +33,7 @@ void defineCreateTests() {
final p = proj!; final p = proj!;
final templateGenerator = getGenerator(templateId)!; final templateGenerator = getGenerator(templateId)!;
print('$templateId: creating template');
ProcessResult createResult = await p.run([ ProcessResult createResult = await p.run([
'create', 'create',
'--force', '--force',
@ -43,6 +44,7 @@ void defineCreateTests() {
expect(createResult.exitCode, 0, reason: createResult.stderr); expect(createResult.exitCode, 0, reason: createResult.stderr);
// Validate that the project analyzes cleanly. // Validate that the project analyzes cleanly.
print('$templateId: analyzing generated project');
ProcessResult analyzeResult = await p.run( ProcessResult analyzeResult = await p.run(
['analyze', '--fatal-infos', projectName], ['analyze', '--fatal-infos', projectName],
workingDir: p.dir.path, workingDir: p.dir.path,
@ -50,6 +52,7 @@ void defineCreateTests() {
expect(analyzeResult.exitCode, 0, reason: analyzeResult.stdout); expect(analyzeResult.exitCode, 0, reason: analyzeResult.stdout);
// Validate that the code is well formatted. // Validate that the code is well formatted.
print('$templateId: checking formatting');
ProcessResult formatResult = await p.run([ ProcessResult formatResult = await p.run([
'format', 'format',
'--output', '--output',
@ -77,6 +80,11 @@ void defineCreateTests() {
return commandParts; return commandParts;
}).toList(); }).toList();
print('$templateId: running the following commands:');
for (final command in runCommands) {
print(' $e');
}
final isServerTemplate = templateGenerator.categories.contains('server'); final isServerTemplate = templateGenerator.categories.contains('server');
final isWebTemplate = templateGenerator.categories.contains('web'); final isWebTemplate = templateGenerator.categories.contains('web');
final workingDir = path.join(p.dirPath, projectName); final workingDir = path.join(p.dirPath, projectName);
@ -88,7 +96,7 @@ void defineCreateTests() {
final isLastCommand = i == runCommands.length - 1; final isLastCommand = i == runCommands.length - 1;
final command = runCommands[i]; final command = runCommands[i];
Process process; Process process;
print('[${i + 1} / ${runCommands.length}] Running "$command"...');
if (isLastCommand && isWebTemplate) { if (isLastCommand && isWebTemplate) {
// The web template uses `webdev` to execute, not `dart`, so don't // The web template uses `webdev` to execute, not `dart`, so don't
// run the test through the project utility method. // run the test through the project utility method.
@ -148,6 +156,7 @@ void defineCreateTests() {
// an exit code of 0. // an exit code of 0.
expect(await process.exitCode, 0); expect(await process.exitCode, 0);
} }
print('[${i + 1} / ${runCommands.length}] Done "$command".');
} }
}); });
} }