mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
Enforce await_only_futures and fix violations (in more packages).
Change-Id: I1812f7721915178e42956f988b9276bf8db0bfaa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164281 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
a36d17730a
commit
d219bde703
|
@ -15,6 +15,7 @@ analyzer:
|
|||
|
||||
linter:
|
||||
rules:
|
||||
- await_only_futures
|
||||
- empty_statements
|
||||
- unnecessary_brace_in_string_interps
|
||||
#
|
||||
|
|
|
@ -561,7 +561,7 @@ class EditDomainHandler extends AbstractRequestHandler {
|
|||
}
|
||||
|
||||
// Prepare the file information.
|
||||
var result = await server.getParsedUnit(file);
|
||||
var result = server.getParsedUnit(file);
|
||||
if (result == null) {
|
||||
server.sendResponse(Response.fileNotAnalyzed(request, file));
|
||||
return;
|
||||
|
|
|
@ -28,7 +28,7 @@ mixin FixCodeProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
void processPackage(Folder pkgFolder) async {
|
||||
Future<void> processPackage(Folder pkgFolder) async {
|
||||
for (var task in _codeTasks) {
|
||||
await task.processPackage(pkgFolder);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class AddLate extends CorrectionProducer {
|
|||
}
|
||||
}
|
||||
|
||||
void _insertAt(ChangeBuilder builder, int offset) async {
|
||||
Future<void> _insertAt(ChangeBuilder builder, int offset) async {
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
builder.addSimpleInsertion(offset, 'late ');
|
||||
});
|
||||
|
|
|
@ -21,7 +21,7 @@ class RemoveAnnotation extends CorrectionProducer {
|
|||
|
||||
@override
|
||||
Future<void> compute(ChangeBuilder builder) async {
|
||||
void addFix(Annotation node) async {
|
||||
Future<void> addFix(Annotation node) async {
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ class AnalysisOptionsFixGenerator {
|
|||
return fixes;
|
||||
}
|
||||
|
||||
void _addFix_removeSetting() async {
|
||||
Future<void> _addFix_removeSetting() async {
|
||||
if (coveringNodePath[0] is YamlScalar) {
|
||||
SourceRange deletionRange;
|
||||
var index = 1;
|
||||
|
|
|
@ -754,7 +754,7 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
|
|||
}
|
||||
|
||||
Future<void> _initializeReturnType() async {
|
||||
var typeProvider = await resolveResult.typeProvider;
|
||||
var typeProvider = resolveResult.typeProvider;
|
||||
if (_selectionFunctionExpression != null) {
|
||||
variableType = '';
|
||||
returnType = '';
|
||||
|
|
|
@ -391,7 +391,7 @@ class ContentsPage extends DiagnosticPageWithNav {
|
|||
raw: true);
|
||||
return;
|
||||
}
|
||||
var file = await server.resourceProvider.getFile(filePath);
|
||||
var file = server.resourceProvider.getFile(filePath);
|
||||
if (!file.exists) {
|
||||
p('The file <code>${escape(filePath)}</code> does not exist.', raw: true);
|
||||
return;
|
||||
|
|
|
@ -203,7 +203,7 @@ transforms:
|
|||
|
||||
// Add to priority files and give chance for the file to be analyzed (if
|
||||
// it would).
|
||||
await setPriorityFiles([brokenFile]);
|
||||
setPriorityFiles([brokenFile]);
|
||||
await waitForTasksFinished();
|
||||
await pumpEventQueue(times: 5000);
|
||||
|
||||
|
|
|
@ -866,12 +866,12 @@ class CompletionDomainHandlerListTokenDetailsTest
|
|||
extends AbstractCompletionDomainTest {
|
||||
String testFileUri;
|
||||
|
||||
void expectTokens(String content, List<TokenDetails> expectedTokens) async {
|
||||
Future<void> expectTokens(String content, List<TokenDetails> expected) async {
|
||||
newFile(testFile, content: content);
|
||||
var request = CompletionListTokenDetailsParams(testFile).toRequest('0');
|
||||
var response = await waitResponse(request);
|
||||
List<Map<String, dynamic>> tokens = response.result['tokens'];
|
||||
_compareTokens(tokens, expectedTokens);
|
||||
_compareTokens(tokens, expected);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -171,7 +171,7 @@ void f() {
|
|||
|
||||
// Deleting the file should result in an update to remove the diagnostics.
|
||||
final secondDiagnosticsUpdate = waitForDiagnostics(mainFileUri);
|
||||
await deleteFile(mainFilePath);
|
||||
deleteFile(mainFilePath);
|
||||
final updatedDiagnostics = await secondDiagnosticsUpdate;
|
||||
expect(updatedDiagnostics, hasLength(0));
|
||||
}
|
||||
|
|
|
@ -74,10 +74,10 @@ void main() {
|
|||
final payload = '{ json payload }';
|
||||
final lspPacket =
|
||||
makeLspPacket(payload, 'application/vscode-jsonrpc; charset=ascii');
|
||||
final outputStream = await Stream.fromIterable([lspPacket])
|
||||
.transform(LspPacketTransformer());
|
||||
final outputStream =
|
||||
Stream.fromIterable([lspPacket]).transform(LspPacketTransformer());
|
||||
|
||||
expectLater(outputStream.toList(),
|
||||
await expectLater(outputStream.toList(),
|
||||
throwsA(const TypeMatcher<InvalidEncodingError>()));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -50,7 +50,7 @@ class A {
|
|||
var f = 0;
|
||||
}
|
||||
''');
|
||||
await await assertHasAssistAt('var ', '''
|
||||
await assertHasAssistAt('var ', '''
|
||||
class A {
|
||||
int f = 0;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ abstract class FixProcessorTest extends AbstractSingleUnitTest {
|
|||
expect(resultCode, expected);
|
||||
}
|
||||
|
||||
void assertHasFixAllFix(ErrorCode errorCode, String expected,
|
||||
Future<void> assertHasFixAllFix(ErrorCode errorCode, String expected,
|
||||
{String target}) async {
|
||||
if (useLineEndingsForPlatform) {
|
||||
expected = normalizeNewlinesForPlatform(expected);
|
||||
|
|
|
@ -1356,7 +1356,7 @@ class CodeShapeMetricsComputer {
|
|||
CodeShapeMetricsComputer();
|
||||
|
||||
/// Compute the metrics for the file(s) in the [rootPath].
|
||||
void compute(String rootPath) async {
|
||||
Future<void> compute(String rootPath) async {
|
||||
final collection = AnalysisContextCollection(
|
||||
includedPaths: [rootPath],
|
||||
resourceProvider: PhysicalResourceProvider.INSTANCE,
|
||||
|
@ -1380,7 +1380,7 @@ class CodeShapeMetricsComputer {
|
|||
/// separate context collection to prevent accumulating memory. The metrics
|
||||
/// should be captured in the [collector]. Include additional details in the
|
||||
/// output if [verbose] is `true`.
|
||||
void _computeInContext(
|
||||
Future<void> _computeInContext(
|
||||
ContextRoot root, CodeShapeDataCollector collector) async {
|
||||
// Create a new collection to avoid consuming large quantities of memory.
|
||||
final collection = AnalysisContextCollection(
|
||||
|
|
|
@ -172,7 +172,7 @@ class FlutterMetricsComputer {
|
|||
FlutterMetricsComputer();
|
||||
|
||||
/// Compute the metrics for the file(s) in the [rootPath].
|
||||
void compute(String rootPath) async {
|
||||
Future<void> compute(String rootPath) async {
|
||||
final collection = AnalysisContextCollection(
|
||||
includedPaths: [rootPath],
|
||||
resourceProvider: PhysicalResourceProvider.INSTANCE,
|
||||
|
|
|
@ -139,7 +139,7 @@ class ImpliedTypeComputer {
|
|||
/// Compute the metrics for the file(s) in the [rootPath].
|
||||
/// If [corpus] is true, treat rootPath as a container of packages, creating
|
||||
/// a new context collection for each subdirectory.
|
||||
void compute(String rootPath, {@required bool verbose}) async {
|
||||
Future<void> compute(String rootPath, {@required bool verbose}) async {
|
||||
final collection = AnalysisContextCollection(
|
||||
includedPaths: [rootPath],
|
||||
resourceProvider: PhysicalResourceProvider.INSTANCE,
|
||||
|
@ -170,7 +170,8 @@ class ImpliedTypeComputer {
|
|||
/// separate context collection to prevent accumulating memory. The metrics
|
||||
/// should be captured in the [collector]. Include additional details in the
|
||||
/// output if [verbose] is `true`.
|
||||
void _computeInContext(ContextRoot root, ImpliedTypeCollector collector,
|
||||
Future<void> _computeInContext(
|
||||
ContextRoot root, ImpliedTypeCollector collector,
|
||||
{@required bool verbose}) async {
|
||||
// Create a new collection to avoid consuming large quantities of memory.
|
||||
final collection = AnalysisContextCollection(
|
||||
|
|
|
@ -1869,7 +1869,7 @@ class RelevanceMetricsComputer {
|
|||
/// Compute the metrics for the file(s) in the [rootPath].
|
||||
/// If [corpus] is true, treat rootPath as a container of packages, creating
|
||||
/// a new context collection for each subdirectory.
|
||||
void compute(String rootPath, {@required bool verbose}) async {
|
||||
Future<void> compute(String rootPath, {@required bool verbose}) async {
|
||||
final collection = AnalysisContextCollection(
|
||||
includedPaths: [rootPath],
|
||||
resourceProvider: PhysicalResourceProvider.INSTANCE,
|
||||
|
@ -1929,7 +1929,8 @@ class RelevanceMetricsComputer {
|
|||
/// separate context collection to prevent accumulating memory. The metrics
|
||||
/// should be captured in the [collector]. Include additional details in the
|
||||
/// output if [verbose] is `true`.
|
||||
void _computeInContext(ContextRoot root, RelevanceDataCollector collector,
|
||||
Future<void> _computeInContext(
|
||||
ContextRoot root, RelevanceDataCollector collector,
|
||||
{@required bool verbose}) async {
|
||||
// Create a new collection to avoid consuming large quantities of memory.
|
||||
final collection = AnalysisContextCollection(
|
||||
|
|
|
@ -1350,7 +1350,7 @@ class RelevanceMetricsComputer {
|
|||
/// Compute the metrics for the file(s) in the [rootPath].
|
||||
/// If [corpus] is true, treat rootPath as a container of packages, creating
|
||||
/// a new context collection for each subdirectory.
|
||||
void compute(String rootPath, {@required bool verbose}) async {
|
||||
Future<void> compute(String rootPath, {@required bool verbose}) async {
|
||||
final collection = AnalysisContextCollection(
|
||||
includedPaths: [rootPath],
|
||||
resourceProvider: PhysicalResourceProvider.INSTANCE,
|
||||
|
@ -1365,7 +1365,8 @@ class RelevanceMetricsComputer {
|
|||
/// separate context collection to prevent accumulating memory. The metrics
|
||||
/// should be captured in the [collector]. Include additional details in the
|
||||
/// output if [verbose] is `true`.
|
||||
void _computeInContext(ContextRoot root, RelevanceDataCollector collector,
|
||||
Future<void> _computeInContext(
|
||||
ContextRoot root, RelevanceDataCollector collector,
|
||||
{@required bool verbose}) async {
|
||||
// Create a new collection to avoid consuming large quantities of memory.
|
||||
final collection = AnalysisContextCollection(
|
||||
|
|
|
@ -4,6 +4,7 @@ analyzer:
|
|||
|
||||
linter:
|
||||
rules:
|
||||
- await_only_futures
|
||||
- empty_statements
|
||||
- unnecessary_brace_in_string_interps
|
||||
#
|
||||
|
|
|
@ -14,6 +14,7 @@ linter:
|
|||
rules:
|
||||
- avoid_single_cascade_in_expression_statements
|
||||
- avoid_unused_constructor_parameters
|
||||
- await_only_futures
|
||||
- empty_statements
|
||||
- iterable_contains_unrelated_type
|
||||
- list_remove_unrelated_type
|
||||
|
|
|
@ -3,6 +3,7 @@ analyzer:
|
|||
implicit-casts: false
|
||||
linter:
|
||||
rules:
|
||||
- await_only_futures
|
||||
- empty_statements
|
||||
- unnecessary_brace_in_string_interps
|
||||
#
|
||||
|
|
|
@ -16,6 +16,7 @@ analyzer:
|
|||
|
||||
linter:
|
||||
rules:
|
||||
- await_only_futures
|
||||
- directives_ordering
|
||||
- empty_statements
|
||||
- unnecessary_brace_in_string_interps
|
||||
|
|
|
@ -16,6 +16,7 @@ analyzer:
|
|||
|
||||
linter:
|
||||
rules:
|
||||
- await_only_futures
|
||||
- empty_constructor_bodies
|
||||
- empty_statements
|
||||
- unnecessary_brace_in_string_interps
|
||||
|
|
|
@ -55,7 +55,7 @@ abstract class _ProvisionalApiTestBase extends AbstractContextTest {
|
|||
removeViaComments: removeViaComments,
|
||||
warnOnWeakCode: warnOnWeakCode);
|
||||
for (var path in input.keys) {
|
||||
if (!(await session.getFile(path)).isPart) {
|
||||
if (!(session.getFile(path)).isPart) {
|
||||
for (var unit in (await session.getResolvedLibrary(path)).units) {
|
||||
migration.prepareInput(unit);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ abstract class _ProvisionalApiTestBase extends AbstractContextTest {
|
|||
}
|
||||
_betweenStages();
|
||||
for (var path in input.keys) {
|
||||
if (!(await session.getFile(path)).isPart) {
|
||||
if (!(session.getFile(path)).isPart) {
|
||||
for (var unit in (await session.getResolvedLibrary(path)).units) {
|
||||
migration.processInput(unit);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ abstract class _ProvisionalApiTestBase extends AbstractContextTest {
|
|||
}
|
||||
_betweenStages();
|
||||
for (var path in input.keys) {
|
||||
if (!(await session.getFile(path)).isPart) {
|
||||
if (!(session.getFile(path)).isPart) {
|
||||
for (var unit in (await session.getResolvedLibrary(path)).units) {
|
||||
migration.finalizeInput(unit);
|
||||
}
|
||||
|
|
|
@ -444,7 +444,7 @@ int${migrated ? '?' : ''} f() => null;
|
|||
'external bool operator ==(dynamic other)');
|
||||
expect(newCoreLibText, isNot(oldCoreLibText));
|
||||
coreLib.writeAsStringSync(newCoreLibText);
|
||||
var projectDir = await createProjectDir(simpleProject());
|
||||
var projectDir = createProjectDir(simpleProject());
|
||||
await assertRunFailure([projectDir], cli: cli);
|
||||
var output = logger.stdoutBuffer.toString();
|
||||
expect(output, contains(messages.sdkNnbdOff));
|
||||
|
@ -464,7 +464,7 @@ int${migrated ? '?' : ''} f() => null;
|
|||
'external bool operator ==(dynamic other)');
|
||||
expect(newCoreLibText, isNot(oldCoreLibText));
|
||||
coreLib.writeAsStringSync(newCoreLibText);
|
||||
var projectDir = await createProjectDir(simpleProject());
|
||||
var projectDir = createProjectDir(simpleProject());
|
||||
await assertRunFailure([projectDir], cli: cli);
|
||||
var output = logger.stdoutBuffer.toString();
|
||||
expect(output, contains(messages.sdkNnbdOff));
|
||||
|
@ -564,7 +564,7 @@ int${migrated ? '?' : ''} f() => null;
|
|||
|
||||
test_lifecycle_apply_changes() async {
|
||||
var projectContents = simpleProject();
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
var cliRunner = cli.decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
|
||||
|
@ -602,7 +602,7 @@ linter:
|
|||
- empty_constructor_bodies
|
||||
''';
|
||||
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli()
|
||||
.decodeCommandLineArgs(_parseArgs(['--no-web-preview', projectDir]));
|
||||
await cliRunner.run();
|
||||
|
@ -615,7 +615,7 @@ linter:
|
|||
|
||||
test_lifecycle_contextdiscovery_handles_single() async {
|
||||
var projectContents = simpleProject();
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli()
|
||||
.decodeCommandLineArgs(_parseArgs(['--no-web-preview', projectDir]));
|
||||
await cliRunner.run();
|
||||
|
@ -626,7 +626,7 @@ linter:
|
|||
|
||||
test_lifecycle_exception_handling() async {
|
||||
var projectContents = simpleProject(sourceText: 'main() { print(0); }');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
injectArtificialException = true;
|
||||
await assertRunFailure([projectDir]);
|
||||
var errorOutput = logger.stderrBuffer.toString();
|
||||
|
@ -638,7 +638,7 @@ linter:
|
|||
|
||||
test_lifecycle_exception_handling_ignore() async {
|
||||
var projectContents = simpleProject(sourceText: 'main() { print(0); }');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
injectArtificialException = true;
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, ['--ignore-exceptions', projectDir],
|
||||
|
@ -659,7 +659,7 @@ linter:
|
|||
test_lifecycle_exception_handling_multiple() async {
|
||||
var projectContents =
|
||||
simpleProject(sourceText: 'main() { print(0); print(1); }');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
injectArtificialException = true;
|
||||
await assertRunFailure([projectDir]);
|
||||
var errorOutput = logger.stderrBuffer.toString();
|
||||
|
@ -673,7 +673,7 @@ linter:
|
|||
test_lifecycle_exception_handling_with_error() async {
|
||||
var projectContents =
|
||||
simpleProject(sourceText: 'main() { print(0); unresolved; }');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
injectArtificialException = true;
|
||||
await assertRunFailure(['--ignore-errors', projectDir]);
|
||||
var errorOutput = logger.stderrBuffer.toString();
|
||||
|
@ -686,7 +686,7 @@ linter:
|
|||
var projectContents = simpleProject(sourceText: '''
|
||||
int f() => null
|
||||
''');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
await assertRunFailure([projectDir]);
|
||||
var output = logger.stdoutBuffer.toString();
|
||||
expect(output, contains('1 analysis issue found'));
|
||||
|
@ -706,7 +706,7 @@ int f() => null
|
|||
var projectContents = simpleProject(sourceText: '''
|
||||
int? f() => null
|
||||
''');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, ['--ignore-errors', projectDir],
|
||||
(url) async {
|
||||
|
@ -722,7 +722,7 @@ int? f() => null
|
|||
|
||||
test_lifecycle_no_preview() async {
|
||||
var projectContents = simpleProject();
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli()
|
||||
.decodeCommandLineArgs(_parseArgs(['--no-web-preview', projectDir]));
|
||||
await cliRunner.run();
|
||||
|
@ -764,7 +764,7 @@ void call_g() => g(null);
|
|||
}
|
||||
|
||||
var projectContents = makeProject();
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var testPath =
|
||||
resourceProvider.pathContext.join(projectDir, 'lib', 'test.dart');
|
||||
var analyzeButDoNotMigratePath = resourceProvider.pathContext
|
||||
|
@ -789,7 +789,7 @@ void call_g() => g(null);
|
|||
|
||||
test_lifecycle_preview() async {
|
||||
var projectContents = simpleProject();
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
var localhostAddressText = Platform.environment.containsKey('FORCE_IPV6')
|
||||
|
@ -806,7 +806,7 @@ void call_g() => g(null);
|
|||
|
||||
test_lifecycle_preview_add_hint() async {
|
||||
var projectContents = simpleProject(sourceText: 'int x;');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
expect(
|
||||
|
@ -835,7 +835,7 @@ void call_g() => g(null);
|
|||
|
||||
test_lifecycle_preview_apply_changes() async {
|
||||
var projectContents = simpleProject();
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
bool applyHookCalled = false;
|
||||
cli._onApplyHook = () {
|
||||
|
@ -861,7 +861,7 @@ void call_g() => g(null);
|
|||
}
|
||||
|
||||
test_lifecycle_preview_extra_forward_slash() async {
|
||||
var projectDir = await createProjectDir(simpleProject());
|
||||
var projectDir = createProjectDir(simpleProject());
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
var uri = Uri.parse(url);
|
||||
|
@ -873,7 +873,7 @@ void call_g() => g(null);
|
|||
test_lifecycle_preview_navigation_links() async {
|
||||
var projectContents = simpleProject(sourceText: 'int x;');
|
||||
projectContents['lib/src/test.dart'] = 'import "../test.dart"; int y = x;';
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
expect(
|
||||
|
@ -907,7 +907,7 @@ void call_g() => g(null);
|
|||
|
||||
test_lifecycle_preview_navigation_tree() async {
|
||||
var projectContents = simpleProject(sourceText: 'int x;');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
expect(
|
||||
|
@ -940,7 +940,7 @@ void call_g() => g(null);
|
|||
|
||||
test_lifecycle_preview_on_host_any() async {
|
||||
var projectContents = simpleProject();
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli()
|
||||
..decodeCommandLineArgs(_parseArgs(['--preview-hostname=any']));
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
|
@ -953,7 +953,7 @@ void call_g() => g(null);
|
|||
|
||||
test_lifecycle_preview_region_link() async {
|
||||
var projectContents = simpleProject(sourceText: 'int x;');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
expect(
|
||||
|
@ -994,7 +994,7 @@ void call_g() => g(null);
|
|||
|
||||
test_lifecycle_preview_region_table_path() async {
|
||||
var projectContents = simpleProject(sourceText: 'int x;');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
expect(
|
||||
|
@ -1027,7 +1027,7 @@ void call_g() => g(null);
|
|||
test_lifecycle_preview_rerun() async {
|
||||
var origSourceText = 'void f() {}';
|
||||
var projectContents = simpleProject(sourceText: origSourceText);
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
await assertPreviewServerResponsive(url);
|
||||
|
@ -1049,7 +1049,7 @@ void call_g() => g(null);
|
|||
|
||||
test_lifecycle_preview_rerun_added_file() async {
|
||||
var projectContents = simpleProject();
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
await assertPreviewServerResponsive(url);
|
||||
|
@ -1072,7 +1072,7 @@ void call_g() => g(null);
|
|||
|
||||
test_lifecycle_preview_rerun_deleted_file() async {
|
||||
var projectContents = simpleProject();
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
// Note: we use the summary to verify that the deletion was noticed
|
||||
var summaryPath = resourceProvider.convertPath('/summary.json');
|
||||
|
@ -1109,7 +1109,7 @@ void call_g() => g(null);
|
|||
test_lifecycle_preview_rerun_with_new_analysis_errors() async {
|
||||
var origSourceText = 'void f(int i) {}';
|
||||
var projectContents = simpleProject(sourceText: origSourceText);
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
await assertPreviewServerResponsive(url);
|
||||
|
@ -1143,9 +1143,9 @@ void call_g() => g(null);
|
|||
var crazyFunctionName = 'crazyFunctionNameThatHasNeverBeenSeenBefore';
|
||||
var projectContents =
|
||||
simpleProject(sourceText: 'void $crazyFunctionName() {}');
|
||||
var mainProjectDir = await createProjectDir(projectContents);
|
||||
var otherProjectDir = await createProjectDir(projectContents,
|
||||
posixPath: '/other_project_dir');
|
||||
var mainProjectDir = createProjectDir(projectContents);
|
||||
var otherProjectDir =
|
||||
createProjectDir(projectContents, posixPath: '/other_project_dir');
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [mainProjectDir], (url) async {
|
||||
await assertPreviewServerResponsive(url);
|
||||
|
@ -1174,7 +1174,7 @@ void call_g() => g(null);
|
|||
|
||||
test_lifecycle_preview_stack_hint_action() async {
|
||||
var projectContents = simpleProject(sourceText: 'int x;');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
expect(
|
||||
|
@ -1209,7 +1209,7 @@ void call_g() => g(null);
|
|||
|
||||
test_lifecycle_preview_stacktrace_link() async {
|
||||
var projectContents = simpleProject(sourceText: 'int x;');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
await runWithPreviewServer(cli, [projectDir], (url) async {
|
||||
expect(
|
||||
|
@ -1246,7 +1246,7 @@ void call_g() => g(null);
|
|||
var projectContents = simpleProject(sourceText: '''
|
||||
int f() => null;
|
||||
''');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
processManager._mockResult = ProcessResult(
|
||||
123 /* pid */,
|
||||
0 /* exitCode */,
|
||||
|
@ -1266,7 +1266,7 @@ int f() => null;
|
|||
var projectContents = simpleProject(sourceText: '''
|
||||
int f() => null;
|
||||
''');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
processManager._mockResult = ProcessResult(
|
||||
123 /* pid */,
|
||||
0 /* exitCode */,
|
||||
|
@ -1287,7 +1287,7 @@ int f() => null;
|
|||
|
||||
test_lifecycle_summary() async {
|
||||
var projectContents = simpleProject();
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var summaryPath = resourceProvider.convertPath('/summary.json');
|
||||
var cliRunner = _createCli().decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--summary', summaryPath, projectDir]));
|
||||
|
@ -1301,7 +1301,7 @@ int f() => null;
|
|||
|
||||
test_lifecycle_summary_does_not_double_count_hint_removals() async {
|
||||
var projectContents = simpleProject(sourceText: 'int/*?*/ x;');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var summaryPath = resourceProvider.convertPath('/summary.json');
|
||||
var cliRunner = _createCli().decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--summary', summaryPath, projectDir]));
|
||||
|
@ -1316,7 +1316,7 @@ int f() => null;
|
|||
|
||||
test_lifecycle_summary_rewritten_upon_rerun() async {
|
||||
var projectContents = simpleProject(sourceText: 'int f(int/*?*/ i) => i;');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cli = _createCli();
|
||||
var summaryPath = resourceProvider.convertPath('/summary.json');
|
||||
await runWithPreviewServer(cli, ['--summary', summaryPath, projectDir],
|
||||
|
@ -1351,7 +1351,7 @@ int f() => null;
|
|||
import 'package:does_not/exist.dart';
|
||||
int f() => null;
|
||||
''');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
await assertRunFailure([projectDir]);
|
||||
var output = logger.stdoutBuffer.toString();
|
||||
expect(output, contains('1 analysis issue found'));
|
||||
|
@ -1464,7 +1464,7 @@ int f() => null;
|
|||
test_package_config_does_not_exist() async {
|
||||
var projectContents = simpleProject()
|
||||
..remove('.dart_tool/package_config.json');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli().decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
|
||||
await cliRunner.run();
|
||||
|
@ -1489,7 +1489,7 @@ int f() => null;
|
|||
}
|
||||
''';
|
||||
var projectContents = simpleProject(packageConfigText: packageConfigText);
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli().decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
|
||||
await cliRunner.run();
|
||||
|
@ -1507,7 +1507,7 @@ int f() => null;
|
|||
}
|
||||
''';
|
||||
var projectContents = simpleProject(packageConfigText: packageConfigText);
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli().decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
|
||||
await cliRunner.run();
|
||||
|
@ -1531,7 +1531,7 @@ int f() => null;
|
|||
}
|
||||
''';
|
||||
var projectContents = simpleProject(packageConfigText: packageConfigText);
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli().decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
|
||||
await cliRunner.run();
|
||||
|
@ -1672,7 +1672,7 @@ int f() => null;
|
|||
var projectContents = simpleProject()
|
||||
..remove('pubspec.yaml')
|
||||
..remove('.dart_tool/package_config.json');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli().decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
|
||||
await cliRunner.run();
|
||||
|
@ -1690,7 +1690,7 @@ name: test
|
|||
environment:
|
||||
foo: 1
|
||||
''');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli().decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
|
||||
await cliRunner.run();
|
||||
|
@ -1710,7 +1710,7 @@ name: test
|
|||
environment: 1
|
||||
''';
|
||||
var projectContents = simpleProject(pubspecText: pubspecText);
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli().decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
|
||||
await cliRunner.run();
|
||||
|
@ -1727,7 +1727,7 @@ environment:
|
|||
''';
|
||||
var projectContents = simpleProject(pubspecText: pubspecText)
|
||||
..remove('.dart_tool/package_config.json');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli().decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
|
||||
await cliRunner.run();
|
||||
|
@ -1742,7 +1742,7 @@ environment:
|
|||
var projectContents = simpleProject(pubspecText: '''
|
||||
name: test
|
||||
''');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli().decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
|
||||
await cliRunner.run();
|
||||
|
@ -1759,7 +1759,7 @@ name: test
|
|||
|
||||
test_pubspec_is_not_a_map() async {
|
||||
var projectContents = simpleProject(pubspecText: 'not-a-map');
|
||||
var projectDir = await createProjectDir(projectContents);
|
||||
var projectDir = createProjectDir(projectContents);
|
||||
var cliRunner = _createCli().decodeCommandLineArgs(
|
||||
_parseArgs(['--no-web-preview', '--apply-changes', projectDir]));
|
||||
expect(() async => await cliRunner.run(), throwsUnsupportedError);
|
||||
|
@ -1882,6 +1882,11 @@ class _TestLogger implements Logger {
|
|||
stdoutBuffer.writeln(message);
|
||||
}
|
||||
|
||||
@override
|
||||
void trace(String message) {
|
||||
throw UnimplementedError('TODO(paulberry)');
|
||||
}
|
||||
|
||||
@override
|
||||
void write(String message) {
|
||||
stdoutBuffer.write(message);
|
||||
|
@ -1891,9 +1896,4 @@ class _TestLogger implements Logger {
|
|||
void writeCharCode(int charCode) {
|
||||
stdoutBuffer.writeCharCode(charCode);
|
||||
}
|
||||
|
||||
@override
|
||||
void trace(String message) {
|
||||
throw UnimplementedError('TODO(paulberry)');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ String base64Encode(List<int> bytes) {
|
|||
return lines.join('\n');
|
||||
}
|
||||
|
||||
void compileWebFrontEnd({bool devMode = false}) async {
|
||||
Future<void> compileWebFrontEnd({bool devMode = false}) async {
|
||||
var sdkBinDir = path.dirname(Platform.resolvedExecutable);
|
||||
var dart2jsBinary = Platform.isWindows ? 'dart2js.bat' : 'dart2js';
|
||||
var dart2jsPath = path.join(sdkBinDir, dart2jsBinary);
|
||||
|
|
Loading…
Reference in a new issue