Commit 9be9a409 authored by Mikkel Nygaard Ravn's avatar Mikkel Nygaard Ravn Committed by GitHub

Avoid running pub get and analyze on every project during create_test (#11932)

parent 02c10b78
...@@ -49,12 +49,12 @@ void main() { ...@@ -49,12 +49,12 @@ void main() {
'test/widget_test.dart' 'test/widget_test.dart'
], ],
); );
}); }, timeout: const Timeout.factor(2.0));
testUsingContext('kotlin/swift project', () async { testUsingContext('kotlin/swift project', () async {
return _createAndAnalyzeProject( return _createProject(
projectDir, projectDir,
<String>['--android-language', 'kotlin', '-i', 'swift'], <String>['--no-pub', '--android-language', 'kotlin', '-i', 'swift'],
<String>[ <String>[
'android/app/src/main/kotlin/com/yourcompany/flutterproject/MainActivity.kt', 'android/app/src/main/kotlin/com/yourcompany/flutterproject/MainActivity.kt',
'ios/Runner/AppDelegate.swift', 'ios/Runner/AppDelegate.swift',
...@@ -95,7 +95,7 @@ void main() { ...@@ -95,7 +95,7 @@ void main() {
'test/widget_test.dart', 'test/widget_test.dart',
], ],
); );
}); }, timeout: const Timeout.factor(2.0));
testUsingContext('plugin project', () async { testUsingContext('plugin project', () async {
return _createAndAnalyzeProject( return _createAndAnalyzeProject(
...@@ -114,12 +114,12 @@ void main() { ...@@ -114,12 +114,12 @@ void main() {
], ],
plugin: true, plugin: true,
); );
}); }, timeout: const Timeout.factor(2.0));
testUsingContext('plugin project (legacy)', () async { testUsingContext('plugin project (legacy)', () async {
return _createAndAnalyzeProject( return _createProject(
projectDir, projectDir,
<String>['--plugin'], <String>['--no-pub', '--plugin'],
<String>[ <String>[
'android/src/main/java/com/yourcompany/flutterproject/FlutterProjectPlugin.java', 'android/src/main/java/com/yourcompany/flutterproject/FlutterProjectPlugin.java',
'ios/Classes/FlutterProjectPlugin.h', 'ios/Classes/FlutterProjectPlugin.h',
...@@ -136,9 +136,9 @@ void main() { ...@@ -136,9 +136,9 @@ void main() {
}); });
testUsingContext('kotlin/swift plugin project', () async { testUsingContext('kotlin/swift plugin project', () async {
return _createAndAnalyzeProject( return _createProject(
projectDir, projectDir,
<String>['--template=plugin', '-a', 'kotlin', '--ios-language', 'swift'], <String>['--no-pub', '--template=plugin', '-a', 'kotlin', '--ios-language', 'swift'],
<String>[ <String>[
'android/src/main/kotlin/com/yourcompany/flutterproject/FlutterProjectPlugin.kt', 'android/src/main/kotlin/com/yourcompany/flutterproject/FlutterProjectPlugin.kt',
'ios/Classes/FlutterProjectPlugin.h', 'ios/Classes/FlutterProjectPlugin.h',
...@@ -162,9 +162,9 @@ void main() { ...@@ -162,9 +162,9 @@ void main() {
}); });
testUsingContext('plugin project with custom org', () async { testUsingContext('plugin project with custom org', () async {
return _createAndAnalyzeProject( return _createProject(
projectDir, projectDir,
<String>['--template=plugin', '--org', 'com.bar.foo'], <String>['--no-pub', '--template=plugin', '--org', 'com.bar.foo'],
<String>[ <String>[
'android/src/main/java/com/bar/foo/flutterproject/FlutterProjectPlugin.java', 'android/src/main/java/com/bar/foo/flutterproject/FlutterProjectPlugin.java',
'example/android/app/src/main/java/com/bar/foo/flutterprojectexample/MainActivity.java', 'example/android/app/src/main/java/com/bar/foo/flutterprojectexample/MainActivity.java',
...@@ -183,7 +183,7 @@ void main() { ...@@ -183,7 +183,7 @@ void main() {
<String>['--with-driver-test'], <String>['--with-driver-test'],
<String>['lib/main.dart'], <String>['lib/main.dart'],
); );
}); }, timeout: const Timeout.factor(2.0));
// Verify content and formatting // Verify content and formatting
testUsingContext('content', () async { testUsingContext('content', () async {
...@@ -299,9 +299,9 @@ void main() { ...@@ -299,9 +299,9 @@ void main() {
}); });
} }
Future<Null> _createAndAnalyzeProject( Future<Null> _createProject(
Directory dir, List<String> createArgs, List<String> expectedPaths, Directory dir, List<String> createArgs, List<String> expectedPaths,
{ List<String> unexpectedPaths = const <String>[], bool plugin = false }) async { { List<String> unexpectedPaths = const <String>[], bool plugin = false}) async {
Cache.flutterRoot = '../..'; Cache.flutterRoot = '../..';
final CreateCommand command = new CreateCommand(); final CreateCommand command = new CreateCommand();
final CommandRunner<Null> runner = createTestCommandRunner(command); final CommandRunner<Null> runner = createTestCommandRunner(command);
...@@ -316,16 +316,21 @@ Future<Null> _createAndAnalyzeProject( ...@@ -316,16 +316,21 @@ Future<Null> _createAndAnalyzeProject(
for (String path in unexpectedPaths) { for (String path in unexpectedPaths) {
expect(fs.file(fs.path.join(dir.path, path)).existsSync(), false, reason: '$path exists'); expect(fs.file(fs.path.join(dir.path, path)).existsSync(), false, reason: '$path exists');
} }
}
Future<Null> _createAndAnalyzeProject(
Directory dir, List<String> createArgs, List<String> expectedPaths,
{ List<String> unexpectedPaths = const <String>[], bool plugin = false }) async {
await _createProject(dir, createArgs, expectedPaths, unexpectedPaths: unexpectedPaths, plugin: plugin);
if (plugin) { if (plugin) {
_analyze(dir.path, target: fs.path.join(dir.path, 'lib', 'flutter_project.dart')); await _analyzeProject(dir.path, target: fs.path.join(dir.path, 'lib', 'flutter_project.dart'));
_analyze(fs.path.join(dir.path, 'example')); await _analyzeProject(fs.path.join(dir.path, 'example'));
} else { } else {
_analyze(dir.path); await _analyzeProject(dir.path);
} }
} }
void _analyze(String workingDir, {String target}) { Future<Null> _analyzeProject(String workingDir, {String target}) async {
final String flutterToolsPath = fs.path.absolute(fs.path.join( final String flutterToolsPath = fs.path.absolute(fs.path.join(
'bin', 'bin',
'flutter_tools.dart', 'flutter_tools.dart',
...@@ -335,7 +340,7 @@ void _analyze(String workingDir, {String target}) { ...@@ -335,7 +340,7 @@ void _analyze(String workingDir, {String target}) {
if (target != null) if (target != null)
args.add(target); args.add(target);
final ProcessResult exec = Process.runSync( final ProcessResult exec = await Process.run(
'$dartSdkPath/bin/dart', '$dartSdkPath/bin/dart',
args, args,
workingDirectory: workingDir, workingDirectory: workingDir,
......
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