diff --git a/packages/flutter_tools/lib/src/build_configuration.dart b/packages/flutter_tools/lib/src/build_configuration.dart index cb04dd5b78..938729df30 100644 --- a/packages/flutter_tools/lib/src/build_configuration.dart +++ b/packages/flutter_tools/lib/src/build_configuration.dart @@ -49,8 +49,9 @@ class BuildConfiguration { BuildConfiguration.prebuilt({ this.hostPlatform, this.targetPlatform, - this.deviceId - }) : type = BuildType.prebuilt, buildDir = null, testable = false; + this.deviceId, + this.testable: false + }) : type = BuildType.prebuilt, buildDir = null; BuildConfiguration.local({ this.type, diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart index a837d0e041..4a905fb835 100644 --- a/packages/flutter_tools/lib/src/commands/test.dart +++ b/packages/flutter_tools/lib/src/commands/test.dart @@ -26,14 +26,20 @@ class TestCommand extends FlutterCommand { 'any test paths. Otherwise, run this command from the root of your project.'; } - String getShellPath(TargetPlatform platform, String buildPath) { - switch (platform) { - case TargetPlatform.linux: - return path.join(buildPath, 'sky_shell'); - case TargetPlatform.mac: - return path.join(buildPath, 'SkyShell.app', 'Contents', 'MacOS', 'SkyShell'); - default: - throw new Exception('Unsupported platform.'); + Future _getShellPath(BuildConfiguration config) async { + if (config.type == BuildType.prebuilt) { + Artifact artifact = ArtifactStore.getArtifact( + type: ArtifactType.shell, targetPlatform: config.targetPlatform); + return await ArtifactStore.getPath(artifact); + } else { + switch (config.targetPlatform) { + case TargetPlatform.linux: + return path.join(config.buildDir, 'sky_shell'); + case TargetPlatform.mac: + return path.join(config.buildDir, 'SkyShell.app', 'Contents', 'MacOS', 'SkyShell'); + default: + throw new Exception('Unsupported platform.'); + } } } @@ -69,6 +75,11 @@ class TestCommand extends FlutterCommand { if (!runFlutterTests && !validateProjectRoot()) return 1; + // If we're running the flutter tests, we want to use the packages directory + // from the unit package in order to find the proper shell binary. + if (runFlutterTests && ArtifactStore.packageRoot == 'packages') + ArtifactStore.packageRoot = path.join(ArtifactStore.flutterRoot, 'packages', 'unit', 'packages'); + Directory testDir = runFlutterTests ? _flutterUnitTestDir : Directory.current; if (testArgs.isEmpty) @@ -84,7 +95,7 @@ class TestCommand extends FlutterCommand { if (!config.testable) continue; foundOne = true; - loader.shellPath = path.join(Directory.current.path, getShellPath(config.targetPlatform, config.buildDir)); + loader.shellPath = path.absolute(await _getShellPath(config)); if (!FileSystemEntity.isFileSync(loader.shellPath)) { logging.severe('Cannot find Flutter shell at ${loader.shellPath}'); return 1; diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart index 9bcf10d1fe..f36e51f0cd 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart @@ -218,6 +218,14 @@ class FlutterCommandRunner extends CommandRunner { targetPlatform: TargetPlatform.android, deviceId: globalResults['android-device-id'] )); + + if (hostPlatform == HostPlatform.linux) { + configs.add(new BuildConfiguration.prebuilt( + hostPlatform: HostPlatform.linux, + targetPlatform: TargetPlatform.linux, + testable: true + )); + } } else { if (!FileSystemEntity.isDirectorySync(enginePath)) logging.warning('$enginePath is not a valid directory'); diff --git a/travis/download_tester.py b/travis/download_tester.py deleted file mode 100755 index ccbfe0e5fc..0000000000 --- a/travis/download_tester.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python -# Copyright 2015 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 argparse -import os -import subprocess -import sys -import zipfile - -def download(base_url, out_dir, name): - url = '%s/%s' % (base_url, name) - dst = os.path.join(out_dir, name) - print 'Downloading', url - subprocess.call([ 'curl', '-o', dst, url ]) - -def main(): - parser = argparse.ArgumentParser(description='Downloads test artifacts from Google storage') - parser.add_argument('revision_file') - parser.add_argument('out_dir') - args = parser.parse_args() - - out_dir = args.out_dir - if not os.path.exists(out_dir): - os.makedirs(out_dir) - - revision = None - with open(args.revision_file, 'r') as f: - revision = f.read() - - base_url = 'https://storage.googleapis.com/mojo/flutter/%s/linux-x64' % revision - download(base_url, out_dir, 'artifacts.zip') - - artifacts_zip = zipfile.ZipFile(os.path.join(out_dir, 'artifacts.zip')) - artifacts_zip.extractall(out_dir) - artifacts_zip.close() - - subprocess.call([ 'chmod', 'a+x', os.path.join(out_dir, 'sky_shell' )]) - subprocess.call([ 'chmod', 'a+x', os.path.join(out_dir, 'sky_snapshot' )]) - -if __name__ == '__main__': - sys.exit(main()) diff --git a/travis/setup.sh b/travis/setup.sh index 97c3458ba9..055930e89f 100755 --- a/travis/setup.sh +++ b/travis/setup.sh @@ -2,5 +2,4 @@ set -ex dart dev/update_packages.dart - -./travis/download_tester.py packages/unit/packages/sky_engine/REVISION bin/cache/travis/out/Debug +(cd packages/unit; ../../bin/flutter cache populate) diff --git a/travis/test.sh b/travis/test.sh index cd713cbc39..67b7906551 100755 --- a/travis/test.sh +++ b/travis/test.sh @@ -5,7 +5,7 @@ set -ex ./bin/flutter analyze --flutter-repo --no-current-directory --no-current-package --congratulate # flutter package tests -./bin/flutter test --flutter-repo --engine-src-path bin/cache/travis +./bin/flutter test --flutter-repo (cd packages/cassowary; pub run test -j1) # (cd packages/flutter_sprites; ) # No tests to run.