Unverified Commit 92094802 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_tools] update analyze_once_test.dart to be null-safe (#141790)

Fixes https://github.com/flutter/flutter/issues/141743

I should have made this change in https://github.com/flutter/flutter/pull/124039, but it escaped my grep search.
parent f340d207
...@@ -63,7 +63,7 @@ void main() { ...@@ -63,7 +63,7 @@ void main() {
"name": "flutter_project", "name": "flutter_project",
"rootUri": "../", "rootUri": "../",
"packageUri": "lib/", "packageUri": "lib/",
"languageVersion": "2.7" "languageVersion": "2.12"
} }
] ]
} }
...@@ -170,7 +170,7 @@ void main() { ...@@ -170,7 +170,7 @@ void main() {
statusTextContains: <String>[ statusTextContains: <String>[
'Analyzing', 'Analyzing',
'unused_element', 'unused_element',
'missing_required_param', 'missing_required_argument',
], ],
exitMessageContains: '2 issues found.', exitMessageContains: '2 issues found.',
exitCode: 1, exitCode: 1,
...@@ -205,7 +205,7 @@ void main() { ...@@ -205,7 +205,7 @@ void main() {
'Analyzing', 'Analyzing',
'unused_element', 'unused_element',
'only_throw_errors', 'only_throw_errors',
'missing_required_param', 'missing_required_argument',
], ],
exitMessageContains: '3 issues found.', exitMessageContains: '3 issues found.',
exitCode: 1, exitCode: 1,
...@@ -266,22 +266,15 @@ StringBuffer bar = StringBuffer('baz'); ...@@ -266,22 +266,15 @@ StringBuffer bar = StringBuffer('baz');
testWithoutContext('analyze once with default options has info issue finally exit code 1.', () async { testWithoutContext('analyze once with default options has info issue finally exit code 1.', () async {
const String infoSourceCode = ''' const String infoSourceCode = '''
int analyze() {} void _analyze() {}
'''; ''';
final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml'));
optionsFile.writeAsStringSync('''
analyzer:
errors:
missing_return: info
''');
fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(infoSourceCode); fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(infoSourceCode);
await runCommand( await runCommand(
arguments: <String>['analyze', '--no-pub'], arguments: <String>['analyze', '--no-pub'],
statusTextContains: <String>[ statusTextContains: <String>[
'info', 'info',
'missing_return', 'unused_element',
], ],
exitMessageContains: '1 issue found.', exitMessageContains: '1 issue found.',
exitCode: 1, exitCode: 1,
...@@ -290,14 +283,14 @@ analyzer: ...@@ -290,14 +283,14 @@ analyzer:
testWithoutContext('analyze once with no-fatal-infos has info issue finally exit code 0.', () async { testWithoutContext('analyze once with no-fatal-infos has info issue finally exit code 0.', () async {
const String infoSourceCode = ''' const String infoSourceCode = '''
int analyze() {} void _analyze() {}
'''; ''';
final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml')); final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml'));
optionsFile.writeAsStringSync(''' optionsFile.writeAsStringSync('''
analyzer: analyzer:
errors: errors:
missing_return: info unused_element: info
'''); ''');
fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(infoSourceCode); fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(infoSourceCode);
...@@ -305,7 +298,7 @@ analyzer: ...@@ -305,7 +298,7 @@ analyzer:
arguments: <String>['analyze', '--no-pub', '--no-fatal-infos'], arguments: <String>['analyze', '--no-pub', '--no-fatal-infos'],
statusTextContains: <String>[ statusTextContains: <String>[
'info', 'info',
'missing_return', 'unused_element',
], ],
exitMessageContains: '1 issue found.', exitMessageContains: '1 issue found.',
); );
...@@ -313,14 +306,14 @@ analyzer: ...@@ -313,14 +306,14 @@ analyzer:
testWithoutContext('analyze once only fatal-warnings has info issue finally exit code 0.', () async { testWithoutContext('analyze once only fatal-warnings has info issue finally exit code 0.', () async {
const String infoSourceCode = ''' const String infoSourceCode = '''
int analyze() {} void _analyze() {}
'''; ''';
final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml')); final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml'));
optionsFile.writeAsStringSync(''' optionsFile.writeAsStringSync('''
analyzer: analyzer:
errors: errors:
missing_return: info unused_element: info
'''); ''');
fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(infoSourceCode); fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(infoSourceCode);
...@@ -328,7 +321,7 @@ analyzer: ...@@ -328,7 +321,7 @@ analyzer:
arguments: <String>['analyze', '--no-pub', '--fatal-warnings', '--no-fatal-infos'], arguments: <String>['analyze', '--no-pub', '--fatal-warnings', '--no-fatal-infos'],
statusTextContains: <String>[ statusTextContains: <String>[
'info', 'info',
'missing_return', 'unused_element',
], ],
exitMessageContains: '1 issue found.', exitMessageContains: '1 issue found.',
); );
...@@ -336,14 +329,14 @@ analyzer: ...@@ -336,14 +329,14 @@ analyzer:
testWithoutContext('analyze once only fatal-infos has warning issue finally exit code 0.', () async { testWithoutContext('analyze once only fatal-infos has warning issue finally exit code 0.', () async {
const String warningSourceCode = ''' const String warningSourceCode = '''
int analyze() {} void _analyze() {}
'''; ''';
final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml')); final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml'));
optionsFile.writeAsStringSync(''' optionsFile.writeAsStringSync('''
analyzer: analyzer:
errors: errors:
missing_return: warning unused_element: warning
'''); ''');
fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(warningSourceCode); fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(warningSourceCode);
...@@ -351,7 +344,7 @@ analyzer: ...@@ -351,7 +344,7 @@ analyzer:
arguments: <String>['analyze','--no-pub', '--fatal-infos', '--no-fatal-warnings'], arguments: <String>['analyze','--no-pub', '--fatal-infos', '--no-fatal-warnings'],
statusTextContains: <String>[ statusTextContains: <String>[
'warning', 'warning',
'missing_return', 'unused_element',
], ],
exitMessageContains: '1 issue found.', exitMessageContains: '1 issue found.',
); );
...@@ -360,14 +353,14 @@ analyzer: ...@@ -360,14 +353,14 @@ analyzer:
testWithoutContext('analyze once only fatal-warnings has warning issue finally exit code 1.', () async { testWithoutContext('analyze once only fatal-warnings has warning issue finally exit code 1.', () async {
const String warningSourceCode = ''' const String warningSourceCode = '''
int analyze() {} void _analyze() {}
'''; ''';
final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml')); final File optionsFile = fileSystem.file(fileSystem.path.join(projectPath, 'analysis_options.yaml'));
optionsFile.writeAsStringSync(''' optionsFile.writeAsStringSync('''
analyzer: analyzer:
errors: errors:
missing_return: warning unused_element: warning
'''); ''');
fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(warningSourceCode); fileSystem.directory(projectPath).childFile('main.dart').writeAsStringSync(warningSourceCode);
...@@ -375,7 +368,7 @@ analyzer: ...@@ -375,7 +368,7 @@ analyzer:
arguments: <String>['analyze','--no-pub', '--no-fatal-infos', '--fatal-warnings'], arguments: <String>['analyze','--no-pub', '--no-fatal-infos', '--fatal-warnings'],
statusTextContains: <String>[ statusTextContains: <String>[
'warning', 'warning',
'missing_return', 'unused_element',
], ],
exitMessageContains: '1 issue found.', exitMessageContains: '1 issue found.',
exitCode: 1, exitCode: 1,
...@@ -408,7 +401,7 @@ class MyApp extends StatelessWidget { ...@@ -408,7 +401,7 @@ class MyApp extends StatelessWidget {
} }
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key); MyHomePage({Key? key, required this.title}) : super(key: key);
final String title; final String title;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment