Enable "omit_local_variable_types" lint in test_runner and fix violations.

Also turned a couple of "final" locals to "var" to be consistent with others.
Removed a no-longer valid analysis option.

Change-Id: I741989b20199ba8f1e86e464e1cf994137332fad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128500
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
This commit is contained in:
Robert Nystrom 2019-12-17 19:48:54 +00:00 committed by commit-bot@chromium.org
parent 3fc1fe9af9
commit cb2cbb7074
23 changed files with 156 additions and 166 deletions

View file

@ -1,15 +1,12 @@
analyzer:
strong-mode:
implicit-casts: false
errors:
override_on_non_overriding_method: error
linter:
rules:
# TODO: Enable these once the existing violations have been fixed.
# - annotate_overrides
# - avoid_renaming_method_parameters
# - non_constant_identifier_names
# - omit_local_variable_types
# - only_throw_errors
# - prefer_initializing_formals
# - prefer_interpolation_to_compose_strings
@ -50,6 +47,7 @@ linter:
- list_remove_unrelated_type
- no_duplicate_case_values
- null_closures
- omit_local_variable_types
- overridden_fields
- package_api_docs
- package_names

View file

@ -54,7 +54,7 @@ Future<AdbCommandResult> _executeCommand(String executable, List<String> args,
process.stdin.close();
Timer timer;
bool timedOut = false;
var timedOut = false;
if (timeout != null) {
timer = Timer(timeout, () {
timedOut = true;
@ -70,7 +70,7 @@ Future<AdbCommandResult> _executeCommand(String executable, List<String> args,
]);
if (timer != null) timer.cancel();
String command = "$executable ${args.join(' ')}";
var command = "$executable ${args.join(' ')}";
return AdbCommandResult(command, results[0] as String, results[1] as String,
results[2] as int, timedOut);
});
@ -190,7 +190,7 @@ class AdbDevice {
Future<Null> waitForBootCompleted() async {
while (true) {
try {
AdbCommandResult result =
var result =
await _adbCommand(['shell', 'getprop', 'sys.boot_completed']);
if (result.stdout.trim() == '1') return;
} catch (_) {}
@ -295,7 +295,7 @@ class AdbDevice {
.where((line) => line.trim().isNotEmpty)
.toList();
if (lines.isNotEmpty) {
int index = lines.last.indexOf(marker);
var index = lines.last.indexOf(marker);
if (index >= 0) {
exitCode =
int.parse(lines.last.substring(index + marker.length).trim());

View file

@ -58,7 +58,7 @@ String _toJSIdentifier(String name) {
// Escape any invalid characters
StringBuffer buffer;
for (int i = 0; i < name.length; i++) {
for (var i = 0; i < name.length; i++) {
var ch = name[i];
var needsEscape = ch == r'$' || _invalidCharInIdentifier.hasMatch(ch);
if (needsEscape && buffer == null) {

View file

@ -290,7 +290,7 @@ class Safari extends Browser {
});
});
Future zoneWrapper() {
Uri safariUri = Uri.base.resolve(safariBundleLocation);
var safariUri = Uri.base.resolve(safariBundleLocation);
return Future(() => killAndResetSafari(bundle: safariUri))
.then(completer.complete);
}
@ -526,7 +526,7 @@ class IE extends Browser {
data: "1", type: "REG_DWORD");
var localAppData = Platform.environment['LOCALAPPDATA'];
Directory dir = Directory("$localAppData\\Microsoft\\"
var dir = Directory("$localAppData\\Microsoft\\"
"Internet Explorer\\Recovery");
return dir.delete(recursive: true).then((_) {
return true;
@ -865,7 +865,7 @@ class BrowserTestRunner {
Browser browser;
if (configuration.runtime == Runtime.chromeOnAndroid) {
AdbDevice device = idleAdbDevices.removeLast();
var device = idleAdbDevices.removeLast();
adbDeviceMapping[id] = device;
browser = AndroidChrome(device);
} else {
@ -1036,7 +1036,7 @@ class BrowserTestRunner {
return null;
}
BrowserTest test = testQueue.removeLast();
var test = testQueue.removeLast();
// If our queue isn't empty, try starting more browsers
if (testQueue.isEmpty) {
lastEmptyTestQueueTime = DateTime.now();
@ -1133,7 +1133,7 @@ class BrowserTestRunner {
var browsers = <Browser>[];
underTermination = true;
testingServer.underTermination = true;
for (BrowserStatus status in browserStatus.values) {
for (var status in browserStatus.values) {
browsers.add(status.browser);
if (status.nextTestTimeout != null) {
status.nextTestTimeout.cancel();

View file

@ -287,7 +287,7 @@ class FastaCompilationCommand extends CompilationCommand {
return escapeCommandLineArgument(argument);
}
StringBuffer buffer = StringBuffer();
var buffer = StringBuffer();
if (workingDirectory != null && !io.Platform.isWindows) {
buffer.write("(cd ");
buffer.write(escapeCommandLineArgument(workingDirectory));

View file

@ -88,7 +88,7 @@ class CommandOutput {
// codes basically saying that codes starting with 0xC0, 0x80 or 0x40
// are crashes, so look at the 4 most significant bits in 32-bit-space
// make sure its either 0b1100, 0b1000 or 0b0100.
int masked = (exitCode & 0xF0000000) >> 28;
var masked = (exitCode & 0xF0000000) >> 28;
return (exitCode < 0) && (masked >= 4) && ((masked & 3) == 0);
}
return exitCode < 0;
@ -880,7 +880,7 @@ class VMKernelCompilationCommandOutput extends CompilationCommandOutput {
// between different kinds of failures and will mark a failed
// compilation to just an exit code of "1". So we treat all `exitCode ==
// 1`s as compile-time errors as well.
const int kBatchModeCompileTimeErrorExit = 1;
const batchModeCompileTimeErrorExit = 1;
// Handle crashes and timeouts first.
if (hasCrashed) return Expectation.dartkCrash;
@ -896,7 +896,7 @@ class VMKernelCompilationCommandOutput extends CompilationCommandOutput {
// Multitests are handled specially.
if (testCase.hasCompileError) {
if (exitCode == VMCommandOutput._compileErrorExitCode ||
exitCode == kBatchModeCompileTimeErrorExit) {
exitCode == batchModeCompileTimeErrorExit) {
return Expectation.pass;
}
return Expectation.missingCompileTimeError;
@ -904,7 +904,7 @@ class VMKernelCompilationCommandOutput extends CompilationCommandOutput {
// The actual outcome depends on the exitCode.
if (exitCode == VMCommandOutput._compileErrorExitCode ||
exitCode == kBatchModeCompileTimeErrorExit) {
exitCode == batchModeCompileTimeErrorExit) {
return Expectation.compileTimeError;
} else if (exitCode != 0) {
// This is a general fail, in case we get an unknown nonzero exitcode.
@ -922,7 +922,7 @@ class VMKernelCompilationCommandOutput extends CompilationCommandOutput {
// between different kinds of failures and will mark a failed
// compilation to just an exit code of "1". So we treat all `exitCode ==
// 1`s as compile-time errors as well.
const int kBatchModeCompileTimeErrorExit = 1;
const batchModeCompileTimeErrorExit = 1;
// Handle crashes and timeouts first.
if (hasCrashed) return Expectation.dartkCrash;
@ -938,7 +938,7 @@ class VMKernelCompilationCommandOutput extends CompilationCommandOutput {
// Multitests are handled specially.
if (exitCode == VMCommandOutput._compileErrorExitCode ||
exitCode == kBatchModeCompileTimeErrorExit) {
exitCode == batchModeCompileTimeErrorExit) {
return Expectation.compileTimeError;
}
if (exitCode != 0) {

View file

@ -312,7 +312,7 @@ class ComposedCompilerConfiguration extends CompilerConfiguration {
// The first compilation command is as usual.
var arguments = pipelineCommands[0].extractArguments(globalArguments, null);
CommandArtifact artifact = pipelineCommands[0]
var artifact = pipelineCommands[0]
.compilerConfiguration
.computeCompilationArtifact(tempDir, arguments, environmentOverrides);
allCommands.addAll(artifact.commands);
@ -320,7 +320,7 @@ class ComposedCompilerConfiguration extends CompilerConfiguration {
// The following compilation commands are based on the output of the
// previous one.
for (var i = 1; i < pipelineCommands.length; i++) {
PipelineCommand command = pipelineCommands[i];
var command = pipelineCommands[i];
arguments = command.extractArguments(globalArguments, artifact.filename);
artifact = command.compilerConfiguration
@ -351,8 +351,7 @@ class ComposedCompilerConfiguration extends CompilerConfiguration {
List<String> vmOptions,
List<String> originalArguments,
CommandArtifact artifact) {
CompilerConfiguration lastCompilerConfiguration =
pipelineCommands.last.compilerConfiguration;
var lastCompilerConfiguration = pipelineCommands.last.compilerConfiguration;
return lastCompilerConfiguration.computeRuntimeArguments(
runtimeConfiguration, testFile, vmOptions, originalArguments, artifact);
}
@ -458,10 +457,10 @@ class Dart2jsCompilerConfiguration extends Dart2xCompilerConfiguration {
List<String> vmOptions,
List<String> originalArguments,
CommandArtifact artifact) {
Uri sdk = _useSdk
var sdk = _useSdk
? Uri.directory(_configuration.buildDirectory).resolve('dart-sdk/')
: Uri.directory(Repository.dir.toNativePath()).resolve('sdk/');
Uri preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/');
var preambleDir = sdk.resolve('lib/_internal/js_runtime/lib/preambles/');
return runtimeConfiguration.dart2jsPreambles(preambleDir)
..add(artifact.filename);
}
@ -775,12 +774,9 @@ class PrecompilerCompilerConfiguration extends CompilerConfiguration
Command computeStripCommand(
String tempDir, Map<String, String> environmentOverrides) {
final String stripTool = "$ndkPath/toolchains/$abiTriple-4.9/prebuilt/"
var stripTool = "$ndkPath/toolchains/$abiTriple-4.9/prebuilt/"
"$host-x86_64/bin/$abiTriple-strip";
final List<String> args = [
'--strip-unneeded',
"$tempDir/out.aotsnapshot",
];
var args = ['--strip-unneeded', "$tempDir/out.aotsnapshot"];
return CompilationCommand('strip', tempDir, bootstrapDependencies(),
stripTool, args, environmentOverrides,
alwaysCompile: !_useSdk);
@ -1041,10 +1037,10 @@ abstract class VMKernelCompilerMixin {
Command computeCompileToKernelCommand(String tempDir, List<String> arguments,
Map<String, String> environmentOverrides) {
final pkgVmDir = Platform.script.resolve('../../../pkg/vm').toFilePath();
final genKernel = '$pkgVmDir/tool/gen_kernel$shellScriptExtension';
var pkgVmDir = Platform.script.resolve('../../../pkg/vm').toFilePath();
var genKernel = '$pkgVmDir/tool/gen_kernel$shellScriptExtension';
final String useAbiVersion = arguments.firstWhere(
var useAbiVersion = arguments.firstWhere(
(arg) => arg.startsWith('--use-abi-version='),
orElse: () => null);

View file

@ -47,10 +47,7 @@ class Graph<T> {
bool get isSealed => _isSealed;
/// Counts the number of nodes who are in [state].
int stateCount(NodeState state) {
int count = _stateCounts[state];
return count == null ? 0 : count;
}
int stateCount(NodeState state) => _stateCounts[state] ?? 0;
void dumpCounts() {
for (var state in _stateCounts.keys) {

View file

@ -609,9 +609,11 @@ compiler.''',
.resolve('runtime/observatory/.packages')
.toFilePath();
return _expandConfigurations(configuration, selectors)
..addAll(_expandConfigurations(
observatoryConfiguration, observatorySelectors));
return [
..._expandConfigurations(configuration, selectors),
..._expandConfigurations(
observatoryConfiguration, observatorySelectors)
];
}
}
@ -738,12 +740,12 @@ compiler.''',
}
}
String namedConfigurationOption = data["named_configuration"] as String;
var namedConfigurationOption = data["named_configuration"] as String;
if (namedConfigurationOption != null) {
List<String> namedConfigurations = namedConfigurationOption.split(',');
var namedConfigurations = namedConfigurationOption.split(',');
var testMatrixFile = "tools/bots/test_matrix.json";
var testMatrix = TestMatrix.fromPath(testMatrixFile);
for (String namedConfiguration in namedConfigurations) {
for (var namedConfiguration in namedConfigurations) {
var configuration = testMatrix.configurations.singleWhere(
(c) => c.name == namedConfiguration,
orElse: () => null);
@ -775,14 +777,15 @@ compiler.''',
// Expand compilers.
for (var compiler in compilers) {
// Expand modes.
String modes = (data["mode"] as String) ?? compiler.defaultMode.name;
var modes = (data["mode"] as String) ?? compiler.defaultMode.name;
if (modes == "all") modes = "debug,release,product";
for (var modeName in modes.split(",")) {
var mode = Mode.find(modeName);
// Expand sanitizers.
String sanitizers = (data["sanitizer"] as String) ?? "none";
if (sanitizers == "all")
var sanitizers = (data["sanitizer"] as String) ?? "none";
if (sanitizers == "all") {
sanitizers = "none,asan,lsan,msan,tsan,ubsan";
}
for (var sanitizerName in sanitizers.split(",")) {
var sanitizer = Sanitizer.find(sanitizerName);
var system = System.find(data["system"] as String);

View file

@ -77,12 +77,12 @@ class Path {
var basePath = base.toString();
// Handle drive letters specially on Windows.
if (base.isAbsolute && Platform.operatingSystem == 'windows') {
bool baseHasDrive =
var baseHasDrive =
basePath.length >= 4 && basePath[2] == ':' && basePath[3] == '/';
bool pathHasDrive =
var pathHasDrive =
_path.length >= 4 && _path[2] == ':' && _path[3] == '/';
if (baseHasDrive && pathHasDrive) {
int baseDrive = basePath.codeUnitAt(1) | 32; // Convert to uppercase.
var baseDrive = basePath.codeUnitAt(1) | 32; // Convert to uppercase.
if (baseDrive >= 'a'.codeUnitAt(0) &&
baseDrive <= 'z'.codeUnitAt(0) &&
baseDrive == (_path.codeUnitAt(1) | 32)) {
@ -106,7 +106,7 @@ class Path {
if (_path.startsWith(basePath)) {
if (_path == basePath) return Path('.');
// There must be a '/' at the end of the match, or immediately after.
int matchEnd = basePath.length;
var matchEnd = basePath.length;
if (_path[matchEnd - 1] == '/' || _path[matchEnd] == '/') {
// Drop any extra '/' characters at matchEnd
while (matchEnd < _path.length && _path[matchEnd] == '/') {
@ -116,16 +116,16 @@ class Path {
}
}
List<String> baseSegments = base.canonicalize().segments();
List<String> pathSegments = canonicalize().segments();
var baseSegments = base.canonicalize().segments();
var pathSegments = canonicalize().segments();
if (baseSegments.length == 1 && baseSegments[0] == '.') {
baseSegments = [];
}
if (pathSegments.length == 1 && pathSegments[0] == '.') {
pathSegments = [];
}
int common = 0;
int length = min(pathSegments.length, baseSegments.length);
var common = 0;
var length = min(pathSegments.length, baseSegments.length);
while (common < length && pathSegments[common] == baseSegments[common]) {
common++;
}
@ -136,10 +136,10 @@ class Path {
" Base path has more '..'s than path does.\n"
" Arguments: $_path.relativeTo($base)");
}
for (int i = common; i < baseSegments.length; i++) {
for (var i = common; i < baseSegments.length; i++) {
segments.add('..');
}
for (int i = common; i < pathSegments.length; i++) {
for (var i = common; i < pathSegments.length; i++) {
segments.add('${pathSegments[i]}');
}
if (segments.isEmpty) {
@ -187,7 +187,7 @@ class Path {
segs[0] = null; // Faster than removeRange().
} else {
// A canonical relative path may start with .. segments.
for (int pos = 0; pos < segs.length && segs[pos] == '..'; ++pos) {
for (var pos = 0; pos < segs.length && segs[pos] == '..'; ++pos) {
segs[pos] = null;
}
}
@ -257,7 +257,7 @@ class Path {
String toNativePath() {
if (isEmpty) return '.';
if (Platform.operatingSystem == 'windows') {
String nativePath = _path;
var nativePath = _path;
// Drop '/' before a drive letter.
if (nativePath.length >= 3 &&
nativePath.startsWith('/') &&
@ -293,18 +293,18 @@ class Path {
String get filenameWithoutExtension {
var name = filename;
if (name == '.' || name == '..') return name;
int pos = name.lastIndexOf('.');
var pos = name.lastIndexOf('.');
return (pos < 0) ? name : name.substring(0, pos);
}
String get extension {
var name = filename;
int pos = name.lastIndexOf('.');
var pos = name.lastIndexOf('.');
return (pos < 0) ? '' : name.substring(pos + 1);
}
Path get directoryPath {
int pos = _path.lastIndexOf('/');
var pos = _path.lastIndexOf('/');
if (pos < 0) return Path('');
while (pos > 0 && _path[pos - 1] == '/') {
--pos;
@ -314,7 +314,7 @@ class Path {
}
String get filename {
int pos = _path.lastIndexOf('/');
var pos = _path.lastIndexOf('/');
return _path.substring(pos + 1);
}
}

View file

@ -54,7 +54,7 @@ class ProcessQueue {
print("\nGenerating all matching test cases ....\n");
for (TestCase testCase in testCases) {
for (var testCase in testCases) {
eventFinishedTestCase(testCase);
var outcomes = testCase.expectedOutcomes.map((o) => '$o').toList()
..sort();
@ -322,11 +322,11 @@ class CommandEnqueuer {
/// changed it's state.
void _changeNodeStateIfNecessary(Node<Command> node) {
if (_initStates.contains(node.state)) {
bool allDependenciesFinished =
var allDependenciesFinished =
node.dependencies.every((dep) => _finishedStates.contains(dep.state));
bool anyDependenciesUnsuccessful = node.dependencies.any((dep) =>
var anyDependenciesUnsuccessful = node.dependencies.any((dep) =>
[NodeState.failed, NodeState.unableToRun].contains(dep.state));
bool allDependenciesSuccessful =
var allDependenciesSuccessful =
node.dependencies.every((dep) => dep.state == NodeState.successful);
var newState = NodeState.waiting;
@ -406,7 +406,7 @@ class CommandQueue {
_checkDone();
if (_numProcesses < _maxProcesses && !_runQueue.isEmpty) {
Command command = _runQueue.removeFirst();
var command = _runQueue.removeFirst();
var isBrowserCommand = command is BrowserTestCommand;
if (isBrowserCommand && _numBrowserProcesses == _maxBrowserProcesses) {
@ -425,7 +425,7 @@ class CommandQueue {
// If a command is part of many TestCases we set the timeout to be
// the maximum over all [TestCase.timeout]s. At some point, we might
// eliminate [TestCase.timeout] completely and move it to [Command].
int timeout =
var timeout =
testCases.map((TestCase test) => test.timeout).fold(0, math.max);
if (_verbose) {
@ -621,7 +621,7 @@ class CommandExecutorImpl implements CommandExecutor {
List<_StepFunction> _pushLibraries(AdbCommand command, AdbDevice device,
String deviceDir, String deviceTestDir) {
final List<_StepFunction> steps = [];
var steps = <_StepFunction>[];
for (var lib in command.extraLibraries) {
var libName = "lib$lib.so";
steps.add(() => device.runAdbCommand([
@ -635,7 +635,7 @@ class CommandExecutorImpl implements CommandExecutor {
Future<CommandOutput> _runAdbPrecompilationCommand(
AdbDevice device, AdbPrecompilationCommand command, int timeout) async {
final String buildPath = command.buildPath;
var buildPath = command.buildPath;
var processTest = command.processTestFilename;
var testdir = command.precompiledTestDirectory;
var arguments = command.arguments;
@ -644,7 +644,7 @@ class CommandExecutorImpl implements CommandExecutor {
// We copy all the files which the vm precompiler puts into the test
// directory.
List<String> files = io.Directory(testdir)
var files = io.Directory(testdir)
.listSync()
.map((file) => file.path)
.map((path) => path.substring(path.lastIndexOf('/') + 1))
@ -714,15 +714,15 @@ class CommandExecutorImpl implements CommandExecutor {
Future<CommandOutput> _runAdbDartkCommand(
AdbDevice device, AdbDartkCommand command, int timeout) async {
final String buildPath = command.buildPath;
final String hostKernelFile = command.kernelFile;
final List<String> arguments = command.arguments;
final String devicedir = DartkAdbRuntimeConfiguration.deviceDir;
final String deviceTestDir = DartkAdbRuntimeConfiguration.deviceTestDir;
var buildPath = command.buildPath;
var hostKernelFile = command.kernelFile;
var arguments = command.arguments;
var devicedir = DartkAdbRuntimeConfiguration.deviceDir;
var deviceTestDir = DartkAdbRuntimeConfiguration.deviceTestDir;
final timeoutDuration = Duration(seconds: timeout);
var timeoutDuration = Duration(seconds: timeout);
final steps = <_StepFunction>[];
var steps = <_StepFunction>[];
steps.add(() => device.runAdbShellCommand(['rm', '-Rf', deviceTestDir]));
steps.add(() => device.runAdbShellCommand(['mkdir', '-p', deviceTestDir]));
@ -777,7 +777,7 @@ class CommandExecutorImpl implements CommandExecutor {
var runners = _batchProcesses[identifier];
if (runners == null) {
runners = List<BatchRunnerProcess>(maxProcesses);
for (int i = 0; i < maxProcesses; i++) {
for (var i = 0; i < maxProcesses; i++) {
runners[i] = BatchRunnerProcess(useJson: identifier == "fasta");
}
_batchProcesses[identifier] = runners;
@ -793,9 +793,9 @@ class CommandExecutorImpl implements CommandExecutor {
BrowserTestCommand browserCommand, int timeout) {
var completer = Completer<CommandOutput>();
var callback = (BrowserTestOutput output) {
callback(BrowserTestOutput output) {
completer.complete(BrowserCommandOutput(browserCommand, output));
};
}
var browserTest = BrowserTest(browserCommand.url, callback, timeout);
_getBrowserTestRunner(browserCommand.configuration).then((testRunner) {
@ -933,7 +933,7 @@ class TestCaseCompleter {
void _completeTestCasesIfPossible(Iterable<TestCase> testCases) {
// Update TestCases with command outputs.
for (TestCase test in testCases) {
for (var test in testCases) {
for (var icommand in test.commands) {
var output = _outputs[icommand];
if (output != null) {
@ -996,7 +996,7 @@ class BatchRunnerProcess {
assert(!_currentlyRunning);
_completer = Completer();
bool sameRunnerType = _runnerType == runnerType &&
var sameRunnerType = _runnerType == runnerType &&
_dictEquals(_processEnvironmentOverrides, command.environmentOverrides);
_runnerType = runnerType;
_currentlyRunning = true;
@ -1129,7 +1129,7 @@ class BatchRunnerProcess {
processFuture.then<dynamic>((io.Process p) {
_process = p;
Stream<String> _stdoutStream = _process.stdout
var _stdoutStream = _process.stdout
.transform(utf8.decoder)
.transform(const LineSplitter());
_stdoutSubscription = _stdoutStream.listen((String line) {
@ -1151,7 +1151,7 @@ class BatchRunnerProcess {
});
_stdoutSubscription.pause();
Stream<String> _stderrStream = _process.stderr
var _stderrStream = _process.stderr
.transform(utf8.decoder)
.transform(const LineSplitter());
_stderrSubscription = _stderrStream.listen((String line) {

View file

@ -191,7 +191,7 @@ Future<Null> resetSafariSettings() async {
home = "$home/";
}
var homeDirectory = Uri.base.resolve(home);
for (String setting in safariSettings) {
for (var setting in safariSettings) {
await deleteIfExists(homeDirectory.resolve(setting));
}
var result = await Process.run(

View file

@ -162,7 +162,7 @@ class CommandLineJavaScriptRuntime extends RuntimeConfiguration {
CommandLineJavaScriptRuntime(this.moniker) : super._subclass();
void checkArtifact(CommandArtifact artifact) {
String type = artifact.mimeType;
var type = artifact.mimeType;
if (type != 'application/javascript') {
throw "Runtime '$moniker' cannot run files of type '$type'.";
}
@ -257,8 +257,8 @@ class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration {
Map<String, String> environmentOverrides,
List<String> extraLibs,
bool isCrashExpected) {
String script = artifact.filename;
String type = artifact.mimeType;
var script = artifact.filename;
var type = artifact.mimeType;
if (script != null &&
type != 'application/dart' &&
type != 'application/dart-snapshot' &&
@ -269,7 +269,7 @@ class StandaloneDartRuntimeConfiguration extends DartVmRuntimeConfiguration {
if (isCrashExpected) {
arguments.insert(0, '--suppress-core-dump');
}
String executable = dartVmBinaryFileName;
var executable = dartVmBinaryFileName;
if (type == 'application/kernel-ir-fully-linked') {
executable = dartVmExecutableFileName;
}
@ -290,8 +290,8 @@ class DartPrecompiledRuntimeConfiguration extends DartVmRuntimeConfiguration {
Map<String, String> environmentOverrides,
List<String> extraLibs,
bool isCrashExpected) {
String script = artifact.filename;
String type = artifact.mimeType;
var script = artifact.filename;
var type = artifact.mimeType;
if (script != null && type != 'application/dart-precompiled') {
throw "dart_precompiled cannot run files of type '$type'.";
}
@ -312,14 +312,14 @@ class DartkAdbRuntimeConfiguration extends DartVmRuntimeConfiguration {
Map<String, String> environmentOverrides,
List<String> extraLibs,
bool isCrashExpected) {
final String script = artifact.filename;
final String type = artifact.mimeType;
var script = artifact.filename;
var type = artifact.mimeType;
if (script != null && type != 'application/kernel-ir-fully-linked') {
throw "dart cannot run files of type '$type'.";
}
final String buildPath = buildDir;
final String processTest = processTestBinaryFileName;
var buildPath = buildDir;
var processTest = processTestBinaryFileName;
return [
AdbDartkCommand(buildPath, processTest, script, arguments, extraLibs)
];
@ -328,9 +328,8 @@ class DartkAdbRuntimeConfiguration extends DartVmRuntimeConfiguration {
class DartPrecompiledAdbRuntimeConfiguration
extends DartVmRuntimeConfiguration {
static const String deviceDir = '/data/local/tmp/precompilation-testing';
static const String deviceTestDir =
'/data/local/tmp/precompilation-testing/test';
static const deviceDir = '/data/local/tmp/precompilation-testing';
static const deviceTestDir = '/data/local/tmp/precompilation-testing/test';
final bool useBlobs;
final bool useElf;
@ -344,13 +343,13 @@ class DartPrecompiledAdbRuntimeConfiguration
Map<String, String> environmentOverrides,
List<String> extraLibs,
bool isCrashExpected) {
String script = artifact.filename;
String type = artifact.mimeType;
var script = artifact.filename;
var type = artifact.mimeType;
if (script != null && type != 'application/dart-precompiled') {
throw "dart_precompiled cannot run files of type '$type'.";
}
String processTest = processTestBinaryFileName;
var processTest = processTestBinaryFileName;
return [
AdbPrecompilationCommand(
buildDir, processTest, script, arguments, useBlobs, useElf, extraLibs)
@ -366,7 +365,7 @@ class SelfCheckRuntimeConfiguration extends DartVmRuntimeConfiguration {
}
void searchForSelfCheckers() {
Uri pkg = Repository.uri.resolve('pkg');
var pkg = Repository.uri.resolve('pkg');
for (var entry in Directory.fromUri(pkg).listSync(recursive: true)) {
if (entry is File && entry.path.endsWith('_self_check.dart')) {
selfCheckers.add(entry.path);
@ -380,7 +379,7 @@ class SelfCheckRuntimeConfiguration extends DartVmRuntimeConfiguration {
Map<String, String> environmentOverrides,
List<String> extraLibs,
bool isCrashExpected) {
String executable = dartVmBinaryFileName;
var executable = dartVmBinaryFileName;
return selfCheckers
.map((String tester) => VMBatchCommand(
executable, tester, arguments, environmentOverrides,

View file

@ -33,16 +33,16 @@ class SummaryReport {
void add(TestCase testCase) {
var expectations = testCase.expectedOutcomes;
bool containsFail = expectations
var containsFail = expectations
.any((expectation) => expectation.canBeOutcomeOf(Expectation.fail));
bool containsPass = expectations.contains(Expectation.pass);
bool containsSkip = expectations
var containsPass = expectations.contains(Expectation.pass);
var containsSkip = expectations
.any((expectation) => expectation.canBeOutcomeOf(Expectation.skip));
bool containsSkipByDesign = expectations.contains(Expectation.skipByDesign);
bool containsCrash = expectations.contains(Expectation.crash);
bool containsOK = expectations.contains(Expectation.ok);
bool containsSlow = expectations.contains(Expectation.slow);
bool containsTimeout = expectations.contains(Expectation.timeout);
var containsSkipByDesign = expectations.contains(Expectation.skipByDesign);
var containsCrash = expectations.contains(Expectation.crash);
var containsOK = expectations.contains(Expectation.ok);
var containsSlow = expectations.contains(Expectation.slow);
var containsTimeout = expectations.contains(Expectation.timeout);
++_total;
if (containsSkip) {
@ -57,7 +57,7 @@ class SummaryReport {
} else {
// We don't do if-else below because the buckets should be exclusive.
// We keep a count around to guarantee that
int markers = 0;
var markers = 0;
// Counts the number of flaky tests.
if (containsFail && containsPass && !containsCrash && !containsOK) {

View file

@ -359,8 +359,8 @@ class RunningProcess {
}
CommandOutput _createCommandOutput(ProcessCommand command, int exitCode) {
List<int> stdoutData = stdout.toList();
List<int> stderrData = stderr.toList();
var stdoutData = stdout.toList();
var stderrData = stderr.toList();
if (stdout.hasNonUtf8 || stderr.hasNonUtf8) {
// If the output contained non-utf8 formatted data, then make the exit
// code non-zero if it isn't already.

View file

@ -267,9 +267,8 @@ class StatusFileUpdatePrinter extends EventListener {
}
void _printFailureOutput(TestCase test) {
String status = '${test.displayName}: ${test.result}';
List<String> configs =
statusToConfigs.putIfAbsent(status, () => <String>[]);
var status = '${test.displayName}: ${test.result}';
var configs = statusToConfigs.putIfAbsent(status, () => <String>[]);
configs.add(test.configurationString);
if (test.lastCommandOutput.hasTimedOut) {
print('\n${test.displayName} timed out on ${test.configurationString}');
@ -279,7 +278,7 @@ class StatusFileUpdatePrinter extends EventListener {
String _extractRuntime(String configuration) {
// Extract runtime from a configuration, for example,
// 'none-vm-checked release_ia32'.
List<String> runtime = configuration.split(' ')[0].split('-');
var runtime = configuration.split(' ')[0].split('-');
return '${runtime[0]}-${runtime[1]}';
}
@ -538,7 +537,7 @@ class BuildbotProgressIndicator extends ProgressIndicator {
if (stepName != null) {
print('@@@BUILD_STEP $stepName failures@@@');
}
for (String line in _failureSummary) {
for (var line in _failureSummary) {
print(line);
}
print('');
@ -723,14 +722,14 @@ class ResultWriter extends EventListener {
lines.map((l) => l + '\n').join();
void done(TestCase test) {
final name = test.displayName;
final index = name.indexOf('/');
final suite = name.substring(0, index);
final testName = name.substring(index + 1);
Duration time =
var name = test.displayName;
var index = name.indexOf('/');
var suite = name.substring(0, index);
var testName = name.substring(index + 1);
var time =
test.commandOutputs.values.fold(Duration.zero, (d, o) => d + o.time);
final record = {
var record = {
"name": name,
"configuration": test.configuration.configuration.name,
"suite": suite,
@ -742,7 +741,7 @@ class ResultWriter extends EventListener {
};
_results.add(record);
if (test.configuration.writeLogs && record['matches'] != true) {
final log = {
var log = {
'name': name,
'configuration': record['configuration'],
'result': record['result'],
@ -759,7 +758,7 @@ class ResultWriter extends EventListener {
void writeOutputFile(List<Map> results, String fileName) {
if (_outputDirectory == null) return;
final path = Uri.directory(_outputDirectory).resolve(fileName);
var path = Uri.directory(_outputDirectory).resolve(fileName);
File.fromUri(path)
.writeAsStringSync(newlineTerminated(results.map(jsonEncode)));
}

View file

@ -209,11 +209,11 @@ abstract class TestSuite {
String createGeneratedTestDirectoryHelper(
String name, String dirname, Path testPath) {
Path relative = testPath.relativeTo(Repository.dir);
var relative = testPath.relativeTo(Repository.dir);
relative = relative.directoryPath.append(relative.filenameWithoutExtension);
String testUniqueName = TestUtils.getShortName(relative.toString());
var testUniqueName = TestUtils.getShortName(relative.toString());
Path generatedTestPath = Path(buildDir)
var generatedTestPath = Path(buildDir)
.append('generated_$name')
.append(dirname)
.append(testUniqueName);
@ -403,7 +403,7 @@ class StandardTestSuite extends TestSuite {
// Initialize _testListPossibleFilenames.
if (configuration.testList != null) {
_testListPossibleFilenames = <String>{};
for (String s in configuration.testList) {
for (var s in configuration.testList) {
if (s.startsWith("$suiteName/")) {
s = s.substring(s.indexOf('/') + 1);
_testListPossibleFilenames

View file

@ -28,7 +28,7 @@ class DispatchingServer {
void _dispatchRequest(HttpRequest request) {
// If the request path matches a prefix in _handlers, send it to that
// handler. Otherwise, run the notFound handler.
for (String prefix in _handlers.keys) {
for (var prefix in _handlers.keys) {
if (request.uri.path.startsWith(prefix)) {
_handlers[prefix](request);
return;
@ -253,9 +253,9 @@ class TestingServers {
Uri _getFileUriFromRequestUri(Uri request) {
// Go to the top of the file to see an explanation of the URL path scheme.
List<String> pathSegments = request.normalizePath().pathSegments;
var pathSegments = request.normalizePath().pathSegments;
if (pathSegments.length == 0) return null;
int packagesIndex = pathSegments.indexOf('packages');
var packagesIndex = pathSegments.indexOf('packages');
if (packagesIndex != -1) {
var packageUri = Uri(
scheme: 'package',
@ -398,7 +398,7 @@ class TestingServers {
// Firefox bug 1016313
// (https://bugzilla.mozilla.org/show_bug.cgi?id=1016313).
response.headers.set(HttpHeaders.contentTypeHeader, 'text/html');
String escapedPath = const HtmlEscape().convert(request.uri.path);
var escapedPath = const HtmlEscape().convert(request.uri.path);
response.write("""
<!DOCTYPE html>
<html lang='en'>

View file

@ -103,7 +103,7 @@ class DebugLogger {
String prettifyJson(Object json,
{int startIndentation = 0, int shiftWidth = 6}) {
int currentIndentation = startIndentation;
var currentIndentation = startIndentation;
var buffer = StringBuffer();
String indentationString() {
@ -174,9 +174,9 @@ bool areByteArraysEqual(
/// Returns `true` if [pattern] was found in [data].
int findBytes(List<int> data, List<int> pattern, [int startPos = 0]) {
// TODO(kustermann): Use one of the fast string-matching algorithms!
for (int i = startPos; i < (data.length - pattern.length); i++) {
bool found = true;
for (int j = 0; j < pattern.length; j++) {
for (var i = startPos; i < (data.length - pattern.length); i++) {
var found = true;
for (var j = 0; j < pattern.length; j++) {
if (data[i + j] != pattern[j]) {
found = false;
break;
@ -288,7 +288,7 @@ bool deepJsonCompare(Object a, Object b) {
if (b is List) {
if (a.length != b.length) return false;
for (int i = 0; i < a.length; i++) {
for (var i = 0; i < a.length; i++) {
if (!deepJsonCompare(a[i], b[i])) return false;
}
return true;
@ -359,10 +359,10 @@ class TestUtils {
if (relativePath.isAbsolute) {
base = Path('/');
}
Directory dir = Directory(base.toNativePath());
var dir = Directory(base.toNativePath());
assert(dir.existsSync());
var segments = relativePath.segments();
for (String segment in segments) {
for (var segment in segments) {
base = base.append(segment);
if (base.toString() == "/$segment" &&
segment.length == 2 &&

View file

@ -112,8 +112,8 @@ class Usage {
}
void calculateColumnWidths() {
int abbr = 0;
int title = 0;
var abbr = 0;
var title = 0;
args.options.forEach((name, option) {
// Make room in the first column if there are abbreviations.
abbr = max(abbr, getAbbreviation(option).length);
@ -201,7 +201,7 @@ class Usage {
String buildAllowedList(Option option) {
var allowedBuffer = StringBuffer();
allowedBuffer.write('[');
bool first = true;
var first = true;
for (var allowed in option.allowed) {
if (!first) allowedBuffer.write(', ');
allowedBuffer.write(allowed);
@ -217,7 +217,7 @@ class Usage {
/// Pads [source] to [length] by adding spaces at the end.
String padRight(String source, int length) {
final result = StringBuffer();
var result = StringBuffer();
result.write(source);
while (result.length < length) {

View file

@ -69,7 +69,7 @@ class FileUtils {
if (testSnapshot != null) testSnapshot.deleteSync();
// if the script did run, it created this file, so we need to delete it
File file = File(scriptOutputPath.toNativePath());
var file = File(scriptOutputPath.toNativePath());
if (file.existsSync()) {
file.deleteSync();
}

View file

@ -30,7 +30,7 @@ Future<List<StaticError>> getErrors(
bool areSameErrors(List<StaticError> first, List<StaticError> second) {
if (first.length != second.length) return false;
for (int i = 0; i < first.length; ++i) {
for (var i = 0; i < first.length; ++i) {
if (first[i].compareTo(second[i]) != 0) return false;
}
return true;
@ -66,9 +66,9 @@ class CleanedMultiTest {
}
CleanedMultiTest removeMultiTestMarker(String test) {
StringBuffer sb = StringBuffer();
var buffer = StringBuffer();
var subTests = <String, String>{};
List<String> lines = LineSplitter.split(test)
var lines = LineSplitter.split(test)
.where((line) => !line.startsWith("// Test created from multitest named"))
.toList();
if (lines.length > 1 && lines.last.isEmpty) {
@ -76,7 +76,7 @@ CleanedMultiTest removeMultiTestMarker(String test) {
// will add a newline to the end.
lines.length--;
}
for (String line in lines) {
for (var line in lines) {
var matches = multitestMarker.allMatches(line);
if (matches.length > 1) {
throw "internal error: cannot process line '$line'";
@ -101,9 +101,9 @@ CleanedMultiTest removeMultiTestMarker(String test) {
throw UnableToConvertException("test contains dynamic outcome");
}
}
sb.writeln(line);
buffer.writeln(line);
}
return CleanedMultiTest(sb.toString(), subTests);
return CleanedMultiTest(buffer.toString(), subTests);
}
Future createRuntimeTest(
@ -120,7 +120,7 @@ Future createRuntimeTest(
}
var runtimeTestPath = "${dirname(testFilePath)}/$runtimeTestBase"
"_runtime_test.dart";
int n = 1;
var n = 1;
while (await File(runtimeTestPath).exists()) {
runtimeTestPath = "${dirname(testFilePath)}/$runtimeTestBase"
"_runtime_${n++}_test.dart";
@ -133,7 +133,7 @@ Future createRuntimeTest(
${cleanedMultiTest.text}""";
if (writeToFile) {
File outputFile = File(runtimeTestPath);
var outputFile = File(runtimeTestPath);
await outputFile.writeAsString(runtimeTestContent, mode: FileMode.append);
print("Runtime part of the test written to '$runtimeTestPath'.");
} else {
@ -169,8 +169,7 @@ Future<void> main(List<String> arguments) async {
exitCode = 1;
return;
}
Directory outputDirectory =
await Directory(dirname(testFilePath)).createTemp();
var outputDirectory = await Directory(dirname(testFilePath)).createTemp();
if (verbose) {
print("Output directory for generated files: ${outputDirectory.uri.path}");
}
@ -192,7 +191,7 @@ Future<void> main(List<String> arguments) async {
// from the analyser and the common front-end.
var options = test.sharedOptions;
var errors = <List<StaticError>>[];
for (TestFile test in tests) {
for (var test in tests) {
if (verbose) {
print("Processing ${test.path}");
}
@ -218,7 +217,7 @@ Future<void> main(List<String> arguments) async {
// and output the result.
var annotatedContent =
updateErrorExpectations(contentWithoutMarkers, errors[0]);
bool writeToFile = results["write"] as bool;
var writeToFile = results["write"] as bool;
if (writeToFile) {
await testFile.writeAsString(annotatedContent);
print("Converted test '${test.path.toNativePath()}'.");
@ -228,10 +227,10 @@ Future<void> main(List<String> arguments) async {
}
// Generate runtime tests for all sub-tests that are generated from the
// 'none' case and those with 'ok' annotations.
for (int i = 1; i < tests.length; ++i) {
String test = tests[i].path.toNativePath();
String base = basenameWithoutExtension(test);
String key = base.split("_").last;
for (var i = 1; i < tests.length; ++i) {
var test = tests[i].path.toNativePath();
var base = basenameWithoutExtension(test);
var key = base.split("_").last;
if (key == "none" || cleanedTest.subTests[key] == "ok") {
await createRuntimeTest(
testFilePath, tests[i].path.toNativePath(), writeToFile);

View file

@ -14,7 +14,6 @@ import 'package:test_runner/src/path.dart';
import 'package:test_runner/src/static_error.dart';
import 'package:test_runner/src/test_file.dart';
import 'package:test_runner/src/update_errors.dart';
import 'package:test_runner/src/utils.dart';
const _usage =
"Usage: dart update_static_error_tests.dart [flags...] <path glob>";