Enable no_leading_underscores_for_local_identifiers (#96422)

This commit is contained in:
Michael Goderbauer
2022-01-21 14:43:59 -08:00
committed by GitHub
parent 53ca7f684a
commit 5684b9f69e
89 changed files with 948 additions and 949 deletions

View File

@@ -132,11 +132,11 @@ class IdeConfigCommand extends FlutterCommand {
}
// Skip files we aren't interested in.
final RegExp _trackedIdeaFileRegExp = RegExp(
final RegExp trackedIdeaFileRegExp = RegExp(
r'(\.name|modules.xml|vcs.xml)$',
);
final bool isATrackedIdeaFile = _hasDirectoryInPath(srcFile, '.idea') &&
(_trackedIdeaFileRegExp.hasMatch(relativePath) ||
(trackedIdeaFileRegExp.hasMatch(relativePath) ||
_hasDirectoryInPath(srcFile, 'runConfigurations'));
final bool isAnImlOutsideIdea = !isATrackedIdeaFile && srcFile.path.endsWith('.iml');
if (!isATrackedIdeaFile && !isAnImlOutsideIdea) {

View File

@@ -21,8 +21,8 @@ import 'flutter_test_adapter.dart';
/// adapters.
class DapServer {
DapServer(
Stream<List<int>> _input,
StreamSink<List<int>> _output, {
Stream<List<int>> input,
StreamSink<List<int>> output, {
required FileSystem fileSystem,
required Platform platform,
this.ipv6 = false,
@@ -30,7 +30,7 @@ class DapServer {
this.enableAuthCodes = true,
bool test = false,
this.logger,
}) : channel = ByteStreamServerChannel(_input, _output, logger) {
}) : channel = ByteStreamServerChannel(input, output, logger) {
adapter = test
? FlutterTestDebugAdapter(channel,
fileSystem: fileSystem,

View File

@@ -88,7 +88,7 @@ class FlutterVersion {
String? _repositoryUrl;
String? get repositoryUrl {
final String _ = channel;
final String _ = channel; // ignore: no_leading_underscores_for_local_identifiers
return _repositoryUrl;
}

View File

@@ -39,14 +39,14 @@ void main() {
);
}
const FakeCommand _kWhichSysctlCommand = FakeCommand(
const FakeCommand kWhichSysctlCommand = FakeCommand(
command: <String>[
'which',
'sysctl',
],
);
const FakeCommand _kx64CheckCommand = FakeCommand(
const FakeCommand kx64CheckCommand = FakeCommand(
command: <String>[
'sysctl',
'hw.optional.arm64',
@@ -61,8 +61,8 @@ void main() {
}) {
final FakeProcessManager fakeProcessManager =
FakeProcessManager.list(<FakeCommand>[
_kWhichSysctlCommand,
_kx64CheckCommand,
kWhichSysctlCommand,
kx64CheckCommand,
]);
final Xcode xcode = Xcode.test(
processManager: fakeProcessManager,

View File

@@ -94,70 +94,70 @@ baz=qux
});
group('text wrapping', () {
const int _lineLength = 40;
const String _longLine = 'This is a long line that needs to be wrapped.';
final String _longLineWithNewlines = 'This is a long line with newlines that\n'
const int lineLength = 40;
const String longLine = 'This is a long line that needs to be wrapped.';
final String longLineWithNewlines = 'This is a long line with newlines that\n'
'needs to be wrapped.\n\n'
'${'0123456789' * 5}';
final String _longAnsiLineWithNewlines = '${AnsiTerminal.red}This${AnsiTerminal.resetAll} is a long line with newlines that\n'
final String longAnsiLineWithNewlines = '${AnsiTerminal.red}This${AnsiTerminal.resetAll} is a long line with newlines that\n'
'needs to be wrapped.\n\n'
'${AnsiTerminal.green}0123456789${AnsiTerminal.resetAll}'
'${'0123456789' * 3}'
'${AnsiTerminal.green}0123456789${AnsiTerminal.resetAll}';
const String _onlyAnsiSequences = '${AnsiTerminal.red}${AnsiTerminal.resetAll}';
final String _indentedLongLineWithNewlines = ' This is an indented long line with newlines that\n'
const String onlyAnsiSequences = '${AnsiTerminal.red}${AnsiTerminal.resetAll}';
final String indentedLongLineWithNewlines = ' This is an indented long line with newlines that\n'
'needs to be wrapped.\n\tAnd preserves tabs.\n \n '
'${'0123456789' * 5}';
const String _shortLine = 'Short line.';
const String _indentedLongLine = ' This is an indented long line that needs to be '
const String shortLine = 'Short line.';
const String indentedLongLine = ' This is an indented long line that needs to be '
'wrapped and indentation preserved.';
testWithoutContext('does not wrap by default in tests', () {
expect(wrapText(_longLine, columnWidth: 80, shouldWrap: true), equals(_longLine));
expect(wrapText(longLine, columnWidth: 80, shouldWrap: true), equals(longLine));
});
testWithoutContext('can override wrap preference if preference is off', () {
expect(wrapText(_longLine, columnWidth: _lineLength, shouldWrap: true), equals('''
expect(wrapText(longLine, columnWidth: lineLength, shouldWrap: true), equals('''
This is a long line that needs to be
wrapped.'''));
});
testWithoutContext('can override wrap preference if preference is on', () {
expect(wrapText(_longLine, shouldWrap: false, columnWidth: 80), equals(_longLine));
expect(wrapText(longLine, shouldWrap: false, columnWidth: 80), equals(longLine));
});
testWithoutContext('does not wrap at all if not told to wrap', () {
expect(wrapText(_longLine, columnWidth: 80, shouldWrap: false), equals(_longLine));
expect(wrapText(longLine, columnWidth: 80, shouldWrap: false), equals(longLine));
});
testWithoutContext('does not wrap short lines.', () {
expect(wrapText(_shortLine, columnWidth: _lineLength, shouldWrap: true), equals(_shortLine));
expect(wrapText(shortLine, columnWidth: lineLength, shouldWrap: true), equals(shortLine));
});
testWithoutContext('able to wrap long lines', () {
expect(wrapText(_longLine, columnWidth: _lineLength, shouldWrap: true), equals('''
expect(wrapText(longLine, columnWidth: lineLength, shouldWrap: true), equals('''
This is a long line that needs to be
wrapped.'''));
});
testWithoutContext('able to handle dynamically changing terminal column size', () {
expect(wrapText(_longLine, columnWidth: 20, shouldWrap: true), equals('''
expect(wrapText(longLine, columnWidth: 20, shouldWrap: true), equals('''
This is a long line
that needs to be
wrapped.'''));
expect(wrapText(_longLine, columnWidth: _lineLength, shouldWrap: true), equals('''
expect(wrapText(longLine, columnWidth: lineLength, shouldWrap: true), equals('''
This is a long line that needs to be
wrapped.'''));
});
testWithoutContext('wrap long lines with no whitespace', () {
expect(wrapText('0123456789' * 5, columnWidth: _lineLength, shouldWrap: true), equals('''
expect(wrapText('0123456789' * 5, columnWidth: lineLength, shouldWrap: true), equals('''
0123456789012345678901234567890123456789
0123456789'''));
});
testWithoutContext('refuses to wrap to a column smaller than 10 characters', () {
expect(wrapText('$_longLine ${'0123456789' * 4}', columnWidth: 1, shouldWrap: true), equals('''
expect(wrapText('$longLine ${'0123456789' * 4}', columnWidth: 1, shouldWrap: true), equals('''
This is a
long line
that needs
@@ -169,21 +169,21 @@ wrapped.
0123456789'''));
});
testWithoutContext('preserves indentation', () {
expect(wrapText(_indentedLongLine, columnWidth: _lineLength, shouldWrap: true), equals('''
expect(wrapText(indentedLongLine, columnWidth: lineLength, shouldWrap: true), equals('''
This is an indented long line that
needs to be wrapped and indentation
preserved.'''));
});
testWithoutContext('preserves indentation and stripping trailing whitespace', () {
expect(wrapText('$_indentedLongLine ', columnWidth: _lineLength, shouldWrap: true), equals('''
expect(wrapText('$indentedLongLine ', columnWidth: lineLength, shouldWrap: true), equals('''
This is an indented long line that
needs to be wrapped and indentation
preserved.'''));
});
testWithoutContext('wraps text with newlines', () {
expect(wrapText(_longLineWithNewlines, columnWidth: _lineLength, shouldWrap: true), equals('''
expect(wrapText(longLineWithNewlines, columnWidth: lineLength, shouldWrap: true), equals('''
This is a long line with newlines that
needs to be wrapped.
@@ -192,7 +192,7 @@ needs to be wrapped.
});
testWithoutContext('wraps text with ANSI sequences embedded', () {
expect(wrapText(_longAnsiLineWithNewlines, columnWidth: _lineLength, shouldWrap: true), equals('''
expect(wrapText(longAnsiLineWithNewlines, columnWidth: lineLength, shouldWrap: true), equals('''
${AnsiTerminal.red}This${AnsiTerminal.resetAll} is a long line with newlines that
needs to be wrapped.
@@ -201,12 +201,12 @@ ${AnsiTerminal.green}0123456789${AnsiTerminal.resetAll}'''));
});
testWithoutContext('wraps text with only ANSI sequences', () {
expect(wrapText(_onlyAnsiSequences, columnWidth: _lineLength, shouldWrap: true),
expect(wrapText(onlyAnsiSequences, columnWidth: lineLength, shouldWrap: true),
equals('${AnsiTerminal.red}${AnsiTerminal.resetAll}'));
});
testWithoutContext('preserves indentation in the presence of newlines', () {
expect(wrapText(_indentedLongLineWithNewlines, columnWidth: _lineLength, shouldWrap: true), equals('''
expect(wrapText(indentedLongLineWithNewlines, columnWidth: lineLength, shouldWrap: true), equals('''
This is an indented long line with
newlines that
needs to be wrapped.
@@ -217,37 +217,37 @@ needs to be wrapped.
});
testWithoutContext('removes trailing whitespace when wrapping', () {
expect(wrapText('$_longLine \t', columnWidth: _lineLength, shouldWrap: true), equals('''
expect(wrapText('$longLine \t', columnWidth: lineLength, shouldWrap: true), equals('''
This is a long line that needs to be
wrapped.'''));
});
testWithoutContext('honors hangingIndent parameter', () {
expect(wrapText(_longLine, columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals('''
expect(wrapText(longLine, columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals('''
This is a long line that needs to be
wrapped.'''));
});
testWithoutContext('handles hangingIndent with a single unwrapped line.', () {
expect(wrapText(_shortLine, columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals('''
expect(wrapText(shortLine, columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals('''
Short line.'''));
});
testWithoutContext('handles hangingIndent with two unwrapped lines and the second is empty.', () {
expect(wrapText('$_shortLine\n', columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals('''
expect(wrapText('$shortLine\n', columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals('''
Short line.
'''));
});
testWithoutContext('honors hangingIndent parameter on already indented line.', () {
expect(wrapText(_indentedLongLine, columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals('''
expect(wrapText(indentedLongLine, columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals('''
This is an indented long line that
needs to be wrapped and
indentation preserved.'''));
});
testWithoutContext('honors hangingIndent and indent parameters at the same time.', () {
expect(wrapText(_indentedLongLine, columnWidth: _lineLength, indent: 6, hangingIndent: 6, shouldWrap: true), equals('''
expect(wrapText(indentedLongLine, columnWidth: lineLength, indent: 6, hangingIndent: 6, shouldWrap: true), equals('''
This is an indented long line
that needs to be wrapped
and indentation
@@ -255,14 +255,14 @@ Short line.
});
testWithoutContext('honors indent parameter on already indented line.', () {
expect(wrapText(_indentedLongLine, columnWidth: _lineLength, indent: 6, shouldWrap: true), equals('''
expect(wrapText(indentedLongLine, columnWidth: lineLength, indent: 6, shouldWrap: true), equals('''
This is an indented long line
that needs to be wrapped and
indentation preserved.'''));
});
testWithoutContext('honors hangingIndent parameter on already indented line.', () {
expect(wrapText(_indentedLongLineWithNewlines, columnWidth: _lineLength, hangingIndent: 6, shouldWrap: true), equals('''
expect(wrapText(indentedLongLineWithNewlines, columnWidth: lineLength, hangingIndent: 6, shouldWrap: true), equals('''
This is an indented long line with
newlines that
needs to be wrapped.

View File

@@ -30,8 +30,8 @@ void main() {
});
testWithoutContext('device.getDevices', () async {
final BasicProject _project = BasicProject();
await _project.setUpIn(tempDir);
final BasicProject project = BasicProject();
await project.setUpIn(tempDir);
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');

View File

@@ -37,8 +37,8 @@ void main() {
});
testWithoutContext('can run and terminate a Flutter app in debug mode', () async {
final BasicProject _project = BasicProject();
await _project.setUpIn(tempDir);
final BasicProject project = BasicProject();
await project.setUpIn(tempDir);
// Once the "topLevelFunction" output arrives, we can terminate the app.
unawaited(
@@ -50,7 +50,7 @@ void main() {
final List<OutputEventBody> outputEvents = await dap.client.collectAllOutput(
launch: () => dap.client
.launch(
cwd: _project.dir.path,
cwd: project.dir.path,
toolArgs: <String>['-d', 'flutter-tester'],
),
);
@@ -67,8 +67,8 @@ void main() {
});
testWithoutContext('can run and terminate a Flutter app in noDebug mode', () async {
final BasicProject _project = BasicProject();
await _project.setUpIn(tempDir);
final BasicProject project = BasicProject();
await project.setUpIn(tempDir);
// Once the "topLevelFunction" output arrives, we can terminate the app.
unawaited(
@@ -80,7 +80,7 @@ void main() {
final List<OutputEventBody> outputEvents = await dap.client.collectAllOutput(
launch: () => dap.client
.launch(
cwd: _project.dir.path,
cwd: project.dir.path,
noDebug: true,
toolArgs: <String>['-d', 'flutter-tester'],
),
@@ -97,13 +97,13 @@ void main() {
});
testWithoutContext('correctly outputs launch errors and terminates', () async {
final CompileErrorProject _project = CompileErrorProject();
await _project.setUpIn(tempDir);
final CompileErrorProject project = CompileErrorProject();
await project.setUpIn(tempDir);
final List<OutputEventBody> outputEvents = await dap.client.collectAllOutput(
launch: () => dap.client
.launch(
cwd: _project.dir.path,
cwd: project.dir.path,
toolArgs: <String>['-d', 'flutter-tester'],
),
);
@@ -115,15 +115,15 @@ void main() {
});
testWithoutContext('can hot reload', () async {
final BasicProject _project = BasicProject();
await _project.setUpIn(tempDir);
final BasicProject project = BasicProject();
await project.setUpIn(tempDir);
// Launch the app and wait for it to print "topLevelFunction".
await Future.wait(<Future<Object>>[
dap.client.outputEvents.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction')),
dap.client.start(
launch: () => dap.client.launch(
cwd: _project.dir.path,
cwd: project.dir.path,
noDebug: true,
toolArgs: <String>['-d', 'flutter-tester'],
),
@@ -152,15 +152,15 @@ void main() {
});
testWithoutContext('can hot restart', () async {
final BasicProject _project = BasicProject();
await _project.setUpIn(tempDir);
final BasicProject project = BasicProject();
await project.setUpIn(tempDir);
// Launch the app and wait for it to print "topLevelFunction".
await Future.wait(<Future<Object>>[
dap.client.outputEvents.firstWhere((OutputEventBody output) => output.output.startsWith('topLevelFunction')),
dap.client.start(
launch: () => dap.client.launch(
cwd: _project.dir.path,
cwd: project.dir.path,
noDebug: true,
toolArgs: <String>['-d', 'flutter-tester'],
),
@@ -189,8 +189,8 @@ void main() {
});
testWithoutContext('can hot restart when exceptions occur on outgoing isolates', () async {
final BasicProjectThatThrows _project = BasicProjectThatThrows();
await _project.setUpIn(tempDir);
final BasicProjectThatThrows project = BasicProjectThatThrows();
await project.setUpIn(tempDir);
// Launch the app and wait for it to stop at an exception.
int originalThreadId, newThreadId;
@@ -200,7 +200,7 @@ void main() {
dap.client.start(
exceptionPauseMode: 'All', // Ensure we stop on all exceptions
launch: () => dap.client.launch(
cwd: _project.dir.path,
cwd: project.dir.path,
toolArgs: <String>['-d', 'flutter-tester'],
),
),
@@ -222,8 +222,8 @@ void main() {
});
testWithoutContext('sends events for extension state updates', () async {
final BasicProject _project = BasicProject();
await _project.setUpIn(tempDir);
final BasicProject project = BasicProject();
await project.setUpIn(tempDir);
const String debugPaintRpc = 'ext.flutter.debugPaint';
// Create a future to capture the isolate ID when the debug paint service
@@ -239,7 +239,7 @@ void main() {
output.output.startsWith('topLevelFunction')),
dap.client.start(
launch: () => dap.client.launch(
cwd: _project.dir.path,
cwd: project.dir.path,
toolArgs: <String>['-d', 'flutter-tester'],
),
),

View File

@@ -131,8 +131,8 @@ class OutOfProcessDapTestServer extends DapTestServer {
...?additionalArgs,
];
final Process _process = await Process.start(executable, args);
final Process process = await Process.start(executable, args);
return OutOfProcessDapTestServer._(_process, logger);
return OutOfProcessDapTestServer._(process, logger);
}
}

View File

@@ -21,32 +21,32 @@ void main() {
});
testWithoutContext('can step over statements', () async {
final SteppingProject _project = SteppingProject();
await _project.setUpIn(tempDir);
final SteppingProject project = SteppingProject();
await project.setUpIn(tempDir);
final FlutterRunTestDriver _flutter = FlutterRunTestDriver(tempDir);
final FlutterRunTestDriver flutter = FlutterRunTestDriver(tempDir);
await _flutter.run(withDebugger: true, startPaused: true);
await _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine);
await _flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint.
await flutter.run(withDebugger: true, startPaused: true);
await flutter.addBreakpoint(project.breakpointUri, project.breakpointLine);
await flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint.
expect((await _flutter.getSourceLocation())?.line, equals(_project.breakpointLine));
expect((await flutter.getSourceLocation())?.line, equals(project.breakpointLine));
// Issue 5 steps, ensuring that we end up on the annotated lines each time.
for (int i = 1; i <= _project.numberOfSteps; i += 1) {
await _flutter.stepOverOrOverAsyncSuspension();
final SourcePosition? location = await _flutter.getSourceLocation();
for (int i = 1; i <= project.numberOfSteps; i += 1) {
await flutter.stepOverOrOverAsyncSuspension();
final SourcePosition? location = await flutter.getSourceLocation();
final int? actualLine = location?.line;
// Get the line we're expected to stop at by searching for the comment
// within the source code.
final int expectedLine = _project.lineForStep(i);
final int expectedLine = project.lineForStep(i);
expect(actualLine, equals(expectedLine),
reason: 'After $i steps, debugger should stop at $expectedLine but stopped at $actualLine'
);
}
await _flutter.stop();
await flutter.stop();
});
}

View File

@@ -14,15 +14,15 @@ import 'test_utils.dart';
void main() {
late Directory tempDir;
late FlutterRunTestDriver _flutter;
late FlutterRunTestDriver flutter;
setUp(() async {
tempDir = createResolvedTempDirectorySync('run_test.');
_flutter = FlutterRunTestDriver(tempDir);
flutter = FlutterRunTestDriver(tempDir);
});
tearDown(() async {
await _flutter.stop();
await flutter.stop();
tryToDelete(tempDir);
});

View File

@@ -15,130 +15,130 @@ import 'test_driver.dart';
import 'test_utils.dart';
void batch1() {
final BasicProject _project = BasicProject();
final BasicProject project = BasicProject();
Directory tempDir;
FlutterRunTestDriver _flutter;
FlutterRunTestDriver flutter;
Future<void> initProject() async {
tempDir = createResolvedTempDirectorySync('run_expression_eval_test.');
await _project.setUpIn(tempDir);
_flutter = FlutterRunTestDriver(tempDir);
await project.setUpIn(tempDir);
flutter = FlutterRunTestDriver(tempDir);
}
Future<void> cleanProject() async {
await _flutter.stop();
await flutter.stop();
tryToDelete(tempDir);
}
Future<void> breakInBuildMethod(FlutterTestDriver flutter) async {
await _flutter.breakAt(
_project.buildMethodBreakpointUri,
_project.buildMethodBreakpointLine,
await flutter.breakAt(
project.buildMethodBreakpointUri,
project.buildMethodBreakpointLine,
);
}
Future<void> breakInTopLevelFunction(FlutterTestDriver flutter) async {
await _flutter.breakAt(
_project.topLevelFunctionBreakpointUri,
_project.topLevelFunctionBreakpointLine,
await flutter.breakAt(
project.topLevelFunctionBreakpointUri,
project.topLevelFunctionBreakpointLine,
);
}
testWithoutContext('flutter run expression evaluation - can evaluate trivial expressions in top level function', () async {
await initProject();
await _flutter.run(withDebugger: true);
await breakInTopLevelFunction(_flutter);
await evaluateTrivialExpressions(_flutter);
await flutter.run(withDebugger: true);
await breakInTopLevelFunction(flutter);
await evaluateTrivialExpressions(flutter);
await cleanProject();
});
testWithoutContext('flutter run expression evaluation - can evaluate trivial expressions in build method', () async {
await initProject();
await _flutter.run(withDebugger: true);
await breakInBuildMethod(_flutter);
await evaluateTrivialExpressions(_flutter);
await flutter.run(withDebugger: true);
await breakInBuildMethod(flutter);
await evaluateTrivialExpressions(flutter);
await cleanProject();
});
testWithoutContext('flutter run expression evaluation - can evaluate complex expressions in top level function', () async {
await initProject();
await _flutter.run(withDebugger: true);
await breakInTopLevelFunction(_flutter);
await evaluateComplexExpressions(_flutter);
await flutter.run(withDebugger: true);
await breakInTopLevelFunction(flutter);
await evaluateComplexExpressions(flutter);
await cleanProject();
});
testWithoutContext('flutter run expression evaluation - can evaluate complex expressions in build method', () async {
await initProject();
await _flutter.run(withDebugger: true);
await breakInBuildMethod(_flutter);
await evaluateComplexExpressions(_flutter);
await flutter.run(withDebugger: true);
await breakInBuildMethod(flutter);
await evaluateComplexExpressions(flutter);
await cleanProject();
});
testWithoutContext('flutter run expression evaluation - can evaluate expressions returning complex objects in top level function', () async {
await initProject();
await _flutter.run(withDebugger: true);
await breakInTopLevelFunction(_flutter);
await evaluateComplexReturningExpressions(_flutter);
await flutter.run(withDebugger: true);
await breakInTopLevelFunction(flutter);
await evaluateComplexReturningExpressions(flutter);
await cleanProject();
});
testWithoutContext('flutter run expression evaluation - can evaluate expressions returning complex objects in build method', () async {
await initProject();
await _flutter.run(withDebugger: true);
await breakInBuildMethod(_flutter);
await evaluateComplexReturningExpressions(_flutter);
await flutter.run(withDebugger: true);
await breakInBuildMethod(flutter);
await evaluateComplexReturningExpressions(flutter);
await cleanProject();
});
}
void batch2() {
final TestsProject _project = TestsProject();
final TestsProject project = TestsProject();
Directory tempDir;
FlutterTestTestDriver _flutter;
FlutterTestTestDriver flutter;
Future<void> initProject() async {
tempDir = createResolvedTempDirectorySync('test_expression_eval_test.');
await _project.setUpIn(tempDir);
_flutter = FlutterTestTestDriver(tempDir);
await project.setUpIn(tempDir);
flutter = FlutterTestTestDriver(tempDir);
}
Future<void> cleanProject() async {
await _flutter?.waitForCompletion();
await flutter?.waitForCompletion();
tryToDelete(tempDir);
}
testWithoutContext('flutter test expression evaluation - can evaluate trivial expressions in a test', () async {
await initProject();
await _flutter.test(
await flutter.test(
withDebugger: true,
beforeStart: () => _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine),
beforeStart: () => flutter.addBreakpoint(project.breakpointUri, project.breakpointLine),
);
await _flutter.waitForPause();
await evaluateTrivialExpressions(_flutter);
await flutter.waitForPause();
await evaluateTrivialExpressions(flutter);
await cleanProject();
});
testWithoutContext('flutter test expression evaluation - can evaluate complex expressions in a test', () async {
await initProject();
await _flutter.test(
await flutter.test(
withDebugger: true,
beforeStart: () => _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine),
beforeStart: () => flutter.addBreakpoint(project.breakpointUri, project.breakpointLine),
);
await _flutter.waitForPause();
await evaluateComplexExpressions(_flutter);
await flutter.waitForPause();
await evaluateComplexExpressions(flutter);
await cleanProject();
});
testWithoutContext('flutter test expression evaluation - can evaluate expressions returning complex objects in a test', () async {
await initProject();
await _flutter.test(
await flutter.test(
withDebugger: true,
beforeStart: () => _flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine),
beforeStart: () => flutter.addBreakpoint(project.breakpointUri, project.breakpointLine),
);
await _flutter.waitForPause();
await evaluateComplexReturningExpressions(_flutter);
await flutter.waitForPause();
await evaluateComplexReturningExpressions(flutter);
await cleanProject();
});
}

View File

@@ -13,15 +13,15 @@ import 'test_driver.dart';
import 'test_utils.dart';
void main() {
FlutterRunTestDriver _flutterRun, _flutterAttach;
final BasicProject _project = BasicProject();
FlutterRunTestDriver flutterRun, flutterAttach;
final BasicProject project = BasicProject();
Directory tempDir;
setUp(() async {
tempDir = createResolvedTempDirectorySync('attach_test.');
await _project.setUpIn(tempDir);
_flutterRun = FlutterRunTestDriver(tempDir, logPrefix: ' RUN ');
_flutterAttach = FlutterRunTestDriver(
await project.setUpIn(tempDir);
flutterRun = FlutterRunTestDriver(tempDir, logPrefix: ' RUN ');
flutterAttach = FlutterRunTestDriver(
tempDir,
logPrefix: 'ATTACH ',
// Only one DDS instance can be connected to the VM service at a time.
@@ -32,74 +32,74 @@ void main() {
});
tearDown(() async {
await _flutterAttach.detach();
await _flutterRun.stop();
await flutterAttach.detach();
await flutterRun.stop();
tryToDelete(tempDir);
});
testWithoutContext('can hot reload', () async {
await _flutterRun.run(withDebugger: true);
await _flutterAttach.attach(_flutterRun.vmServicePort);
await _flutterAttach.hotReload();
await flutterRun.run(withDebugger: true);
await flutterAttach.attach(flutterRun.vmServicePort);
await flutterAttach.hotReload();
});
testWithoutContext('can detach, reattach, hot reload', () async {
await _flutterRun.run(withDebugger: true);
await _flutterAttach.attach(_flutterRun.vmServicePort);
await _flutterAttach.detach();
await _flutterAttach.attach(_flutterRun.vmServicePort);
await _flutterAttach.hotReload();
await flutterRun.run(withDebugger: true);
await flutterAttach.attach(flutterRun.vmServicePort);
await flutterAttach.detach();
await flutterAttach.attach(flutterRun.vmServicePort);
await flutterAttach.hotReload();
});
testWithoutContext('killing process behaves the same as detach ', () async {
await _flutterRun.run(withDebugger: true);
await _flutterAttach.attach(_flutterRun.vmServicePort);
await _flutterAttach.quit();
_flutterAttach = FlutterRunTestDriver(
await flutterRun.run(withDebugger: true);
await flutterAttach.attach(flutterRun.vmServicePort);
await flutterAttach.quit();
flutterAttach = FlutterRunTestDriver(
tempDir,
logPrefix: 'ATTACH-2',
spawnDdsInstance: false,
);
await _flutterAttach.attach(_flutterRun.vmServicePort);
await _flutterAttach.hotReload();
await flutterAttach.attach(flutterRun.vmServicePort);
await flutterAttach.hotReload();
});
testWithoutContext('sets activeDevToolsServerAddress extension', () async {
await _flutterRun.run(
await flutterRun.run(
startPaused: true,
withDebugger: true,
additionalCommandArgs: <String>['--devtools-server-address', 'http://127.0.0.1:9105'],
);
await _flutterRun.resume();
await flutterRun.resume();
await pollForServiceExtensionValue<String>(
testDriver: _flutterRun,
testDriver: flutterRun,
extension: 'ext.flutter.activeDevToolsServerAddress',
continuePollingValue: '',
matches: equals('http://127.0.0.1:9105'),
);
await pollForServiceExtensionValue<String>(
testDriver: _flutterRun,
testDriver: flutterRun,
extension: 'ext.flutter.connectedVmServiceUri',
continuePollingValue: '',
matches: isNotEmpty,
);
final Response response = await _flutterRun.callServiceExtension('ext.flutter.connectedVmServiceUri');
final Response response = await flutterRun.callServiceExtension('ext.flutter.connectedVmServiceUri');
final String vmServiceUri = response.json['value'] as String;
// Attach with a different DevTools server address.
await _flutterAttach.attach(
_flutterRun.vmServicePort,
await flutterAttach.attach(
flutterRun.vmServicePort,
additionalCommandArgs: <String>['--devtools-server-address', 'http://127.0.0.1:9110'],
);
await pollForServiceExtensionValue<String>(
testDriver: _flutterAttach,
testDriver: flutterAttach,
extension: 'ext.flutter.activeDevToolsServerAddress',
continuePollingValue: '',
matches: equals('http://127.0.0.1:9110'),
);
await pollForServiceExtensionValue<String>(
testDriver: _flutterRun,
testDriver: flutterRun,
extension: 'ext.flutter.connectedVmServiceUri',
continuePollingValue: '',
matches: equals(vmServiceUri),

View File

@@ -15,17 +15,17 @@ import 'test_utils.dart';
void main() {
Directory tempDir;
final BasicProject _project = BasicProject();
FlutterRunTestDriver _flutter;
final BasicProject project = BasicProject();
FlutterRunTestDriver flutter;
setUp(() async {
tempDir = createResolvedTempDirectorySync('run_test.');
await _project.setUpIn(tempDir);
_flutter = FlutterRunTestDriver(tempDir);
await project.setUpIn(tempDir);
flutter = FlutterRunTestDriver(tempDir);
});
tearDown(() async {
await _flutter.stop();
await flutter.stop();
tryToDelete(tempDir);
});
@@ -36,35 +36,35 @@ void main() {
// some of the checks for devices.
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
const ProcessManager _processManager = LocalProcessManager();
final ProcessResult _proc = await _processManager.run(
const ProcessManager processManager = LocalProcessManager();
final ProcessResult proc = await processManager.run(
<String>[flutterBin, 'run', '-d', 'invalid-device-id'],
workingDirectory: tempDir.path,
);
expect(_proc.stdout, isNot(contains('flutter has exited unexpectedly')));
expect(_proc.stderr, isNot(contains('flutter has exited unexpectedly')));
if (!_proc.stderr.toString().contains('Unable to locate a development')
&& !_proc.stdout.toString().contains('No devices found with name or id matching')) {
expect(proc.stdout, isNot(contains('flutter has exited unexpectedly')));
expect(proc.stderr, isNot(contains('flutter has exited unexpectedly')));
if (!proc.stderr.toString().contains('Unable to locate a development')
&& !proc.stdout.toString().contains('No devices found with name or id matching')) {
fail("'flutter run -d invalid-device-id' did not produce the expected error");
}
});
testWithoutContext('sets activeDevToolsServerAddress extension', () async {
await _flutter.run(
await flutter.run(
startPaused: true,
withDebugger: true,
additionalCommandArgs: <String>['--devtools-server-address', 'http://127.0.0.1:9110'],
);
await _flutter.resume();
await flutter.resume();
await pollForServiceExtensionValue<String>(
testDriver: _flutter,
testDriver: flutter,
extension: 'ext.flutter.activeDevToolsServerAddress',
continuePollingValue: '',
matches: equals('http://127.0.0.1:9110'),
);
await pollForServiceExtensionValue<String>(
testDriver: _flutter,
testDriver: flutter,
extension: 'ext.flutter.connectedVmServiceUri',
continuePollingValue: '',
matches: isNotEmpty,

View File

@@ -18,14 +18,14 @@ import 'test_utils.dart';
void main() {
Directory tempDir;
final ProjectWithEarlyError _project = ProjectWithEarlyError();
const String _exceptionStart = '══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞══════════════════';
FlutterRunTestDriver _flutter;
final ProjectWithEarlyError project = ProjectWithEarlyError();
const String exceptionStart = '══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞══════════════════';
FlutterRunTestDriver flutter;
setUp(() async {
tempDir = createResolvedTempDirectorySync('run_test.');
await _project.setUpIn(tempDir);
_flutter = FlutterRunTestDriver(tempDir);
await project.setUpIn(tempDir);
flutter = FlutterRunTestDriver(tempDir);
});
tearDown(() async {
@@ -75,23 +75,23 @@ void main() {
await process.exitCode;
expect(stdout.toString(), contains(_exceptionStart));
expect(stdout.toString(), contains(exceptionStart));
});
testWithoutContext('flutter run in machine mode does not print an error', () async {
final StringBuffer stdout = StringBuffer();
await _flutter.run(
await flutter.run(
startPaused: true,
withDebugger: true,
structuredErrors: true,
);
await _flutter.resume();
await flutter.resume();
final Completer<void> completer = Completer<void>();
await Future<void>(() async {
_flutter.stdout.listen((String line) {
flutter.stdout.listen((String line) {
stdout.writeln(line);
});
await completer.future;
@@ -99,8 +99,8 @@ void main() {
// We don't expect to see any output but want to write to stdout anyway.
completer.complete();
});
await _flutter.stop();
await flutter.stop();
expect(stdout.toString(), isNot(contains(_exceptionStart)));
expect(stdout.toString(), isNot(contains(exceptionStart)));
});
}

View File

@@ -17,30 +17,30 @@ import 'test_utils.dart';
const Duration requiredLifespan = Duration(seconds: 5);
void main() {
final BasicProject _project = BasicProject();
FlutterRunTestDriver _flutter;
final BasicProject project = BasicProject();
FlutterRunTestDriver flutter;
Directory tempDir;
setUp(() async {
tempDir = createResolvedTempDirectorySync('lifetime_test.');
await _project.setUpIn(tempDir);
_flutter = FlutterRunTestDriver(tempDir);
await project.setUpIn(tempDir);
flutter = FlutterRunTestDriver(tempDir);
});
tearDown(() async {
await _flutter.stop();
await flutter.stop();
tryToDelete(tempDir);
});
testWithoutContext('flutter run does not terminate when a debugger is attached', () async {
await _flutter.run(withDebugger: true);
await flutter.run(withDebugger: true);
await Future<void>.delayed(requiredLifespan);
expect(_flutter.hasExited, equals(false));
expect(flutter.hasExited, equals(false));
});
testWithoutContext('flutter run does not terminate when a debugger is attached and pause-on-exceptions', () async {
await _flutter.run(withDebugger: true, pauseOnExceptions: true);
await flutter.run(withDebugger: true, pauseOnExceptions: true);
await Future<void>.delayed(requiredLifespan);
expect(_flutter.hasExited, equals(false));
expect(flutter.hasExited, equals(false));
});
}

View File

@@ -14,15 +14,15 @@ import 'test_utils.dart';
void main() {
Directory tempDir;
FlutterRunTestDriver _flutter;
FlutterRunTestDriver flutter;
setUp(() async {
tempDir = createResolvedTempDirectorySync('run_test.');
_flutter = FlutterRunTestDriver(tempDir);
flutter = FlutterRunTestDriver(tempDir);
});
tearDown(() async {
await _flutter.stop();
await flutter.stop();
tryToDelete(tempDir);
});

View File

@@ -44,11 +44,11 @@ Future<void> waitForObservatoryMessage(Process process, int port) async {
void main() {
Directory tempDir;
final BasicProject _project = BasicProject();
final BasicProject project = BasicProject();
setUp(() async {
tempDir = createResolvedTempDirectorySync('run_test.');
await _project.setUpIn(tempDir);
await project.setUpIn(tempDir);
});
tearDown(() async {

View File

@@ -17,33 +17,33 @@ import 'test_utils.dart';
// stateful one and back.
void main() {
Directory tempDir;
final HotReloadProject _project = HotReloadProject();
FlutterRunTestDriver _flutter;
final HotReloadProject project = HotReloadProject();
FlutterRunTestDriver flutter;
setUp(() async {
tempDir = createResolvedTempDirectorySync('hot_reload_test.');
await _project.setUpIn(tempDir);
_flutter = FlutterRunTestDriver(tempDir);
await project.setUpIn(tempDir);
flutter = FlutterRunTestDriver(tempDir);
});
tearDown(() async {
await _flutter?.stop();
await flutter?.stop();
tryToDelete(tempDir);
});
testWithoutContext('Can switch between stateless and stateful', () async {
await _flutter.run();
await _flutter.hotReload();
await flutter.run();
await flutter.hotReload();
final StringBuffer stdout = StringBuffer();
final StreamSubscription<String> subscription = _flutter.stdout.listen(stdout.writeln);
final StreamSubscription<String> subscription = flutter.stdout.listen(stdout.writeln);
// switch to stateful.
_project.toggleState();
await _flutter.hotReload();
project.toggleState();
await flutter.hotReload();
// switch to stateless.
_project.toggleState();
await _flutter.hotReload();
project.toggleState();
await flutter.hotReload();
final String logs = stdout.toString();

View File

@@ -103,8 +103,8 @@ abstract class FlutterTestDriver {
}
_debugPrint('Spawning flutter $arguments in ${_projectFolder.path}');
const ProcessManager _processManager = LocalProcessManager();
_process = await _processManager.start(
const ProcessManager processManager = LocalProcessManager();
_process = await processManager.start(
<String>[flutterBin]
.followedBy(arguments)
.toList(),
@@ -760,8 +760,8 @@ class FlutterRunTestDriver extends FlutterTestDriver {
}
class FlutterTestTestDriver extends FlutterTestDriver {
FlutterTestTestDriver(Directory _projectFolder, {String? logPrefix})
: super(_projectFolder, logPrefix: logPrefix);
FlutterTestTestDriver(Directory projectFolder, {String? logPrefix})
: super(projectFolder, logPrefix: logPrefix);
Future<void> test({
String testFile = 'test/test.dart',

View File

@@ -21,8 +21,8 @@ void main() {
setUp(() async {
tempDir = createResolvedTempDirectorySync('vmservice_integration_test.');
final BasicProject _project = BasicProject();
await _project.setUpIn(tempDir);
final BasicProject project = BasicProject();
await project.setUpIn(tempDir);
flutter = FlutterRunTestDriver(tempDir);
await flutter.run(withDebugger: true);

View File

@@ -20,27 +20,27 @@ void main() {
});
testWithoutContext('Web debugger can step over statements', () async {
final WebSteppingProject _project = WebSteppingProject();
await _project.setUpIn(tempDirectory);
final WebSteppingProject project = WebSteppingProject();
await project.setUpIn(tempDirectory);
flutter = FlutterRunTestDriver(tempDirectory);
await flutter.run(
withDebugger: true, startPaused: true, chrome: true,
additionalCommandArgs: <String>['--verbose', '--web-renderer=html']);
await flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine);
await flutter.addBreakpoint(project.breakpointUri, project.breakpointLine);
await flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint.
expect((await flutter.getSourceLocation()).line, equals(_project.breakpointLine));
expect((await flutter.getSourceLocation()).line, equals(project.breakpointLine));
// Issue 5 steps, ensuring that we end up on the annotated lines each time.
for (int i = 1; i <= _project.numberOfSteps; i += 1) {
for (int i = 1; i <= project.numberOfSteps; i += 1) {
await flutter.stepOverOrOverAsyncSuspension();
final SourcePosition location = await flutter.getSourceLocation();
final int actualLine = location.line;
// Get the line we're expected to stop at by searching for the comment
// within the source code.
final int expectedLine = _project.lineForStep(i);
final int expectedLine = project.lineForStep(i);
expect(actualLine, equals(expectedLine),
reason: 'After $i steps, debugger should stop at $expectedLine but stopped at $actualLine'