Commit fe37825f authored by Devon Carew's avatar Devon Carew

run pub with --no-package-symlinks

parent c9c84946
// Copyright (c) 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 'cassowary_test.dart' as cassowary_test;
void main() {
cassowary_test.main();
}
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library cassowary.test;
import 'package:test/test.dart';
import 'package:cassowary/cassowary.dart';
......
// Copyright (c) 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 'flutter_driver_test.dart' as flutter_driver_test;
import 'retry_test.dart' as retry_test;
void main() {
flutter_driver_test.main();
retry_test.main();
}
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
import 'dart:async';
import 'package:test/test.dart';
import 'package:flutter_driver/src/driver.dart';
import 'package:flutter_driver/src/error.dart';
import 'package:flutter_driver/src/health.dart';
......@@ -11,6 +11,7 @@ import 'package:flutter_driver/src/message.dart';
import 'package:json_rpc_2/json_rpc_2.dart' as rpc;
import 'package:mockito/mockito.dart';
import 'package:quiver/testing/async.dart';
import 'package:test/test.dart';
import 'package:vm_service_client/vm_service_client.dart';
void main() {
......
......@@ -122,12 +122,6 @@ class AnalyzeCommand extends FlutterCommand {
@override
bool get requiresProjectRoot => false;
bool get isFlutterRepo {
return FileSystemEntity.isDirectorySync('examples') &&
FileSystemEntity.isDirectorySync('packages') &&
FileSystemEntity.isFileSync('bin/flutter');
}
@override
Future<int> runInProject() async {
return argResults['watch'] ? _analyzeWatch() : _analyzeOnce();
......@@ -658,7 +652,7 @@ class AnalysisServer {
List<String> args = <String>[snapshot, '--sdk', sdk];
printTrace('dart ${args.join(' ')}');
_process = await Process.start('dart', args);
_process = await Process.start(path.join(dartSdkPath, 'bin', 'dart'), args);
_process.exitCode.whenComplete(() => _process = null);
Stream<String> errorStream = _process.stderr.transform(UTF8.decoder).transform(const LineSplitter());
......
......@@ -20,7 +20,6 @@ Future<int> pubGet({
directory = Directory.current.path;
File pubSpecYaml = new File(path.join(directory, 'pubspec.yaml'));
File pubSpecLock = new File(path.join(directory, 'pubspec.lock'));
File dotPackages = new File(path.join(directory, '.packages'));
if (!pubSpecYaml.existsSync()) {
......@@ -30,21 +29,20 @@ Future<int> pubGet({
return 1;
}
if (!checkLastModified || !pubSpecLock.existsSync() || pubSpecYaml.lastModifiedSync().isAfter(pubSpecLock.lastModifiedSync())) {
if (!checkLastModified || !dotPackages.existsSync() || pubSpecYaml.lastModifiedSync().isAfter(dotPackages.lastModifiedSync())) {
String command = upgrade ? 'upgrade' : 'get';
printStatus("Running 'pub $command' in $directory${Platform.pathSeparator}...");
int code = await runCommandAndStreamOutput(
<String>[sdkBinaryName('pub'), '--verbosity=warning', command],
<String>[sdkBinaryName('pub'), '--verbosity=warning', command, '--no-package-symlinks'],
workingDirectory: directory
);
if (code != 0)
return code;
}
if ((pubSpecLock.existsSync() && pubSpecLock.lastModifiedSync().isAfter(pubSpecYaml.lastModifiedSync())) &&
(dotPackages.existsSync() && dotPackages.lastModifiedSync().isAfter(pubSpecYaml.lastModifiedSync())))
if (dotPackages.existsSync() && dotPackages.lastModifiedSync().isAfter(pubSpecYaml.lastModifiedSync()))
return 0;
printError('$directory: pubspec.yaml, pubspec.lock, and .packages are in an inconsistent state');
printError('$directory: pubspec.yaml and .packages are in an inconsistent state');
return 1;
}
......@@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io';
import 'package:path/path.dart' as path;
/// Locate the Dart SDK by finding the Dart VM and going up two directories.
String get dartSdkPath => new File(Platform.executable).parent.parent.path;
import '../artifacts.dart';
/// Locate the Dart SDK.
String get dartSdkPath {
return path.join(ArtifactStore.flutterRoot, 'bin', 'cache', 'dart-sdk');
}
......@@ -15,6 +15,7 @@ import 'package:yaml/yaml.dart';
import 'artifacts.dart';
import 'base/file_system.dart' show ensureDirectoryExists;
import 'globals.dart';
import 'package_map.dart';
import 'toolchain.dart';
import 'zip.dart';
......@@ -38,6 +39,9 @@ class _Asset {
final String source;
final String base;
final String key;
@override
String toString() => 'base: $base, key: $key';
}
Map<String, dynamic> _readMaterialFontsManifest() {
......@@ -70,26 +74,34 @@ List<_Asset> _getMaterialAssets(String fontSet) {
return result;
}
Map<_Asset, List<_Asset>> _parseAssets(Map<String, dynamic> manifestDescriptor, String assetBase) {
Map<_Asset, List<_Asset>> _parseAssets(
PackageMap packageMap,
Map<String, dynamic> manifestDescriptor,
String assetBase
) {
Map<_Asset, List<_Asset>> result = <_Asset, List<_Asset>>{};
if (manifestDescriptor == null)
return result;
if (manifestDescriptor.containsKey('assets')) {
for (String asset in manifestDescriptor['assets']) {
_Asset baseAsset = new _Asset(base: assetBase, key: asset);
_Asset baseAsset = _resolveAsset(packageMap, assetBase, asset);
List<_Asset> variants = <_Asset>[];
result[baseAsset] = variants;
// Find asset variants
String assetPath = path.join(assetBase, asset);
String assetPath = path.join(baseAsset.base, baseAsset.key);
String assetFilename = path.basename(assetPath);
Directory assetDir = new Directory(path.dirname(assetPath));
List<FileSystemEntity> files = assetDir.listSync(recursive: true);
for (FileSystemEntity entity in files) {
if (path.basename(entity.path) == assetFilename &&
FileSystemEntity.isFileSync(entity.path) &&
entity.path != assetPath) {
String key = path.relative(entity.path, from: assetBase);
variants.add(new _Asset(base: assetBase, key: key));
String key = path.relative(entity.path, from: baseAsset.base);
variants.add(new _Asset(base: baseAsset.base, key: key));
}
}
}
......@@ -114,6 +126,28 @@ Map<_Asset, List<_Asset>> _parseAssets(Map<String, dynamic> manifestDescriptor,
return result;
}
_Asset _resolveAsset(PackageMap packageMap, String assetBase, String asset) {
if (asset.startsWith('packages/')) {
// Convert packages/flutter_gallery_assets/clouds-0.png to clouds-0.png.
String packageKey = asset.substring(9);
String relativeAsset = asset;
int index = packageKey.indexOf('/');
if (index != -1) {
relativeAsset = packageKey.substring(index + 1);
packageKey = packageKey.substring(0, index);
}
Uri uri = packageMap.map[packageKey];
if (uri != null && uri.scheme == 'file') {
File file = new File.fromUri(uri);
return new _Asset(base: file.path, key: relativeAsset);
}
}
return new _Asset(base: assetBase, key: asset);
}
dynamic _loadManifest(String manifestPath) {
if (manifestPath == null || !FileSystemEntity.isFileSync(manifestPath))
return null;
......@@ -271,7 +305,8 @@ Future<int> assemble({
}) async {
printTrace('Building $outputPath');
Map<_Asset, List<_Asset>> assets = _parseAssets(manifestDescriptor, assetBasePath);
PackageMap packageMap = new PackageMap(path.join(assetBasePath, '.packages'));
Map<_Asset, List<_Asset>> assets = _parseAssets(packageMap, manifestDescriptor, assetBasePath);
final bool usesMaterialDesign = manifestDescriptor != null && manifestDescriptor['uses-material-design'] == true;
......
......@@ -146,7 +146,7 @@ class FlutterCommandRunner extends CommandRunner {
ArgResults _globalResults;
String get _defaultFlutterRoot {
static String get _defaultFlutterRoot {
if (Platform.environment.containsKey(kFlutterRootEnvironmentVariableName))
return Platform.environment[kFlutterRootEnvironmentVariableName];
try {
......@@ -157,6 +157,12 @@ class FlutterCommandRunner extends CommandRunner {
return path.dirname(path.dirname(path.dirname(script)));
if (path.basename(script) == kFlutterToolsScriptFileName)
return path.dirname(path.dirname(path.dirname(path.dirname(script))));
// If run from a bare script within the repo.
if (script.contains('flutter/packages/'))
return script.substring(0, script.indexOf('flutter/packages/') + 8);
if (script.contains('flutter/examples/'))
return script.substring(0, script.indexOf('flutter/examples/') + 8);
} catch (error) {
// we don't have a logger at the time this is run
// (which is why we don't use printTrace here)
......@@ -363,4 +369,9 @@ class FlutterCommandRunner extends CommandRunner {
return configs;
}
static void initFlutterRoot() {
if (ArtifactStore.flutterRoot == null)
ArtifactStore.flutterRoot = _defaultFlutterRoot;
}
}
// Copyright (c) 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.
// TODO(devoncarew): These `all.dart` test files are here to work around
// https://github.com/dart-lang/test/issues/327; the `test` package currently
// doesn't support running without symlinks. We can delete these files once that
// fix lands.
import 'adb_test.dart' as adb_test;
import 'analyze_duplicate_names_test.dart' as analyze_duplicate_names_test;
import 'analyze_test.dart' as analyze_test;
import 'android_device_test.dart' as android_device_test;
import 'android_sdk_test.dart' as android_sdk_test;
import 'base_utils_test.dart' as base_utils_test;
import 'context_test.dart' as context_test;
import 'create_test.dart' as create_test;
import 'daemon_test.dart' as daemon_test;
import 'device_test.dart' as device_test;
import 'drive_test.dart' as drive_test;
import 'install_test.dart' as install_test;
import 'listen_test.dart' as listen_test;
import 'logs_test.dart' as logs_test;
import 'os_utils_test.dart' as os_utils_test;
import 'run_test.dart' as run_test;
import 'service_protocol_test.dart' as service_protocol_test;
import 'stop_test.dart' as stop_test;
import 'trace_test.dart' as trace_test;
void main() {
adb_test.main();
analyze_duplicate_names_test.main();
analyze_test.main();
android_device_test.main();
android_sdk_test.main();
base_utils_test.main();
context_test.main();
create_test.main();
daemon_test.main();
device_test.main();
drive_test.main();
install_test.main();
listen_test.main();
logs_test.main();
os_utils_test.main();
run_test.main();
service_protocol_test.main();
stop_test.main();
trace_test.main();
}
......@@ -9,6 +9,7 @@ import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/commands/analyze.dart';
import 'package:flutter_tools/src/dart/pub.dart';
import 'package:flutter_tools/src/dart/sdk.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
......@@ -19,6 +20,7 @@ void main() {
Directory tempDir;
setUp(() {
FlutterCommandRunner.initFlutterRoot();
tempDir = Directory.systemTemp.createTempSync('analysis_test');
});
......
// Copyright (c) 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 'bundle_test.dart' as bundle_test;
import 'signing_test.dart' as signing_test;
void main() {
bundle_test.main();
signing_test.main();
}
// Copyright (c) 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 'newton_test.dart' as newton_test;
void main() {
newton_test.main();
}
......@@ -6,15 +6,12 @@ export PATH="$PWD/bin:$PATH"
# analyze all the Dart code in the repo
flutter analyze --flutter-repo --no-current-directory --no-current-package --congratulate
(cd packages/cassowary; pub run test -j1)
(cd packages/cassowary; dart -c test/all.dart)
(cd packages/flutter; flutter test)
(cd packages/flutter_driver; dart -c test/all.dart)
(cd packages/flutter_sprites; flutter test)
(cd packages/flutter_tools; pub run test)
# (cd packages/flutter_test; ) # No tests to run.
(cd packages/flx; pub run test -j1)
(cd packages/newton; pub run test -j1)
# (cd packages/playfair; ) # No tests to run.
# (cd packages/updater; ) # No tests to run.
(cd packages/flutter_driver; pub run test -j1)
(cd packages/flutter_tools; dart -c test/all.dart)
(cd packages/flx; dart -c test/all.dart)
(cd packages/newton; dart -c test/all.dart)
(cd examples/stocks; flutter test)
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