diff --git a/packages/flutter_tools/lib/src/android/android_sdk.dart b/packages/flutter_tools/lib/src/android/android_sdk.dart index ac5d5d69f5..d590d6551c 100644 --- a/packages/flutter_tools/lib/src/android/android_sdk.dart +++ b/packages/flutter_tools/lib/src/android/android_sdk.dart @@ -140,7 +140,7 @@ class AndroidSdk { if (platformsDir.existsSync()) { platforms = platformsDir .listSync() - .map((FileSystemEntity entity) => fs.path.basename(entity.path)) + .map((FileSystemEntity entity) => fs.path.basename(entity.path)) .where((String name) => name.startsWith('android-')) .toList(); } diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart index 5c265ab070..e399217ee7 100644 --- a/packages/flutter_tools/lib/src/asset.dart +++ b/packages/flutter_tools/lib/src/asset.dart @@ -336,8 +336,9 @@ Map<_Asset, List<_Asset>> _parseAssets( if (manifestDescriptor == null) return result; - excludeDirs = excludeDirs.map( - (String exclude) => fs.path.absolute(exclude) + fs.path.separator).toList(); + excludeDirs = excludeDirs.map( + (String exclude) => fs.path.absolute(exclude) + fs.path.separator + ).toList(); if (manifestDescriptor.containsKey('assets')) { for (String asset in manifestDescriptor['assets']) { diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart index cdca01ac25..ef9b7e3826 100644 --- a/packages/flutter_tools/lib/src/commands/test.dart +++ b/packages/flutter_tools/lib/src/commands/test.dart @@ -172,7 +172,7 @@ class TestCommand extends FlutterCommand { testArgs.add('--'); Directory testDir; - Iterable files = argResults.rest.map((String testPath) => fs.path.absolute(testPath)).toList(); + Iterable files = argResults.rest.map((String testPath) => fs.path.absolute(testPath)).toList(); if (argResults['start-paused']) { if (files.length != 1) throwToolExit('When using --start-paused, you must specify a single test file to run.', exitCode: 1); diff --git a/packages/flutter_tools/test/all.dart b/packages/flutter_tools/test/all.dart index f23d03f7e3..b07cb50232 100644 --- a/packages/flutter_tools/test/all.dart +++ b/packages/flutter_tools/test/all.dart @@ -30,8 +30,7 @@ import 'device_test.dart' as device_test; import 'devices_test.dart' as devices_test; import 'doctor_test.dart' as doctor_test; import 'drive_test.dart' as drive_test; -import 'forbid_dart_io_test.dart' as forbid_dart_io_test; -import 'forbid_package_path_test.dart' as forbid_package_path_test; +import 'forbidden_imports_test.dart' as forbidden_imports_test; import 'format_test.dart' as format_test; import 'hot_test.dart' as hot_test; import 'install_test.dart' as install_test; @@ -70,8 +69,7 @@ void main() { devices_test.main(); doctor_test.main(); drive_test.main(); - forbid_dart_io_test.main(); - forbid_package_path_test.main(); + forbidden_imports_test.main(); format_test.main(); hot_test.main(); install_test.main(); diff --git a/packages/flutter_tools/test/forbid_package_path_test.dart b/packages/flutter_tools/test/forbid_package_path_test.dart deleted file mode 100644 index 6cb7c1e075..0000000000 --- a/packages/flutter_tools/test/forbid_package_path_test.dart +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; -import 'package:test/test.dart'; - -void main() { - setUp(() { - String flutterTools = fs.path.join(platform.environment['FLUTTER_ROOT'], - 'packages', 'flutter_tools'); - assert(fs.path.equals(fs.currentDirectory.path, flutterTools)); - }); - - test('no unauthorized imports of package:path', () { - for (String path in ['lib', 'bin', 'test']) { - fs.directory(path) - .listSync(recursive: true) - .where(_isDartFile) - .map(_asFile) - .forEach((File file) { - for (String line in file.readAsLinesSync()) { - if (line.startsWith(new RegExp('import.*package:path/path.dart'))) { - fail("${file.path} imports 'package:path/path.dart'; use 'fs.path' instead"); - } - } - } - ); - } - }); -} - -bool _isDartFile(FileSystemEntity entity) => entity is File && entity.path.endsWith('.dart'); - -File _asFile(FileSystemEntity entity) => entity; diff --git a/packages/flutter_tools/test/forbid_dart_io_test.dart b/packages/flutter_tools/test/forbidden_imports_test.dart similarity index 51% rename from packages/flutter_tools/test/forbid_dart_io_test.dart rename to packages/flutter_tools/test/forbidden_imports_test.dart index cf7a9b5751..2846d0be8a 100644 --- a/packages/flutter_tools/test/forbid_dart_io_test.dart +++ b/packages/flutter_tools/test/forbidden_imports_test.dart @@ -8,12 +8,16 @@ import 'package:test/test.dart'; void main() { setUp(() { - String flutterTools = fs.path.join(platform.environment['FLUTTER_ROOT'], - 'packages', 'flutter_tools'); + String flutterRoot = platform.environment['FLUTTER_ROOT']; + if (flutterRoot == null) + throw new Exception('Please set FLUTTER_ROOT env var before running tests.'); + String flutterTools = fs.path.join(flutterRoot, 'packages', 'flutter_tools'); assert(fs.path.equals(fs.currentDirectory.path, flutterTools)); }); test('no unauthorized imports of dart:io', () { + bool _isNotWhitelisted(FileSystemEntity entity) => entity.path != fs.path.join('lib', 'src', 'base', 'io.dart'); + for (String path in ['lib', 'bin']) { fs.directory(path) .listSync(recursive: true) @@ -31,12 +35,25 @@ void main() { ); } }); + + test('no unauthorized imports of package:path', () { + for (String path in ['lib', 'bin', 'test']) { + fs.directory(path) + .listSync(recursive: true) + .where(_isDartFile) + .map(_asFile) + .forEach((File file) { + for (String line in file.readAsLinesSync()) { + if (line.startsWith(new RegExp('import.*package:path/path.dart'))) { + fail("${file.path} imports 'package:path/path.dart'; use 'fs.path' instead"); + } + } + } + ); + } + }); } -bool _isDartFile(FileSystemEntity entity) => - entity is File && entity.path.endsWith('.dart'); - -bool _isNotWhitelisted(FileSystemEntity entity) => - entity.path != fs.path.join('lib', 'src', 'base', 'io.dart'); +bool _isDartFile(FileSystemEntity entity) => entity is File && entity.path.endsWith('.dart'); File _asFile(FileSystemEntity entity) => entity;