Skip to content

Commit

Permalink
Fix for no inputs in build mode.
Browse files Browse the repository at this point in the history
[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]>
  • Loading branch information
scheglov authored and [email protected] committed Jul 9, 2020
1 parent dfdc7e4 commit 0a5e69a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 18 deletions.
4 changes: 4 additions & 0 deletions pkg/analyzer_cli/lib/src/build_mode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,10 @@ class BuildMode with HasContextMixin {
}

void _setAnalysisDriverAnalysisContext(String rootPath) {
if (rootPath == null) {
return;
}

var apiContextRoots = api.ContextLocator(
resourceProvider: resourceProvider,
).locateRoots(
Expand Down
55 changes: 37 additions & 18 deletions pkg/analyzer_cli/test/driver_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ void main() {
}

class AbstractBuildModeTest extends BaseTest {
List<String> get _sdkSummaryArguments {
var sdkPath = path.dirname(
path.dirname(
Platform.resolvedExecutable,
),
);

var dartSdkSummaryPath = path.join(
sdkPath,
'lib',
'_internal',
'strong.sum',
);

return ['--dart-sdk-summary', dartSdkSummaryPath];
}

Future<void> _doDrive(
String filePath, {
String sourceArgument,
Expand All @@ -54,24 +71,7 @@ class AbstractBuildModeTest extends BaseTest {
args.add('--build-mode');
args.add('--format=machine');

{
var sdkPath = path.dirname(
path.dirname(
Platform.resolvedExecutable,
),
);

var dartSdkSummaryPath = path.join(
sdkPath,
'lib',
'_internal',
'strong.sum',
);

args.add('--dart-sdk-summary');
args.add(dartSdkSummaryPath);
}

args.addAll(_sdkSummaryArguments);
args.addAll(additionalArgs);

if (sourceArgument == null) {
Expand Down Expand Up @@ -587,6 +587,25 @@ var b = new B();
expect(exitCode, isNot(0));
}

Future<void> test_noInputs() async {
await withTempDirAsync((tempDir) async {
var outputPath = path.join(tempDir, 'test.sum');

await driveMany([], args: [
'--build-mode',
'--format=machine',
..._sdkSummaryArguments,
'--build-summary-only',
'--build-summary-output=$outputPath',
]);

var output = File(outputPath);
expect(output.existsSync(), isTrue);

expect(exitCode, 0);
});
}

Future<void> test_noStatistics() async {
await _doDrive(path.join('data', 'test_file.dart'));
// Should not print statistics summary.
Expand Down

0 comments on commit 0a5e69a

Please sign in to comment.