From c936aa8cd47f424a76bce57a4bb6ff253d0de22a Mon Sep 17 00:00:00 2001 From: Mikkel Nygaard Ravn Date: Fri, 10 Nov 2017 15:56:17 +0100 Subject: [PATCH] One more timeout. Centralize definitions. (#12970) --- .../test/commands/analyze_once_test.dart | 2 +- .../test/commands/create_test.dart | 21 ++++++++----------- .../test/commands/packages_test.dart | 6 ++---- packages/flutter_tools/test/src/common.dart | 9 +++++++- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/packages/flutter_tools/test/commands/analyze_once_test.dart b/packages/flutter_tools/test/commands/analyze_once_test.dart index 05e4e401a4..22350e8abd 100644 --- a/packages/flutter_tools/test/commands/analyze_once_test.dart +++ b/packages/flutter_tools/test/commands/analyze_once_test.dart @@ -47,7 +47,7 @@ void main() { ], ); expect(libMain.existsSync(), isTrue); - }); + }, timeout: allowForRemotePubInvocation); // Analyze in the current directory - no arguments testUsingContext('flutter analyze working directory', () async { diff --git a/packages/flutter_tools/test/commands/create_test.dart b/packages/flutter_tools/test/commands/create_test.dart index 31fe72f5ff..47cc959817 100644 --- a/packages/flutter_tools/test/commands/create_test.dart +++ b/packages/flutter_tools/test/commands/create_test.dart @@ -22,9 +22,6 @@ import '../src/context.dart'; const String frameworkRevision = '12345678'; const String frameworkChannel = 'omega'; -const Timeout createProjectTimeout = const Timeout.factor(2.0); -const Timeout createProjectAndGetPackagesTimeout = const Timeout.factor(10.0); - void main() { group('create', () { Directory temp; @@ -60,7 +57,7 @@ void main() { 'flutter_project.iml', ], ); - }, timeout: createProjectAndGetPackagesTimeout); + }, timeout: allowForRemotePubInvocation); testUsingContext('kotlin/swift project', () async { return _createProject( @@ -79,7 +76,7 @@ void main() { 'ios/Runner/main.m', ], ); - }, timeout: createProjectTimeout); + }, timeout: allowForCreateFlutterProject); testUsingContext('package project', () async { return _createAndAnalyzeProject( @@ -106,7 +103,7 @@ void main() { 'test/widget_test.dart', ], ); - }, timeout: createProjectAndGetPackagesTimeout); + }, timeout: allowForRemotePubInvocation); testUsingContext('plugin project', () async { return _createAndAnalyzeProject( @@ -126,7 +123,7 @@ void main() { ], plugin: true, ); - }, timeout: createProjectAndGetPackagesTimeout); + }, timeout: allowForRemotePubInvocation); testUsingContext('kotlin/swift plugin project', () async { return _createProject( @@ -152,7 +149,7 @@ void main() { ], plugin: true, ); - }, timeout: createProjectTimeout); + }, timeout: allowForCreateFlutterProject); testUsingContext('plugin project with custom org', () async { return _createProject( @@ -168,7 +165,7 @@ void main() { ], plugin: true, ); - }, timeout: createProjectTimeout); + }, timeout: allowForCreateFlutterProject); testUsingContext('project with-driver-test', () async { return _createAndAnalyzeProject( @@ -176,7 +173,7 @@ void main() { ['--with-driver-test'], ['lib/main.dart'], ); - }, timeout: createProjectAndGetPackagesTimeout); + }, timeout: allowForRemotePubInvocation); // Verify content and formatting testUsingContext('content', () async { @@ -252,7 +249,7 @@ void main() { overrides: { FlutterVersion: () => mockFlutterVersion, }, - timeout: createProjectTimeout); + timeout: allowForCreateFlutterProject); // Verify that we can regenerate over an existing project. testUsingContext('can re-gen over existing project', () async { @@ -264,7 +261,7 @@ void main() { await runner.run(['create', '--no-pub', projectDir.path]); await runner.run(['create', '--no-pub', projectDir.path]); - }, timeout: createProjectTimeout); + }, timeout: allowForCreateFlutterProject); // Verify that we help the user correct an option ordering issue testUsingContext('produces sensible error message', () async { diff --git a/packages/flutter_tools/test/commands/packages_test.dart b/packages/flutter_tools/test/commands/packages_test.dart index ab107e58a7..a3f9be3dde 100644 --- a/packages/flutter_tools/test/commands/packages_test.dart +++ b/packages/flutter_tools/test/commands/packages_test.dart @@ -17,8 +17,6 @@ import 'package:test/test.dart'; import '../src/common.dart'; import '../src/context.dart'; -const Timeout remotePubTimeout = const Timeout.factor(10.0); - void main() { Cache.disableLocking(); group('packages get/upgrade', () { @@ -57,7 +55,7 @@ void main() { final String projectPath = await runCommand('get'); expectExists(projectPath, 'lib/main.dart'); expectExists(projectPath, '.packages'); - }, timeout: remotePubTimeout); + }, timeout: allowForRemotePubInvocation); testUsingContext('get --offline', () async { final String projectPath = await runCommand('get', args: ['--offline']); @@ -69,7 +67,7 @@ void main() { final String projectPath = await runCommand('upgrade'); expectExists(projectPath, 'lib/main.dart'); expectExists(projectPath, '.packages'); - }, timeout: remotePubTimeout); + }, timeout: allowForRemotePubInvocation); }); group('packages test/pub', () { diff --git a/packages/flutter_tools/test/src/common.dart b/packages/flutter_tools/test/src/common.dart index c56af86fa8..543fda7d5f 100644 --- a/packages/flutter_tools/test/src/common.dart +++ b/packages/flutter_tools/test/src/common.dart @@ -96,4 +96,11 @@ Future createProject(Directory temp) async { final CommandRunner runner = createTestCommandRunner(command); await runner.run(['create', '--no-pub', projectPath]); return projectPath; -} \ No newline at end of file +} + +/// Test case timeout for tests involving remote calls to `pub get` or similar. +const Timeout allowForRemotePubInvocation = const Timeout.factor(10.0); + +/// Test case timeout for tests involving creating a Flutter project with +/// `--no-pub`. Use [allowForRemotePubInvocation] when creation involves `pub`. +const Timeout allowForCreateFlutterProject = const Timeout.factor(2.0);