Skip to content

Commit 0a5e69a

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Fix for no inputs in build mode.
[email protected] Bug: https://buganizer.corp.google.com/issues/160854685 Change-Id: I9dd7f6e6c8293432c39d2d0cdd28bcd06880bf8e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153940 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent dfdc7e4 commit 0a5e69a

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

pkg/analyzer_cli/lib/src/build_mode.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,10 @@ class BuildMode with HasContextMixin {
547547
}
548548

549549
void _setAnalysisDriverAnalysisContext(String rootPath) {
550+
if (rootPath == null) {
551+
return;
552+
}
553+
550554
var apiContextRoots = api.ContextLocator(
551555
resourceProvider: resourceProvider,
552556
).locateRoots(

pkg/analyzer_cli/test/driver_test.dart

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ void main() {
3838
}
3939

4040
class AbstractBuildModeTest extends BaseTest {
41+
List<String> get _sdkSummaryArguments {
42+
var sdkPath = path.dirname(
43+
path.dirname(
44+
Platform.resolvedExecutable,
45+
),
46+
);
47+
48+
var dartSdkSummaryPath = path.join(
49+
sdkPath,
50+
'lib',
51+
'_internal',
52+
'strong.sum',
53+
);
54+
55+
return ['--dart-sdk-summary', dartSdkSummaryPath];
56+
}
57+
4158
Future<void> _doDrive(
4259
String filePath, {
4360
String sourceArgument,
@@ -54,24 +71,7 @@ class AbstractBuildModeTest extends BaseTest {
5471
args.add('--build-mode');
5572
args.add('--format=machine');
5673

57-
{
58-
var sdkPath = path.dirname(
59-
path.dirname(
60-
Platform.resolvedExecutable,
61-
),
62-
);
63-
64-
var dartSdkSummaryPath = path.join(
65-
sdkPath,
66-
'lib',
67-
'_internal',
68-
'strong.sum',
69-
);
70-
71-
args.add('--dart-sdk-summary');
72-
args.add(dartSdkSummaryPath);
73-
}
74-
74+
args.addAll(_sdkSummaryArguments);
7575
args.addAll(additionalArgs);
7676

7777
if (sourceArgument == null) {
@@ -587,6 +587,25 @@ var b = new B();
587587
expect(exitCode, isNot(0));
588588
}
589589

590+
Future<void> test_noInputs() async {
591+
await withTempDirAsync((tempDir) async {
592+
var outputPath = path.join(tempDir, 'test.sum');
593+
594+
await driveMany([], args: [
595+
'--build-mode',
596+
'--format=machine',
597+
..._sdkSummaryArguments,
598+
'--build-summary-only',
599+
'--build-summary-output=$outputPath',
600+
]);
601+
602+
var output = File(outputPath);
603+
expect(output.existsSync(), isTrue);
604+
605+
expect(exitCode, 0);
606+
});
607+
}
608+
590609
Future<void> test_noStatistics() async {
591610
await _doDrive(path.join('data', 'test_file.dart'));
592611
// Should not print statistics summary.

0 commit comments

Comments
 (0)