[flutter_tools] standardize patterns for integration.shard (#64980)
Integration tests must only go through the real file system/process manager/platform. The global indirection makes this code harder to understand than if it directly referred to the concrete instances that are being used. Update the integration shard to use a const instance of a LocalFIleSystem, LocalProcessManager, and LocalPlatform. Remove global usage and apply testWithoutContext.
This commit is contained in:
parent
46d1aba2e2
commit
6b444c4dd7
@ -5,25 +5,24 @@
|
|||||||
import 'package:file_testing/file_testing.dart';
|
import 'package:file_testing/file_testing.dart';
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
import 'package:flutter_tools/src/base/platform.dart';
|
import 'package:flutter_tools/src/base/platform.dart';
|
||||||
import 'package:process/process.dart';
|
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
const String apkDebugMessage = 'A summary of your APK analysis can be found at: ';
|
const String apkDebugMessage = 'A summary of your APK analysis can be found at: ';
|
||||||
const String iosDebugMessage = 'A summary of your iOS bundle analysis can be found at: ';
|
const String iosDebugMessage = 'A summary of your iOS bundle analysis can be found at: ';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('--analyze-size flag produces expected output on hello_world for Android', () async {
|
testWithoutContext('--analyze-size flag produces expected output on hello_world for Android', () async {
|
||||||
final String woringDirectory = globals.fs.path.join(getFlutterRoot(), 'examples', 'hello_world');
|
final String woringDirectory = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
'build',
|
'build',
|
||||||
'apk',
|
'apk',
|
||||||
'--analyze-size',
|
'--analyze-size',
|
||||||
'--target-platform=android-arm64'
|
'--target-platform=android-arm64'
|
||||||
], workingDirectory: globals.fs.path.join(getFlutterRoot(), 'examples', 'hello_world'));
|
], workingDirectory: fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world'));
|
||||||
|
|
||||||
print(result.stdout);
|
print(result.stdout);
|
||||||
print(result.stderr);
|
print(result.stderr);
|
||||||
@ -34,14 +33,14 @@ void main() {
|
|||||||
.firstWhere((String line) => line.contains(apkDebugMessage));
|
.firstWhere((String line) => line.contains(apkDebugMessage));
|
||||||
|
|
||||||
final String outputFilePath = line.split(apkDebugMessage).last.trim();
|
final String outputFilePath = line.split(apkDebugMessage).last.trim();
|
||||||
expect(globals.fs.file(globals.fs.path.join(woringDirectory, outputFilePath)), exists);
|
expect(fileSystem.file(fileSystem.path.join(woringDirectory, outputFilePath)), exists);
|
||||||
expect(result.exitCode, 0);
|
expect(result.exitCode, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('--analyze-size flag produces expected output on hello_world for iOS', () async {
|
testWithoutContext('--analyze-size flag produces expected output on hello_world for iOS', () async {
|
||||||
final String woringDirectory = globals.fs.path.join(getFlutterRoot(), 'examples', 'hello_world');
|
final String woringDirectory = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
'build',
|
'build',
|
||||||
'ios',
|
'ios',
|
||||||
@ -58,20 +57,20 @@ void main() {
|
|||||||
.firstWhere((String line) => line.contains(iosDebugMessage));
|
.firstWhere((String line) => line.contains(iosDebugMessage));
|
||||||
|
|
||||||
final String outputFilePath = line.split(iosDebugMessage).last.trim();
|
final String outputFilePath = line.split(iosDebugMessage).last.trim();
|
||||||
expect(globals.fs.file(globals.fs.path.join(woringDirectory, outputFilePath)), exists);
|
expect(fileSystem.file(fileSystem.path.join(woringDirectory, outputFilePath)), exists);
|
||||||
expect(result.exitCode, 0);
|
expect(result.exitCode, 0);
|
||||||
}, skip: !const LocalPlatform().isMacOS); // Only supported on macOS
|
}, skip: !const LocalPlatform().isMacOS); // Only supported on macOS
|
||||||
|
|
||||||
test('--analyze-size is only supported in release mode', () async {
|
testWithoutContext('--analyze-size is only supported in release mode', () async {
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
'build',
|
'build',
|
||||||
'apk',
|
'apk',
|
||||||
'--analyze-size',
|
'--analyze-size',
|
||||||
'--target-platform=android-arm64',
|
'--target-platform=android-arm64',
|
||||||
'--debug',
|
'--debug',
|
||||||
], workingDirectory: globals.fs.path.join(getFlutterRoot(), 'examples', 'hello_world'));
|
], workingDirectory: fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world'));
|
||||||
|
|
||||||
print(result.stdout);
|
print(result.stdout);
|
||||||
print(result.stderr);
|
print(result.stderr);
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import 'test_data/background_project.dart';
|
import 'test_data/background_project.dart';
|
||||||
@ -23,7 +22,7 @@ void main() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Hot restart kills background isolates', () async {
|
testWithoutContext('Hot restart kills background isolates', () async {
|
||||||
final BackgroundProject project = BackgroundProject();
|
final BackgroundProject project = BackgroundProject();
|
||||||
await project.setUpIn(tempDir);
|
await project.setUpIn(tempDir);
|
||||||
final FlutterRunTestDriver flutter = FlutterRunTestDriver(tempDir);
|
final FlutterRunTestDriver flutter = FlutterRunTestDriver(tempDir);
|
||||||
@ -58,7 +57,7 @@ void main() {
|
|||||||
await flutter?.stop();
|
await flutter?.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Hot reload updates background isolates', () async {
|
testWithoutContext('Hot reload updates background isolates', () async {
|
||||||
final RepeatingBackgroundProject project = RepeatingBackgroundProject();
|
final RepeatingBackgroundProject project = RepeatingBackgroundProject();
|
||||||
await project.setUpIn(tempDir);
|
await project.setUpIn(tempDir);
|
||||||
final FlutterRunTestDriver flutter = FlutterRunTestDriver(tempDir);
|
final FlutterRunTestDriver flutter = FlutterRunTestDriver(tempDir);
|
||||||
|
@ -7,16 +7,14 @@ import 'dart:convert';
|
|||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
import 'package:flutter_tools/src/features.dart';
|
import 'package:flutter_tools/src/features.dart';
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
import 'package:process/process.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import 'test_utils.dart';
|
import 'test_utils.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('All development tools and deprecated commands are hidden and help text is not verbose', () async {
|
testWithoutContext('All development tools and deprecated commands are hidden and help text is not verbose', () async {
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
'-h',
|
'-h',
|
||||||
'-v',
|
'-v',
|
||||||
@ -34,9 +32,9 @@ void main() {
|
|||||||
expect(result.stdout, isNot(contains('exiting with code 0')));
|
expect(result.stdout, isNot(contains('exiting with code 0')));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter doctor is not verbose', () async {
|
testWithoutContext('flutter doctor is not verbose', () async {
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
'doctor',
|
'doctor',
|
||||||
'-v',
|
'-v',
|
||||||
@ -46,9 +44,9 @@ void main() {
|
|||||||
expect(result.stdout, isNot(contains('exiting with code 0')));
|
expect(result.stdout, isNot(contains('exiting with code 0')));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter doctor -vv super verbose', () async {
|
testWithoutContext('flutter doctor -vv super verbose', () async {
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
'doctor',
|
'doctor',
|
||||||
'-vv',
|
'-vv',
|
||||||
@ -58,9 +56,9 @@ void main() {
|
|||||||
expect(result.stdout, contains('Running shutdown hooks'));
|
expect(result.stdout, contains('Running shutdown hooks'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter config contains all features', () async {
|
testWithoutContext('flutter config contains all features', () async {
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
'config',
|
'config',
|
||||||
]);
|
]);
|
||||||
@ -72,7 +70,7 @@ void main() {
|
|||||||
]));
|
]));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run --machine uses AppRunLogger', () async {
|
testWithoutContext('flutter run --machine uses AppRunLogger', () async {
|
||||||
final Directory directory = createResolvedTempDirectorySync('flutter_run_test.')
|
final Directory directory = createResolvedTempDirectorySync('flutter_run_test.')
|
||||||
.createTempSync('_flutter_run_test.')
|
.createTempSync('_flutter_run_test.')
|
||||||
..createSync(recursive: true);
|
..createSync(recursive: true);
|
||||||
@ -88,8 +86,8 @@ void main() {
|
|||||||
.childDirectory('lib')
|
.childDirectory('lib')
|
||||||
.childFile('main.dart')
|
.childFile('main.dart')
|
||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
'run',
|
'run',
|
||||||
'--show-test-device', // ensure command can fail to run and hit injection of correct logger.
|
'--show-test-device', // ensure command can fail to run and hit injection of correct logger.
|
||||||
@ -103,9 +101,9 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter attach --machine uses AppRunLogger', () async {
|
testWithoutContext('flutter attach --machine uses AppRunLogger', () async {
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
'attach',
|
'attach',
|
||||||
'--machine',
|
'--machine',
|
||||||
@ -115,9 +113,9 @@ void main() {
|
|||||||
expect(result.stderr, contains('Target file')); // Target file not found, but different paths on Windows and Linux/macOS.
|
expect(result.stderr, contains('Target file')); // Target file not found, but different paths on Windows and Linux/macOS.
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter build aot is deprecated', () async {
|
testWithoutContext('flutter build aot is deprecated', () async {
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
'build',
|
'build',
|
||||||
'-h',
|
'-h',
|
||||||
@ -131,9 +129,9 @@ void main() {
|
|||||||
expect(result.stdout, isNot(contains('exiting with code 0')));
|
expect(result.stdout, isNot(contains('exiting with code 0')));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter --version --machine outputs JSON with flutterRoot', () async {
|
testWithoutContext('flutter --version --machine outputs JSON with flutterRoot', () async {
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await processManager.run(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
'--version',
|
'--version',
|
||||||
'--machine',
|
'--machine',
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file_testing/file_testing.dart';
|
import 'package:file_testing/file_testing.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
|
|
||||||
@ -23,7 +22,7 @@ void main() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Can collect coverage in machine mode', () async {
|
testWithoutContext('Can collect coverage in machine mode', () async {
|
||||||
final TestProject project = TestProject();
|
final TestProject project = TestProject();
|
||||||
await project.setUpIn(tempDir);
|
await project.setUpIn(tempDir);
|
||||||
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
|
final FlutterTestTestDriver flutter = FlutterTestTestDriver(tempDir);
|
||||||
|
@ -9,7 +9,6 @@ import 'dart:io';
|
|||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
import 'package:process/process.dart';
|
import 'package:process/process.dart';
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
@ -18,13 +17,13 @@ import 'test_driver.dart';
|
|||||||
import 'test_utils.dart';
|
import 'test_utils.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('device.getDevices', () async {
|
testWithoutContext('device.getDevices', () async {
|
||||||
final Directory tempDir = createResolvedTempDirectorySync('daemon_mode_test.');
|
final Directory tempDir = createResolvedTempDirectorySync('daemon_mode_test.');
|
||||||
|
|
||||||
final BasicProject _project = BasicProject();
|
final BasicProject _project = BasicProject();
|
||||||
await _project.setUpIn(tempDir);
|
await _project.setUpIn(tempDir);
|
||||||
|
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
|
|
||||||
const ProcessManager processManager = LocalProcessManager();
|
const ProcessManager processManager = LocalProcessManager();
|
||||||
final Process process = await processManager.start(
|
final Process process = await processManager.start(
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import 'test_data/stepping_project.dart';
|
import 'test_data/stepping_project.dart';
|
||||||
@ -13,7 +12,7 @@ import 'test_driver.dart';
|
|||||||
import 'test_utils.dart';
|
import 'test_utils.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('can step over statements', () async {
|
testWithoutContext('can step over statements', () async {
|
||||||
final Directory tempDir = createResolvedTempDirectorySync('debugger_stepping_test.');
|
final Directory tempDir = createResolvedTempDirectorySync('debugger_stepping_test.');
|
||||||
|
|
||||||
final SteppingProject _project = SteppingProject();
|
final SteppingProject _project = SteppingProject();
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import 'test_data/stepping_project.dart';
|
import 'test_data/stepping_project.dart';
|
||||||
@ -20,7 +19,7 @@ void main() {
|
|||||||
tempDirectory = createResolvedTempDirectorySync('debugger_stepping_test.');
|
tempDirectory = createResolvedTempDirectorySync('debugger_stepping_test.');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Web debugger can step over statements', () async {
|
testWithoutContext('Web debugger can step over statements', () async {
|
||||||
final WebSteppingProject _project = WebSteppingProject();
|
final WebSteppingProject _project = WebSteppingProject();
|
||||||
await _project.setUpIn(tempDirectory);
|
await _project.setUpIn(tempDirectory);
|
||||||
|
|
||||||
|
@ -5,21 +5,19 @@
|
|||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
import 'package:flutter_tools/src/base/logger.dart';
|
import 'package:flutter_tools/src/base/logger.dart';
|
||||||
import 'package:flutter_tools/src/base/platform.dart';
|
|
||||||
import 'package:flutter_tools/src/base/process.dart';
|
import 'package:flutter_tools/src/base/process.dart';
|
||||||
import 'package:flutter_tools/src/base/terminal.dart';
|
import 'package:flutter_tools/src/base/terminal.dart';
|
||||||
import 'package:process/process.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
const String _kInitialVersion = 'v1.9.1';
|
const String _kInitialVersion = 'v1.9.1';
|
||||||
const String _kBranch = 'dev';
|
const String _kBranch = 'dev';
|
||||||
final FileSystem fileSystem = LocalFileSystem.instance;
|
|
||||||
const ProcessManager processManager = LocalProcessManager();
|
|
||||||
final Stdio stdio = Stdio();
|
final Stdio stdio = Stdio();
|
||||||
final ProcessUtils processUtils = ProcessUtils(processManager: processManager, logger: StdoutLogger(
|
final ProcessUtils processUtils = ProcessUtils(processManager: processManager, logger: StdoutLogger(
|
||||||
terminal: AnsiTerminal(
|
terminal: AnsiTerminal(
|
||||||
platform: const LocalPlatform(),
|
platform: platform,
|
||||||
stdio: stdio,
|
stdio: stdio,
|
||||||
),
|
),
|
||||||
stdio: stdio,
|
stdio: stdio,
|
||||||
@ -46,7 +44,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Can upgrade and downgrade a Flutter checkout', () async {
|
testWithoutContext('Can upgrade and downgrade a Flutter checkout', () async {
|
||||||
final Directory testDirectory = parentDirectory.childDirectory('flutter');
|
final Directory testDirectory = parentDirectory.childDirectory('flutter');
|
||||||
testDirectory.createSync(recursive: true);
|
testDirectory.createSync(recursive: true);
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import 'dart:async';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
import 'package:matcher/matcher.dart';
|
import 'package:matcher/matcher.dart';
|
||||||
|
|
||||||
import 'package:vm_service/vm_service.dart';
|
import 'package:vm_service/vm_service.dart';
|
||||||
@ -47,7 +46,7 @@ void batch1() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
test('flutter run expression evaluation - can evaluate trivial expressions in top level function', () async {
|
testWithoutContext('flutter run expression evaluation - can evaluate trivial expressions in top level function', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await _flutter.run(withDebugger: true);
|
await _flutter.run(withDebugger: true);
|
||||||
await breakInTopLevelFunction(_flutter);
|
await breakInTopLevelFunction(_flutter);
|
||||||
@ -55,7 +54,7 @@ void batch1() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run expression evaluation - can evaluate trivial expressions in build method', () async {
|
testWithoutContext('flutter run expression evaluation - can evaluate trivial expressions in build method', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await _flutter.run(withDebugger: true);
|
await _flutter.run(withDebugger: true);
|
||||||
await breakInBuildMethod(_flutter);
|
await breakInBuildMethod(_flutter);
|
||||||
@ -63,7 +62,7 @@ void batch1() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run expression evaluation - can evaluate complex expressions in top level function', () async {
|
testWithoutContext('flutter run expression evaluation - can evaluate complex expressions in top level function', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await _flutter.run(withDebugger: true);
|
await _flutter.run(withDebugger: true);
|
||||||
await breakInTopLevelFunction(_flutter);
|
await breakInTopLevelFunction(_flutter);
|
||||||
@ -71,7 +70,7 @@ void batch1() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run expression evaluation - can evaluate complex expressions in build method', () async {
|
testWithoutContext('flutter run expression evaluation - can evaluate complex expressions in build method', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await _flutter.run(withDebugger: true);
|
await _flutter.run(withDebugger: true);
|
||||||
await breakInBuildMethod(_flutter);
|
await breakInBuildMethod(_flutter);
|
||||||
@ -79,7 +78,7 @@ void batch1() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run expression evaluation - can evaluate expressions returning complex objects in top level function', () async {
|
testWithoutContext('flutter run expression evaluation - can evaluate expressions returning complex objects in top level function', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await _flutter.run(withDebugger: true);
|
await _flutter.run(withDebugger: true);
|
||||||
await breakInTopLevelFunction(_flutter);
|
await breakInTopLevelFunction(_flutter);
|
||||||
@ -87,7 +86,7 @@ void batch1() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run expression evaluation - can evaluate expressions returning complex objects in build method', () async {
|
testWithoutContext('flutter run expression evaluation - can evaluate expressions returning complex objects in build method', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await _flutter.run(withDebugger: true);
|
await _flutter.run(withDebugger: true);
|
||||||
await breakInBuildMethod(_flutter);
|
await breakInBuildMethod(_flutter);
|
||||||
@ -112,7 +111,7 @@ void batch2() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
test('flutter test expression evaluation - can evaluate trivial expressions in a test', () async {
|
testWithoutContext('flutter test expression evaluation - can evaluate trivial expressions in a test', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await _flutter.test(
|
await _flutter.test(
|
||||||
withDebugger: true,
|
withDebugger: true,
|
||||||
@ -123,7 +122,7 @@ void batch2() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter test expression evaluation - can evaluate complex expressions in a test', () async {
|
testWithoutContext('flutter test expression evaluation - can evaluate complex expressions in a test', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await _flutter.test(
|
await _flutter.test(
|
||||||
withDebugger: true,
|
withDebugger: true,
|
||||||
@ -134,7 +133,7 @@ void batch2() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter test expression evaluation - can evaluate expressions returning complex objects in a test', () async {
|
testWithoutContext('flutter test expression evaluation - can evaluate expressions returning complex objects in a test', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await _flutter.test(
|
await _flutter.test(
|
||||||
withDebugger: true,
|
withDebugger: true,
|
||||||
|
@ -3,10 +3,8 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
import 'package:matcher/matcher.dart';
|
import 'package:matcher/matcher.dart';
|
||||||
|
|
||||||
import 'package:vm_service/vm_service.dart';
|
import 'package:vm_service/vm_service.dart';
|
||||||
@ -55,7 +53,7 @@ void batch1() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
test('flutter run expression evaluation - error if expression evaluation disabled', () async {
|
testWithoutContext('flutter run expression evaluation - error if expression evaluation disabled', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await start(expressionEvaluation: false);
|
await start(expressionEvaluation: false);
|
||||||
await breakInTopLevelFunction(_flutter);
|
await breakInTopLevelFunction(_flutter);
|
||||||
@ -63,7 +61,7 @@ void batch1() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
||||||
|
|
||||||
test('flutter run expression evaluation - no native javascript objects in static scope', () async {
|
testWithoutContext('flutter run expression evaluation - no native javascript objects in static scope', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await start(expressionEvaluation: true);
|
await start(expressionEvaluation: true);
|
||||||
await breakInTopLevelFunction(_flutter);
|
await breakInTopLevelFunction(_flutter);
|
||||||
@ -71,7 +69,7 @@ void batch1() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
||||||
|
|
||||||
test('flutter run expression evaluation - can handle compilation errors', () async {
|
testWithoutContext('flutter run expression evaluation - can handle compilation errors', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await start(expressionEvaluation: true);
|
await start(expressionEvaluation: true);
|
||||||
await breakInTopLevelFunction(_flutter);
|
await breakInTopLevelFunction(_flutter);
|
||||||
@ -79,7 +77,7 @@ void batch1() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
||||||
|
|
||||||
test('flutter run expression evaluation - can evaluate trivial expressions in top level function', () async {
|
testWithoutContext('flutter run expression evaluation - can evaluate trivial expressions in top level function', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await start(expressionEvaluation: true);
|
await start(expressionEvaluation: true);
|
||||||
await breakInTopLevelFunction(_flutter);
|
await breakInTopLevelFunction(_flutter);
|
||||||
@ -87,7 +85,7 @@ void batch1() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
||||||
|
|
||||||
test('flutter run expression evaluation - can evaluate trivial expressions in build method', () async {
|
testWithoutContext('flutter run expression evaluation - can evaluate trivial expressions in build method', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await start(expressionEvaluation: true);
|
await start(expressionEvaluation: true);
|
||||||
await breakInBuildMethod(_flutter);
|
await breakInBuildMethod(_flutter);
|
||||||
@ -95,7 +93,7 @@ void batch1() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
||||||
|
|
||||||
test('flutter run expression evaluation - can evaluate complex expressions in top level function', () async {
|
testWithoutContext('flutter run expression evaluation - can evaluate complex expressions in top level function', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await start(expressionEvaluation: true);
|
await start(expressionEvaluation: true);
|
||||||
await breakInTopLevelFunction(_flutter);
|
await breakInTopLevelFunction(_flutter);
|
||||||
@ -103,7 +101,7 @@ void batch1() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
||||||
|
|
||||||
test('flutter run expression evaluation - can evaluate complex expressions in build method', () async {
|
testWithoutContext('flutter run expression evaluation - can evaluate complex expressions in build method', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await _flutter.run(withDebugger: true, chrome: true);
|
await _flutter.run(withDebugger: true, chrome: true);
|
||||||
await breakInBuildMethod(_flutter);
|
await breakInBuildMethod(_flutter);
|
||||||
@ -147,7 +145,7 @@ void batch2() {
|
|||||||
startPaused: true, script: _project.testFilePath);
|
startPaused: true, script: _project.testFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
test('flutter test expression evaluation - error if expression evaluation disabled', () async {
|
testWithoutContext('flutter test expression evaluation - error if expression evaluation disabled', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await startPaused(expressionEvaluation: false);
|
await startPaused(expressionEvaluation: false);
|
||||||
await breakInMethod(_flutter);
|
await breakInMethod(_flutter);
|
||||||
@ -155,7 +153,7 @@ void batch2() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
||||||
|
|
||||||
test('flutter test expression evaluation - can evaluate trivial expressions in a test', () async {
|
testWithoutContext('flutter test expression evaluation - can evaluate trivial expressions in a test', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await startPaused(expressionEvaluation: true);
|
await startPaused(expressionEvaluation: true);
|
||||||
await breakInMethod(_flutter);
|
await breakInMethod(_flutter);
|
||||||
@ -163,7 +161,7 @@ void batch2() {
|
|||||||
await cleanProject();
|
await cleanProject();
|
||||||
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
}, skip: 'CI not setup for web tests'); // https://github.com/flutter/flutter/issues/53779
|
||||||
|
|
||||||
test('flutter test expression evaluation - can evaluate complex expressions in a test', () async {
|
testWithoutContext('flutter test expression evaluation - can evaluate complex expressions in a test', () async {
|
||||||
await initProject();
|
await initProject();
|
||||||
await startPaused(expressionEvaluation: true);
|
await startPaused(expressionEvaluation: true);
|
||||||
await breakInMethod(_flutter);
|
await breakInMethod(_flutter);
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import 'test_data/basic_project.dart';
|
import 'test_data/basic_project.dart';
|
||||||
@ -37,7 +36,7 @@ void main() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('writes pid-file', () async {
|
testWithoutContext('writes pid-file', () async {
|
||||||
final File pidFile = tempDir.childFile('test.pid');
|
final File pidFile = tempDir.childFile('test.pid');
|
||||||
await _flutterRun.run(withDebugger: true);
|
await _flutterRun.run(withDebugger: true);
|
||||||
await _flutterAttach.attach(
|
await _flutterAttach.attach(
|
||||||
@ -47,13 +46,13 @@ void main() {
|
|||||||
expect(pidFile.existsSync(), isTrue);
|
expect(pidFile.existsSync(), isTrue);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can hot reload', () async {
|
testWithoutContext('can hot reload', () async {
|
||||||
await _flutterRun.run(withDebugger: true);
|
await _flutterRun.run(withDebugger: true);
|
||||||
await _flutterAttach.attach(_flutterRun.vmServicePort);
|
await _flutterAttach.attach(_flutterRun.vmServicePort);
|
||||||
await _flutterAttach.hotReload();
|
await _flutterAttach.hotReload();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can detach, reattach, hot reload', () async {
|
testWithoutContext('can detach, reattach, hot reload', () async {
|
||||||
await _flutterRun.run(withDebugger: true);
|
await _flutterRun.run(withDebugger: true);
|
||||||
await _flutterAttach.attach(_flutterRun.vmServicePort);
|
await _flutterAttach.attach(_flutterRun.vmServicePort);
|
||||||
await _flutterAttach.detach();
|
await _flutterAttach.detach();
|
||||||
@ -61,7 +60,7 @@ void main() {
|
|||||||
await _flutterAttach.hotReload();
|
await _flutterAttach.hotReload();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('killing process behaves the same as detach ', () async {
|
testWithoutContext('killing process behaves the same as detach ', () async {
|
||||||
await _flutterRun.run(withDebugger: true);
|
await _flutterRun.run(withDebugger: true);
|
||||||
await _flutterAttach.attach(_flutterRun.vmServicePort);
|
await _flutterAttach.attach(_flutterRun.vmServicePort);
|
||||||
await _flutterAttach.quit();
|
await _flutterAttach.quit();
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import 'test_data/basic_project.dart';
|
import 'test_data/basic_project.dart';
|
||||||
@ -26,7 +25,7 @@ void main() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can correctly reference flutter generated code.', () async {
|
testWithoutContext('can correctly reference flutter generated code.', () async {
|
||||||
await flutter.run();
|
await flutter.run();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,7 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
import 'package:process/process.dart';
|
import 'package:process/process.dart';
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
@ -29,12 +27,12 @@ void main() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run reports an error if an invalid device is supplied', () async {
|
testWithoutContext('flutter run reports an error if an invalid device is supplied', () async {
|
||||||
// This test forces flutter to check for all possible devices to catch issues
|
// This test forces flutter to check for all possible devices to catch issues
|
||||||
// like https://github.com/flutter/flutter/issues/21418 which were skipped
|
// like https://github.com/flutter/flutter/issues/21418 which were skipped
|
||||||
// over because other integration tests run using flutter-tester which short-cuts
|
// over because other integration tests run using flutter-tester which short-cuts
|
||||||
// some of the checks for devices.
|
// some of the checks for devices.
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
|
|
||||||
const ProcessManager _processManager = LocalProcessManager();
|
const ProcessManager _processManager = LocalProcessManager();
|
||||||
final ProcessResult _proc = await _processManager.run(
|
final ProcessResult _proc = await _processManager.run(
|
||||||
@ -50,7 +48,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run writes pid-file', () async {
|
testWithoutContext('flutter run writes pid-file', () async {
|
||||||
final File pidFile = tempDir.childFile('test.pid');
|
final File pidFile = tempDir.childFile('test.pid');
|
||||||
await _flutter.run(pidFile: pidFile);
|
await _flutter.run(pidFile: pidFile);
|
||||||
expect(pidFile.existsSync(), isTrue);
|
expect(pidFile.existsSync(), isTrue);
|
||||||
|
@ -3,12 +3,9 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
import 'package:process/process.dart';
|
|
||||||
import 'package:vm_service/vm_service.dart';
|
import 'package:vm_service/vm_service.dart';
|
||||||
import 'package:vm_service/vm_service_io.dart';
|
import 'package:vm_service/vm_service_io.dart';
|
||||||
|
|
||||||
@ -33,8 +30,8 @@ void main() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run in non-machine mode reports an early error in an application', () async {
|
testWithoutContext('flutter run in non-machine mode reports an early error in an application', () async {
|
||||||
final String flutterBin = globals.fs.path.join(
|
final String flutterBin = fileSystem.path.join(
|
||||||
getFlutterRoot(),
|
getFlutterRoot(),
|
||||||
'bin',
|
'bin',
|
||||||
'flutter',
|
'flutter',
|
||||||
@ -42,7 +39,7 @@ void main() {
|
|||||||
|
|
||||||
final StringBuffer stdout = StringBuffer();
|
final StringBuffer stdout = StringBuffer();
|
||||||
|
|
||||||
final Process process = await const LocalProcessManager().start(<String>[
|
final Process process = await processManager.start(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
'run',
|
'run',
|
||||||
'--disable-service-auth-codes',
|
'--disable-service-auth-codes',
|
||||||
@ -79,7 +76,7 @@ void main() {
|
|||||||
expect(stdout.toString(), contains(_exceptionStart));
|
expect(stdout.toString(), contains(_exceptionStart));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run in machine mode does not print an error', () async {
|
testWithoutContext('flutter run in machine mode does not print an error', () async {
|
||||||
final StringBuffer stdout = StringBuffer();
|
final StringBuffer stdout = StringBuffer();
|
||||||
|
|
||||||
await _flutter.run(
|
await _flutter.run(
|
||||||
@ -105,7 +102,7 @@ void main() {
|
|||||||
expect(stdout.toString(), isNot(contains(_exceptionStart)));
|
expect(stdout.toString(), isNot(contains(_exceptionStart)));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run for web reports an early error in an application', () async {
|
testWithoutContext('flutter run for web reports an early error in an application', () async {
|
||||||
final StringBuffer stdout = StringBuffer();
|
final StringBuffer stdout = StringBuffer();
|
||||||
|
|
||||||
await _flutter.run(
|
await _flutter.run(
|
||||||
|
@ -2,22 +2,22 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
final String flutterTools = globals.fs.path.join(getFlutterRoot(), 'packages', 'flutter_tools');
|
final String flutterTools = fileSystem.path.join(getFlutterRoot(), 'packages', 'flutter_tools');
|
||||||
|
|
||||||
test('no imports of commands/* or test/* in lib/src/*', () {
|
test('no imports of commands/* or test/* in lib/src/*', () {
|
||||||
final List<String> skippedPaths = <String> [
|
final List<String> skippedPaths = <String> [
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'commands'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'commands'),
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'test'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'test'),
|
||||||
];
|
];
|
||||||
bool _isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path));
|
bool _isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path));
|
||||||
|
|
||||||
final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, 'lib', 'src'))
|
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, 'lib', 'src'))
|
||||||
.listSync(recursive: true)
|
.listSync(recursive: true)
|
||||||
.where(_isDartFile)
|
.where(_isDartFile)
|
||||||
.where(_isNotSkipped)
|
.where(_isNotSkipped)
|
||||||
@ -29,7 +29,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
if (line.startsWith(RegExp(r'import.*commands/'))
|
if (line.startsWith(RegExp(r'import.*commands/'))
|
||||||
|| line.startsWith(RegExp(r'import.*test/'))) {
|
|| line.startsWith(RegExp(r'import.*test/'))) {
|
||||||
final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
|
final String relativePath = fileSystem.path.relative(file.path, from:flutterTools);
|
||||||
fail('$relativePath imports $line. This import introduces a layering violation. '
|
fail('$relativePath imports $line. This import introduces a layering violation. '
|
||||||
'Please find another way to access the information you are using.');
|
'Please find another way to access the information you are using.');
|
||||||
}
|
}
|
||||||
@ -41,9 +41,9 @@ void main() {
|
|||||||
final List<String> skippedPaths = <String> [];
|
final List<String> skippedPaths = <String> [];
|
||||||
bool _isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path));
|
bool _isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path));
|
||||||
|
|
||||||
final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, 'lib', 'src'))
|
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, 'lib', 'src'))
|
||||||
.listSync(recursive: true)
|
.listSync(recursive: true)
|
||||||
.followedBy(globals.fs.directory(globals.fs.path.join(flutterTools, 'test',)).listSync(recursive: true))
|
.followedBy(fileSystem.directory(fileSystem.path.join(flutterTools, 'test',)).listSync(recursive: true))
|
||||||
.where(_isDartFile)
|
.where(_isDartFile)
|
||||||
.where(_isNotSkipped)
|
.where(_isNotSkipped)
|
||||||
.map(_asFile);
|
.map(_asFile);
|
||||||
@ -51,7 +51,7 @@ void main() {
|
|||||||
for (final String line in file.readAsLinesSync()) {
|
for (final String line in file.readAsLinesSync()) {
|
||||||
if (line.startsWith(RegExp(r'import.*globals.dart'))
|
if (line.startsWith(RegExp(r'import.*globals.dart'))
|
||||||
&& !line.contains(r'as globals')) {
|
&& !line.contains(r'as globals')) {
|
||||||
final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
|
final String relativePath = fileSystem.path.relative(file.path, from:flutterTools);
|
||||||
fail('$relativePath imports globals.dart without a globals prefix.');
|
fail('$relativePath imports globals.dart without a globals prefix.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,14 +60,14 @@ void main() {
|
|||||||
|
|
||||||
test('no unauthorized imports of dart:io', () {
|
test('no unauthorized imports of dart:io', () {
|
||||||
final List<String> allowedPaths = <String>[
|
final List<String> allowedPaths = <String>[
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'base', 'io.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'io.dart'),
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'base', 'platform.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'platform.dart'),
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_io.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_io.dart'),
|
||||||
];
|
];
|
||||||
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
|
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
|
||||||
|
|
||||||
for (final String dirName in <String>['lib', 'bin']) {
|
for (final String dirName in <String>['lib', 'bin']) {
|
||||||
final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName))
|
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
|
||||||
.listSync(recursive: true)
|
.listSync(recursive: true)
|
||||||
.where(_isDartFile)
|
.where(_isDartFile)
|
||||||
.where(_isNotAllowed)
|
.where(_isNotAllowed)
|
||||||
@ -76,7 +76,7 @@ void main() {
|
|||||||
for (final String line in file.readAsLinesSync()) {
|
for (final String line in file.readAsLinesSync()) {
|
||||||
if (line.startsWith(RegExp(r'import.*dart:io')) &&
|
if (line.startsWith(RegExp(r'import.*dart:io')) &&
|
||||||
!line.contains('ignore: dart_io_import')) {
|
!line.contains('ignore: dart_io_import')) {
|
||||||
final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
|
final String relativePath = fileSystem.path.relative(file.path, from:flutterTools);
|
||||||
fail("$relativePath imports 'dart:io'; import 'lib/src/base/io.dart' instead");
|
fail("$relativePath imports 'dart:io'; import 'lib/src/base/io.dart' instead");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,15 +86,15 @@ void main() {
|
|||||||
|
|
||||||
test('no unauthorized imports of test_api', () {
|
test('no unauthorized imports of test_api', () {
|
||||||
final List<String> allowedPaths = <String>[
|
final List<String> allowedPaths = <String>[
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'build_runner', 'build_script.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'build_runner', 'build_script.dart'),
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_platform.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_platform.dart'),
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_web_platform.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_web_platform.dart'),
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'test', 'test_wrapper.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'test', 'test_wrapper.dart'),
|
||||||
];
|
];
|
||||||
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
|
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
|
||||||
|
|
||||||
for (final String dirName in <String>['lib']) {
|
for (final String dirName in <String>['lib']) {
|
||||||
final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName))
|
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
|
||||||
.listSync(recursive: true)
|
.listSync(recursive: true)
|
||||||
.where(_isDartFile)
|
.where(_isDartFile)
|
||||||
.where(_isNotAllowed)
|
.where(_isNotAllowed)
|
||||||
@ -103,7 +103,7 @@ void main() {
|
|||||||
for (final String line in file.readAsLinesSync()) {
|
for (final String line in file.readAsLinesSync()) {
|
||||||
if (line.startsWith(RegExp(r'import.*package:test_api')) &&
|
if (line.startsWith(RegExp(r'import.*package:test_api')) &&
|
||||||
!line.contains('ignore: test_api_import')) {
|
!line.contains('ignore: test_api_import')) {
|
||||||
final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
|
final String relativePath = fileSystem.path.relative(file.path, from:flutterTools);
|
||||||
fail("$relativePath imports 'package:test_api/test_api.dart';");
|
fail("$relativePath imports 'package:test_api/test_api.dart';");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,11 +113,11 @@ void main() {
|
|||||||
|
|
||||||
test('no unauthorized imports of package:path', () {
|
test('no unauthorized imports of package:path', () {
|
||||||
final List<String> allowedPath = <String>[
|
final List<String> allowedPath = <String>[
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'build_runner', 'web_compilation_delegate.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'build_runner', 'web_compilation_delegate.dart'),
|
||||||
globals.fs.path.join(flutterTools, 'test', 'general.shard', 'platform_plugins_test.dart'),
|
fileSystem.path.join(flutterTools, 'test', 'general.shard', 'platform_plugins_test.dart'),
|
||||||
];
|
];
|
||||||
for (final String dirName in <String>['lib', 'bin', 'test']) {
|
for (final String dirName in <String>['lib', 'bin', 'test']) {
|
||||||
final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName))
|
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
|
||||||
.listSync(recursive: true)
|
.listSync(recursive: true)
|
||||||
.where(_isDartFile)
|
.where(_isDartFile)
|
||||||
.where((FileSystemEntity entity) => !allowedPath.contains(entity.path))
|
.where((FileSystemEntity entity) => !allowedPath.contains(entity.path))
|
||||||
@ -126,8 +126,8 @@ void main() {
|
|||||||
for (final String line in file.readAsLinesSync()) {
|
for (final String line in file.readAsLinesSync()) {
|
||||||
if (line.startsWith(RegExp(r'import.*package:path/path.dart')) &&
|
if (line.startsWith(RegExp(r'import.*package:path/path.dart')) &&
|
||||||
!line.contains('ignore: package_path_import')) {
|
!line.contains('ignore: package_path_import')) {
|
||||||
final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
|
final String relativePath = fileSystem.path.relative(file.path, from:flutterTools);
|
||||||
fail("$relativePath imports 'package:path/path.dart'; use 'globals.fs.path' instead");
|
fail("$relativePath imports 'package:path/path.dart'; use 'fileSystem.path' instead");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,10 +136,11 @@ void main() {
|
|||||||
|
|
||||||
test('no unauthorized imports of package:file/local.dart', () {
|
test('no unauthorized imports of package:file/local.dart', () {
|
||||||
final List<String> allowedPath = <String>[
|
final List<String> allowedPath = <String>[
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'base', 'file_system.dart'),
|
fileSystem.path.join(flutterTools, 'test', 'integration.shard', 'test_utils.dart'),
|
||||||
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'file_system.dart'),
|
||||||
];
|
];
|
||||||
for (final String dirName in <String>['lib', 'bin', 'test']) {
|
for (final String dirName in <String>['lib', 'bin', 'test']) {
|
||||||
final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName))
|
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
|
||||||
.listSync(recursive: true)
|
.listSync(recursive: true)
|
||||||
.where(_isDartFile)
|
.where(_isDartFile)
|
||||||
.where((FileSystemEntity entity) => !allowedPath.contains(entity.path))
|
.where((FileSystemEntity entity) => !allowedPath.contains(entity.path))
|
||||||
@ -147,7 +148,7 @@ void main() {
|
|||||||
for (final File file in files) {
|
for (final File file in files) {
|
||||||
for (final String line in file.readAsLinesSync()) {
|
for (final String line in file.readAsLinesSync()) {
|
||||||
if (line.startsWith(RegExp(r'import.*package:file/local.dart'))) {
|
if (line.startsWith(RegExp(r'import.*package:file/local.dart'))) {
|
||||||
final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
|
final String relativePath = fileSystem.path.relative(file.path, from:flutterTools);
|
||||||
fail("$relativePath imports 'package:file/local.dart'; use 'lib/src/base/file_system.dart' instead");
|
fail("$relativePath imports 'package:file/local.dart'; use 'lib/src/base/file_system.dart' instead");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,13 +158,13 @@ void main() {
|
|||||||
|
|
||||||
test('no unauthorized imports of dart:convert', () {
|
test('no unauthorized imports of dart:convert', () {
|
||||||
final List<String> allowedPaths = <String>[
|
final List<String> allowedPaths = <String>[
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'convert.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'convert.dart'),
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_io.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_io.dart'),
|
||||||
];
|
];
|
||||||
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
|
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => path != entity.path);
|
||||||
|
|
||||||
for (final String dirName in <String>['lib']) {
|
for (final String dirName in <String>['lib']) {
|
||||||
final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName))
|
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
|
||||||
.listSync(recursive: true)
|
.listSync(recursive: true)
|
||||||
.where(_isDartFile)
|
.where(_isDartFile)
|
||||||
.where(_isNotAllowed)
|
.where(_isNotAllowed)
|
||||||
@ -172,7 +173,7 @@ void main() {
|
|||||||
for (final String line in file.readAsLinesSync()) {
|
for (final String line in file.readAsLinesSync()) {
|
||||||
if (line.startsWith(RegExp(r'import.*dart:convert')) &&
|
if (line.startsWith(RegExp(r'import.*dart:convert')) &&
|
||||||
!line.contains('ignore: dart_convert_import')) {
|
!line.contains('ignore: dart_convert_import')) {
|
||||||
final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
|
final String relativePath = fileSystem.path.relative(file.path, from:flutterTools);
|
||||||
fail("$relativePath imports 'dart:convert'; import 'lib/src/convert.dart' instead");
|
fail("$relativePath imports 'dart:convert'; import 'lib/src/convert.dart' instead");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,16 +183,16 @@ void main() {
|
|||||||
|
|
||||||
test('no unauthorized imports of build_runner or dwds', () {
|
test('no unauthorized imports of build_runner or dwds', () {
|
||||||
final List<String> allowedPaths = <String>[
|
final List<String> allowedPaths = <String>[
|
||||||
globals.fs.path.join(flutterTools, 'test', 'src', 'build_runner'),
|
fileSystem.path.join(flutterTools, 'test', 'src', 'build_runner'),
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'src', 'build_runner'),
|
fileSystem.path.join(flutterTools, 'lib', 'src', 'build_runner'),
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'executable.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'executable.dart'),
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'devfs_web.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'devfs_web.dart'),
|
||||||
globals.fs.path.join(flutterTools, 'lib', 'resident_web_runner.dart'),
|
fileSystem.path.join(flutterTools, 'lib', 'resident_web_runner.dart'),
|
||||||
];
|
];
|
||||||
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => !entity.path.contains(path));
|
bool _isNotAllowed(FileSystemEntity entity) => allowedPaths.every((String path) => !entity.path.contains(path));
|
||||||
|
|
||||||
for (final String dirName in <String>['lib']) {
|
for (final String dirName in <String>['lib']) {
|
||||||
final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName))
|
final Iterable<File> files = fileSystem.directory(fileSystem.path.join(flutterTools, dirName))
|
||||||
.listSync(recursive: true)
|
.listSync(recursive: true)
|
||||||
.where(_isDartFile)
|
.where(_isDartFile)
|
||||||
.where(_isNotAllowed)
|
.where(_isNotAllowed)
|
||||||
@ -203,7 +204,7 @@ void main() {
|
|||||||
line.startsWith(RegExp(r'import.*package:build_config/build_config.dart')) ||
|
line.startsWith(RegExp(r'import.*package:build_config/build_config.dart')) ||
|
||||||
line.startsWith(RegExp(r'import.*dwds:*.dart')) ||
|
line.startsWith(RegExp(r'import.*dwds:*.dart')) ||
|
||||||
line.startsWith(RegExp(r'import.*build_runner/.*.dart'))) {
|
line.startsWith(RegExp(r'import.*build_runner/.*.dart'))) {
|
||||||
final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
|
final String relativePath = fileSystem.path.relative(file.path, from:flutterTools);
|
||||||
fail('$relativePath imports a build_runner package');
|
fail('$relativePath imports a build_runner package');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,10 +213,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('no import of packages in tool_backend.dart', () {
|
test('no import of packages in tool_backend.dart', () {
|
||||||
final File file = globals.fs.file(globals.fs.path.join(flutterTools, 'bin', 'tool_backend.dart'));
|
final File file = fileSystem.file(fileSystem.path.join(flutterTools, 'bin', 'tool_backend.dart'));
|
||||||
for (final String line in file.readAsLinesSync()) {
|
for (final String line in file.readAsLinesSync()) {
|
||||||
if (line.startsWith(RegExp(r'import.*package:.*'))) {
|
if (line.startsWith(RegExp(r'import.*package:.*'))) {
|
||||||
final String relativePath = globals.fs.path.relative(file.path, from:flutterTools);
|
final String relativePath = fileSystem.path.relative(file.path, from:flutterTools);
|
||||||
fail('$relativePath imports a package');
|
fail('$relativePath imports a package');
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import 'test_data/gen_l10n_project.dart';
|
import 'test_data/gen_l10n_project.dart';
|
||||||
@ -153,7 +152,7 @@ void main() {
|
|||||||
|
|
||||||
// TODO(jsimmons): need a localization test that uses deferred loading
|
// TODO(jsimmons): need a localization test that uses deferred loading
|
||||||
// (see https://github.com/flutter/flutter/issues/61911)
|
// (see https://github.com/flutter/flutter/issues/61911)
|
||||||
test('generated l10n classes produce expected localized strings', () async {
|
testWithoutContext('generated l10n classes produce expected localized strings', () async {
|
||||||
await project.setUpIn(tempDir);
|
await project.setUpIn(tempDir);
|
||||||
flutter = FlutterRunTestDriver(tempDir);
|
flutter = FlutterRunTestDriver(tempDir);
|
||||||
final StringBuffer stdout = await runApp();
|
final StringBuffer stdout = await runApp();
|
||||||
|
@ -6,7 +6,6 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/common.dart';
|
import 'package:flutter_tools/src/base/common.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
import 'package:vm_service/vm_service.dart';
|
import 'package:vm_service/vm_service.dart';
|
||||||
import 'package:vm_service/vm_service_io.dart';
|
import 'package:vm_service/vm_service_io.dart';
|
||||||
|
|
||||||
@ -31,12 +30,12 @@ void main() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('hot reload works without error', () async {
|
testWithoutContext('hot reload works without error', () async {
|
||||||
await flutter.run();
|
await flutter.run();
|
||||||
await flutter.hotReload();
|
await flutter.hotReload();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('multiple overlapping hot reload are debounced and queued', () async {
|
testWithoutContext('multiple overlapping hot reload are debounced and queued', () async {
|
||||||
await flutter.run();
|
await flutter.run();
|
||||||
// Capture how many *real* hot reloads occur.
|
// Capture how many *real* hot reloads occur.
|
||||||
int numReloads = 0;
|
int numReloads = 0;
|
||||||
@ -70,7 +69,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('newly added code executes during hot reload', () async {
|
testWithoutContext('newly added code executes during hot reload', () async {
|
||||||
final StringBuffer stdout = StringBuffer();
|
final StringBuffer stdout = StringBuffer();
|
||||||
final StreamSubscription<String> subscription = flutter.stdout.listen(stdout.writeln);
|
final StreamSubscription<String> subscription = flutter.stdout.listen(stdout.writeln);
|
||||||
await flutter.run();
|
await flutter.run();
|
||||||
@ -83,7 +82,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('fastReassemble behavior triggers hot reload behavior with evaluation of expression', () async {
|
testWithoutContext('fastReassemble behavior triggers hot reload behavior with evaluation of expression', () async {
|
||||||
final Completer<void> tick1 = Completer<void>();
|
final Completer<void> tick1 = Completer<void>();
|
||||||
final Completer<void> tick2 = Completer<void>();
|
final Completer<void> tick2 = Completer<void>();
|
||||||
final Completer<void> tick3 = Completer<void>();
|
final Completer<void> tick3 = Completer<void>();
|
||||||
@ -150,12 +149,12 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('hot restart works without error', () async {
|
testWithoutContext('hot restart works without error', () async {
|
||||||
await flutter.run();
|
await flutter.run();
|
||||||
await flutter.hotRestart();
|
await flutter.hotRestart();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('breakpoints are hit after hot reload', () async {
|
testWithoutContext('breakpoints are hit after hot reload', () async {
|
||||||
Isolate isolate;
|
Isolate isolate;
|
||||||
final Completer<void> sawTick1 = Completer<void>();
|
final Completer<void> sawTick1 = Completer<void>();
|
||||||
final Completer<void> sawDebuggerPausedMessage = Completer<void>();
|
final Completer<void> sawDebuggerPausedMessage = Completer<void>();
|
||||||
@ -209,7 +208,7 @@ void main() {
|
|||||||
await subscription.cancel();
|
await subscription.cancel();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("hot reload doesn't reassemble if paused", () async {
|
testWithoutContext("hot reload doesn't reassemble if paused", () async {
|
||||||
final Completer<void> sawTick1 = Completer<void>();
|
final Completer<void> sawTick1 = Completer<void>();
|
||||||
final Completer<void> sawDebuggerPausedMessage1 = Completer<void>();
|
final Completer<void> sawDebuggerPausedMessage1 = Completer<void>();
|
||||||
final Completer<void> sawDebuggerPausedMessage2 = Completer<void>();
|
final Completer<void> sawDebuggerPausedMessage2 = Completer<void>();
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import 'test_data/basic_project.dart';
|
import 'test_data/basic_project.dart';
|
||||||
@ -33,13 +32,13 @@ void main() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run does not terminate when a debugger is attached', () async {
|
testWithoutContext('flutter run does not terminate when a debugger is attached', () async {
|
||||||
await _flutter.run(withDebugger: true);
|
await _flutter.run(withDebugger: true);
|
||||||
await Future<void>.delayed(requiredLifespan);
|
await Future<void>.delayed(requiredLifespan);
|
||||||
expect(_flutter.hasExited, equals(false));
|
expect(_flutter.hasExited, equals(false));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('fluter run does not terminate when a debugger is attached and pause-on-exceptions', () async {
|
testWithoutContext('fluter run does not terminate when a debugger is attached and pause-on-exceptions', () async {
|
||||||
await _flutter.run(withDebugger: true, pauseOnExceptions: true);
|
await _flutter.run(withDebugger: true, pauseOnExceptions: true);
|
||||||
await Future<void>.delayed(requiredLifespan);
|
await Future<void>.delayed(requiredLifespan);
|
||||||
expect(_flutter.hasExited, equals(false));
|
expect(_flutter.hasExited, equals(false));
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io' as io;
|
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
@ -11,10 +10,9 @@ import 'package:flutter_tools/src/base/logger.dart';
|
|||||||
import 'package:flutter_tools/src/base/platform.dart';
|
import 'package:flutter_tools/src/base/platform.dart';
|
||||||
import 'package:flutter_tools/src/base/terminal.dart';
|
import 'package:flutter_tools/src/base/terminal.dart';
|
||||||
import 'package:flutter_tools/src/ios/plist_parser.dart';
|
import 'package:flutter_tools/src/ios/plist_parser.dart';
|
||||||
import 'package:process/process.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import '../src/context.dart';
|
import 'test_utils.dart';
|
||||||
|
|
||||||
const String base64PlistXml =
|
const String base64PlistXml =
|
||||||
'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0I'
|
'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0I'
|
||||||
@ -38,8 +36,6 @@ void main() {
|
|||||||
// `ProcessManager` because doing so wouldn't actually test what we want to
|
// `ProcessManager` because doing so wouldn't actually test what we want to
|
||||||
// test, which is that the underlying tool we're using to parse Plist files
|
// test, which is that the underlying tool we're using to parse Plist files
|
||||||
// works with the way we're calling it.
|
// works with the way we're calling it.
|
||||||
FileSystem fileSystem;
|
|
||||||
ProcessManager processManager;
|
|
||||||
File file;
|
File file;
|
||||||
PlistParser parser;
|
PlistParser parser;
|
||||||
BufferLogger logger;
|
BufferLogger logger;
|
||||||
@ -52,8 +48,6 @@ void main() {
|
|||||||
stdio: null,
|
stdio: null,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
fileSystem = LocalFileSystemBlockingSetCurrentDirectory();
|
|
||||||
processManager = const LocalProcessManager();
|
|
||||||
parser = PlistParser(
|
parser = PlistParser(
|
||||||
fileSystem: fileSystem,
|
fileSystem: fileSystem,
|
||||||
processManager: processManager,
|
processManager: processManager,
|
||||||
@ -73,7 +67,7 @@ void main() {
|
|||||||
expect(parser.getValueFromFile(file.absolute.path, 'CFBundleIdentifier'), 'io.flutter.flutter.app');
|
expect(parser.getValueFromFile(file.absolute.path, 'CFBundleIdentifier'), 'io.flutter.flutter.app');
|
||||||
expect(logger.statusText, isEmpty);
|
expect(logger.statusText, isEmpty);
|
||||||
expect(logger.errorText, isEmpty);
|
expect(logger.errorText, isEmpty);
|
||||||
}, skip: !io.Platform.isMacOS);
|
}, skip: !platform.isMacOS);
|
||||||
|
|
||||||
testWithoutContext('PlistParser.getValueFromFile works with binary file', () {
|
testWithoutContext('PlistParser.getValueFromFile works with binary file', () {
|
||||||
file.writeAsBytesSync(base64.decode(base64PlistBinary));
|
file.writeAsBytesSync(base64.decode(base64PlistBinary));
|
||||||
@ -82,7 +76,7 @@ void main() {
|
|||||||
expect(parser.getValueFromFile(file.absolute.path, 'CFBundleIdentifier'), 'io.flutter.flutter.app');
|
expect(parser.getValueFromFile(file.absolute.path, 'CFBundleIdentifier'), 'io.flutter.flutter.app');
|
||||||
expect(logger.statusText, isEmpty);
|
expect(logger.statusText, isEmpty);
|
||||||
expect(logger.errorText, isEmpty);
|
expect(logger.errorText, isEmpty);
|
||||||
}, skip: !io.Platform.isMacOS);
|
}, skip: !platform.isMacOS);
|
||||||
|
|
||||||
testWithoutContext('PlistParser.getValueFromFile works with json file', () {
|
testWithoutContext('PlistParser.getValueFromFile works with json file', () {
|
||||||
file.writeAsBytesSync(base64.decode(base64PlistJson));
|
file.writeAsBytesSync(base64.decode(base64PlistJson));
|
||||||
@ -91,13 +85,13 @@ void main() {
|
|||||||
expect(parser.getValueFromFile(file.absolute.path, 'CFBundleIdentifier'), 'io.flutter.flutter.app');
|
expect(parser.getValueFromFile(file.absolute.path, 'CFBundleIdentifier'), 'io.flutter.flutter.app');
|
||||||
expect(logger.statusText, isEmpty);
|
expect(logger.statusText, isEmpty);
|
||||||
expect(logger.errorText, isEmpty);
|
expect(logger.errorText, isEmpty);
|
||||||
}, skip: !io.Platform.isMacOS);
|
}, skip: !platform.isMacOS);
|
||||||
|
|
||||||
testWithoutContext('PlistParser.getValueFromFile returns null for non-existent plist file', () {
|
testWithoutContext('PlistParser.getValueFromFile returns null for non-existent plist file', () {
|
||||||
expect(parser.getValueFromFile('missing.plist', 'CFBundleIdentifier'), null);
|
expect(parser.getValueFromFile('missing.plist', 'CFBundleIdentifier'), null);
|
||||||
expect(logger.statusText, isEmpty);
|
expect(logger.statusText, isEmpty);
|
||||||
expect(logger.errorText, isEmpty);
|
expect(logger.errorText, isEmpty);
|
||||||
}, skip: !io.Platform.isMacOS);
|
}, skip: !platform.isMacOS);
|
||||||
|
|
||||||
testWithoutContext('PlistParser.getValueFromFile returns null for non-existent key within plist', () {
|
testWithoutContext('PlistParser.getValueFromFile returns null for non-existent key within plist', () {
|
||||||
file.writeAsBytesSync(base64.decode(base64PlistXml));
|
file.writeAsBytesSync(base64.decode(base64PlistXml));
|
||||||
@ -106,7 +100,7 @@ void main() {
|
|||||||
expect(parser.getValueFromFile(file.absolute.path, 'BadKey'), null);
|
expect(parser.getValueFromFile(file.absolute.path, 'BadKey'), null);
|
||||||
expect(logger.statusText, isEmpty);
|
expect(logger.statusText, isEmpty);
|
||||||
expect(logger.errorText, isEmpty);
|
expect(logger.errorText, isEmpty);
|
||||||
}, skip: !io.Platform.isMacOS);
|
}, skip: !platform.isMacOS);
|
||||||
|
|
||||||
testWithoutContext('PlistParser.getValueFromFile returns null for malformed plist file', () {
|
testWithoutContext('PlistParser.getValueFromFile returns null for malformed plist file', () {
|
||||||
file.writeAsBytesSync(const <int>[1, 2, 3, 4, 5, 6]);
|
file.writeAsBytesSync(const <int>[1, 2, 3, 4, 5, 6]);
|
||||||
@ -114,7 +108,7 @@ void main() {
|
|||||||
expect(parser.getValueFromFile(file.path, 'CFBundleIdentifier'), null);
|
expect(parser.getValueFromFile(file.path, 'CFBundleIdentifier'), null);
|
||||||
expect(logger.statusText, isNotEmpty);
|
expect(logger.statusText, isNotEmpty);
|
||||||
expect(logger.errorText, isEmpty);
|
expect(logger.errorText, isEmpty);
|
||||||
}, skip: !io.Platform.isMacOS);
|
}, skip: !platform.isMacOS);
|
||||||
|
|
||||||
testWithoutContext('PlistParser.getValueFromFile throws when /usr/bin/plutil is not found', () async {
|
testWithoutContext('PlistParser.getValueFromFile throws when /usr/bin/plutil is not found', () async {
|
||||||
expect(
|
expect(
|
||||||
@ -123,5 +117,5 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(logger.statusText, isEmpty);
|
expect(logger.statusText, isEmpty);
|
||||||
expect(logger.errorText, isEmpty);
|
expect(logger.errorText, isEmpty);
|
||||||
}, skip: io.Platform.isMacOS);
|
}, skip: platform.isMacOS);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import 'test_data/stateless_stateful_project.dart';
|
import 'test_data/stateless_stateful_project.dart';
|
||||||
@ -30,7 +29,7 @@ void main() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Can switch between stateless and stateful', () async {
|
testWithoutContext('Can switch between stateless and stateful', () async {
|
||||||
await _flutter.run();
|
await _flutter.run();
|
||||||
await _flutter.hotReload();
|
await _flutter.hotReload();
|
||||||
final StringBuffer stdout = StringBuffer();
|
final StringBuffer stdout = StringBuffer();
|
||||||
|
@ -2,26 +2,25 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:io'; // ignore: dart_io_import
|
import 'package:file/file.dart';
|
||||||
|
|
||||||
import 'package:path/path.dart' as path; // ignore: package_path_import
|
|
||||||
import 'package:flutter_tools/src/convert.dart';
|
import 'package:flutter_tools/src/convert.dart';
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
/// Checks that all active template files are defined in the template_manifest.json file.
|
/// Checks that all active template files are defined in the template_manifest.json file.
|
||||||
void main() {
|
void main() {
|
||||||
test('Check template manifest is up to date', () {
|
testWithoutContext('Check template manifest is up to date', () {
|
||||||
final Map<String, Object> manifest = json.decode(
|
final Map<String, Object> manifest = json.decode(
|
||||||
File('templates/template_manifest.json').readAsStringSync(),
|
fileSystem.file('templates/template_manifest.json').readAsStringSync(),
|
||||||
) as Map<String, Object>;
|
) as Map<String, Object>;
|
||||||
final Set<Uri> declaredFileList = Set<Uri>.from(
|
final Set<Uri> declaredFileList = Set<Uri>.from(
|
||||||
(manifest['files'] as List<Object>).cast<String>().map<Uri>(path.toUri));
|
(manifest['files'] as List<Object>).cast<String>().map<Uri>(fileSystem.path.toUri));
|
||||||
|
|
||||||
final Set<Uri> activeTemplateList = Directory('templates')
|
final Set<Uri> activeTemplateList = fileSystem.directory('templates')
|
||||||
.listSync(recursive: true)
|
.listSync(recursive: true)
|
||||||
.whereType<File>()
|
.whereType<File>()
|
||||||
.where((File file) => path.basename(file.path) != 'template_manifest.json' &&
|
.where((File file) => fileSystem.path.basename(file.path) != 'template_manifest.json' &&
|
||||||
path.basename(file.path) != '.DS_Store')
|
fileSystem.path.basename(file.path) != '.DS_Store')
|
||||||
.map((File file) => file.uri)
|
.map((File file) => file.uri)
|
||||||
.toSet();
|
.toSet();
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
|
|
||||||
import '../test_utils.dart';
|
import '../test_utils.dart';
|
||||||
import 'project.dart';
|
import 'project.dart';
|
||||||
|
|
||||||
@ -53,7 +51,7 @@ class BackgroundProject extends Project {
|
|||||||
|
|
||||||
void updateTestIsolatePhrase(String message) {
|
void updateTestIsolatePhrase(String message) {
|
||||||
final String newMainContents = main.replaceFirst('Isolate thread', message);
|
final String newMainContents = main.replaceFirst('Isolate thread', message);
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +101,6 @@ class RepeatingBackgroundProject extends Project {
|
|||||||
|
|
||||||
void updateTestIsolatePhrase(String message) {
|
void updateTestIsolatePhrase(String message) {
|
||||||
final String newMainContents = main.replaceFirst('Isolate thread', message);
|
final String newMainContents = main.replaceFirst('Isolate thread', message);
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
import '../test_utils.dart';
|
import '../test_utils.dart';
|
||||||
@ -19,16 +17,16 @@ class GenL10nProject extends Project {
|
|||||||
bool useSyntheticPackage = false,
|
bool useSyntheticPackage = false,
|
||||||
}) {
|
}) {
|
||||||
this.dir = dir;
|
this.dir = dir;
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_en.arb'), appEn);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'l10n', 'app_en.arb'), appEn);
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_en_CA.arb'), appEnCa);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'l10n', 'app_en_CA.arb'), appEnCa);
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_en_GB.arb'), appEnGb);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'l10n', 'app_en_GB.arb'), appEnGb);
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_es.arb'), appEs);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'l10n', 'app_es.arb'), appEs);
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_es_419.arb'), appEs419);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'l10n', 'app_es_419.arb'), appEs419);
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_zh.arb'), appZh);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'l10n', 'app_zh.arb'), appZh);
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_zh_Hant.arb'), appZhHant);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'l10n', 'app_zh_Hant.arb'), appZhHant);
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_zh_Hans.arb'), appZhHans);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'l10n', 'app_zh_Hans.arb'), appZhHans);
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'l10n', 'app_zh_Hant_TW.arb'), appZhHantTw);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'l10n', 'app_zh_Hant_TW.arb'), appZhHantTw);
|
||||||
writeFile(globals.fs.path.join(dir.path, 'l10n.yaml'), l10nYaml(
|
writeFile(fileSystem.path.join(dir.path, 'l10n.yaml'), l10nYaml(
|
||||||
useDeferredLoading: useDeferredLoading,
|
useDeferredLoading: useDeferredLoading,
|
||||||
useSyntheticPackage: useSyntheticPackage,
|
useSyntheticPackage: useSyntheticPackage,
|
||||||
));
|
));
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
|
|
||||||
import '../test_utils.dart';
|
import '../test_utils.dart';
|
||||||
import 'project.dart';
|
import 'project.dart';
|
||||||
|
|
||||||
@ -86,6 +84,6 @@ class HotReloadProject extends Project {
|
|||||||
'// printHotReloadWorked();',
|
'// printHotReloadWorked();',
|
||||||
'printHotReloadWorked();',
|
'printHotReloadWorked();',
|
||||||
);
|
);
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'main.dart'), newMainContents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
|
|
||||||
import '../test_utils.dart';
|
import '../test_utils.dart';
|
||||||
|
|
||||||
@ -33,17 +31,17 @@ abstract class Project {
|
|||||||
|
|
||||||
Future<void> setUpIn(Directory dir) async {
|
Future<void> setUpIn(Directory dir) async {
|
||||||
this.dir = dir;
|
this.dir = dir;
|
||||||
writeFile(globals.fs.path.join(dir.path, 'pubspec.yaml'), pubspec);
|
writeFile(fileSystem.path.join(dir.path, 'pubspec.yaml'), pubspec);
|
||||||
if (main != null) {
|
if (main != null) {
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'main.dart'), main);
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'main.dart'), main);
|
||||||
}
|
}
|
||||||
if (test != null) {
|
if (test != null) {
|
||||||
writeFile(globals.fs.path.join(dir.path, 'test', 'test.dart'), test);
|
writeFile(fileSystem.path.join(dir.path, 'test', 'test.dart'), test);
|
||||||
}
|
}
|
||||||
if (generatedFile != null) {
|
if (generatedFile != null) {
|
||||||
writeFile(globals.fs.path.join(dir.path, '.dart_tool', 'flutter_gen', 'flutter_gen.dart'), generatedFile);
|
writeFile(fileSystem.path.join(dir.path, '.dart_tool', 'flutter_gen', 'flutter_gen.dart'), generatedFile);
|
||||||
}
|
}
|
||||||
writeFile(globals.fs.path.join(dir.path, 'web', 'index.html'), _kDefaultHtml);
|
writeFile(fileSystem.path.join(dir.path, 'web', 'index.html'), _kDefaultHtml);
|
||||||
writePackages(dir.path);
|
writePackages(dir.path);
|
||||||
await getPackages(dir.path);
|
await getPackages(dir.path);
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
|
|
||||||
import '../test_utils.dart';
|
import '../test_utils.dart';
|
||||||
import 'project.dart';
|
import 'project.dart';
|
||||||
|
|
||||||
@ -74,6 +72,6 @@ class HotReloadProject extends Project {
|
|||||||
|
|
||||||
void toggleState() {
|
void toggleState() {
|
||||||
stateful = !stateful;
|
stateful = !stateful;
|
||||||
writeFile(globals.fs.path.join(dir.path, 'lib', 'main.dart'), getCode(stateful));
|
writeFile(fileSystem.path.join(dir.path, 'lib', 'main.dart'), getCode(stateful));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
|
|
||||||
import '../test_utils.dart';
|
import '../test_utils.dart';
|
||||||
import 'project.dart';
|
import 'project.dart';
|
||||||
@ -46,7 +45,7 @@ class TestsProject extends Project {
|
|||||||
return super.setUpIn(dir);
|
return super.setUpIn(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
String get testFilePath => globals.fs.path.join(dir.path, 'test', 'test.dart');
|
String get testFilePath => fileSystem.path.join(dir.path, 'test', 'test.dart');
|
||||||
|
|
||||||
Uri get breakpointUri => Uri.file(testFilePath);
|
Uri get breakpointUri => Uri.file(testFilePath);
|
||||||
Uri get breakpointAppUri => Uri.parse('org-dartlang-app:///test.dart');
|
Uri get breakpointAppUri => Uri.parse('org-dartlang-app:///test.dart');
|
||||||
|
@ -4,19 +4,20 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:io' as io; // ignore: dart_io_import
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/common.dart';
|
import 'package:flutter_tools/src/base/common.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
import 'package:flutter_tools/src/base/utils.dart';
|
import 'package:flutter_tools/src/base/utils.dart';
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
import 'package:process/process.dart';
|
import 'package:process/process.dart';
|
||||||
import 'package:vm_service/vm_service.dart';
|
import 'package:vm_service/vm_service.dart';
|
||||||
import 'package:vm_service/vm_service_io.dart';
|
import 'package:vm_service/vm_service_io.dart';
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
|
import 'test_utils.dart';
|
||||||
|
|
||||||
// Set this to true for debugging to get verbose logs written to stdout.
|
// Set this to true for debugging to get verbose logs written to stdout.
|
||||||
// The logs include the following:
|
// The logs include the following:
|
||||||
@ -84,7 +85,7 @@ abstract class FlutterTestDriver {
|
|||||||
bool withDebugger = false,
|
bool withDebugger = false,
|
||||||
File pidFile,
|
File pidFile,
|
||||||
}) async {
|
}) async {
|
||||||
final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter');
|
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||||
if (withDebugger) {
|
if (withDebugger) {
|
||||||
arguments.add('--start-paused');
|
arguments.add('--start-paused');
|
||||||
}
|
}
|
||||||
@ -175,7 +176,7 @@ abstract class FlutterTestDriver {
|
|||||||
.catchError((Object e) => _debugPrint('Ignoring failure to resume during shutdown'));
|
.catchError((Object e) => _debugPrint('Ignoring failure to resume during shutdown'));
|
||||||
|
|
||||||
_debugPrint('Sending SIGTERM to $_processPid..');
|
_debugPrint('Sending SIGTERM to $_processPid..');
|
||||||
ProcessSignal.SIGTERM.send(_processPid);
|
io.Process.killPid(_processPid, io.ProcessSignal.sigterm);
|
||||||
return _process.exitCode.timeout(quitTimeout, onTimeout: _killForcefully);
|
return _process.exitCode.timeout(quitTimeout, onTimeout: _killForcefully);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,36 +4,47 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:file/file.dart';
|
||||||
|
import 'package:file/local.dart';
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
import 'package:flutter_tools/src/base/platform.dart';
|
||||||
|
import 'package:process/process.dart';
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
|
|
||||||
|
/// The [FileSystem] for the integration test environment.
|
||||||
|
const FileSystem fileSystem = LocalFileSystem();
|
||||||
|
|
||||||
|
/// The [Platform] for the integration test environment.
|
||||||
|
const Platform platform = LocalPlatform();
|
||||||
|
|
||||||
|
/// The [ProcessManager] for the integration test environment.
|
||||||
|
const ProcessManager processManager = LocalProcessManager();
|
||||||
|
|
||||||
/// Creates a temporary directory but resolves any symlinks to return the real
|
/// Creates a temporary directory but resolves any symlinks to return the real
|
||||||
/// underlying path to avoid issues with breakpoints/hot reload.
|
/// underlying path to avoid issues with breakpoints/hot reload.
|
||||||
/// https://github.com/flutter/flutter/pull/21741
|
/// https://github.com/flutter/flutter/pull/21741
|
||||||
Directory createResolvedTempDirectorySync(String prefix) {
|
Directory createResolvedTempDirectorySync(String prefix) {
|
||||||
assert(prefix.endsWith('.'));
|
assert(prefix.endsWith('.'));
|
||||||
final Directory tempDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_$prefix');
|
final Directory tempDirectory = fileSystem.systemTempDirectory.createTempSync('flutter_$prefix');
|
||||||
return globals.fs.directory(tempDirectory.resolveSymbolicLinksSync());
|
return fileSystem.directory(tempDirectory.resolveSymbolicLinksSync());
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeFile(String path, String content) {
|
void writeFile(String path, String content) {
|
||||||
globals.fs.file(path)
|
fileSystem.file(path)
|
||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsStringSync(content)
|
..writeAsStringSync(content)
|
||||||
..setLastModifiedSync(DateTime.now().add(const Duration(seconds: 10)));
|
..setLastModifiedSync(DateTime.now().add(const Duration(seconds: 10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void writePackages(String folder) {
|
void writePackages(String folder) {
|
||||||
writeFile(globals.fs.path.join(folder, '.packages'), '''
|
writeFile(fileSystem.path.join(folder, '.packages'), '''
|
||||||
test:${globals.fs.path.join(globals.fs.currentDirectory.path, 'lib')}/
|
test:${fileSystem.path.join(fileSystem.currentDirectory.path, 'lib')}/
|
||||||
''');
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
void writePubspec(String folder) {
|
void writePubspec(String folder) {
|
||||||
writeFile(globals.fs.path.join(folder, 'pubspec.yaml'), '''
|
writeFile(fileSystem.path.join(folder, 'pubspec.yaml'), '''
|
||||||
name: test
|
name: test
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
@ -43,11 +54,11 @@ dependencies:
|
|||||||
|
|
||||||
Future<void> getPackages(String folder) async {
|
Future<void> getPackages(String folder) async {
|
||||||
final List<String> command = <String>[
|
final List<String> command = <String>[
|
||||||
globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter'),
|
fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'),
|
||||||
'pub',
|
'pub',
|
||||||
'get',
|
'get',
|
||||||
];
|
];
|
||||||
final ProcessResult result = await globals.processManager.run(command, workingDirectory: folder);
|
final ProcessResult result = await processManager.run(command, workingDirectory: folder);
|
||||||
if (result.exitCode != 0) {
|
if (result.exitCode != 0) {
|
||||||
throw Exception('flutter pub get failed: ${result.stderr}\n${result.stdout}');
|
throw Exception('flutter pub get failed: ${result.stderr}\n${result.stdout}');
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
import 'package:flutter_tools/src/base/io.dart';
|
import 'package:flutter_tools/src/base/io.dart';
|
||||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
|
||||||
import 'package:process/process.dart';
|
import 'package:process/process.dart';
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
@ -21,7 +20,7 @@ void main() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Can parse and output summaries for code coverage', () async {
|
testWithoutContext('Can parse and output summaries for code coverage', () async {
|
||||||
final File coverageFile = tempDir.childFile('info.lcov')
|
final File coverageFile = tempDir.childFile('info.lcov')
|
||||||
..writeAsStringSync('''
|
..writeAsStringSync('''
|
||||||
SF:lib/src/artifacts.dart
|
SF:lib/src/artifacts.dart
|
||||||
@ -51,8 +50,8 @@ LH:6
|
|||||||
end_of_record
|
end_of_record
|
||||||
''');
|
''');
|
||||||
|
|
||||||
final String dartScript = globals.fs.path.join(getFlutterRoot(), 'bin', 'dart');
|
final String dartScript = fileSystem.path.join(getFlutterRoot(), 'bin', 'dart');
|
||||||
final String coverageScript = globals.fs.path.join(getFlutterRoot(), 'packages', 'flutter_tools', 'tool', 'unit_coverage.dart');
|
final String coverageScript = fileSystem.path.join(getFlutterRoot(), 'packages', 'flutter_tools', 'tool', 'unit_coverage.dart');
|
||||||
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
final ProcessResult result = await const LocalProcessManager().run(<String>[
|
||||||
dartScript,
|
dartScript,
|
||||||
coverageScript,
|
coverageScript,
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io'; // ignore: dart_io_import
|
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:flutter_tools/src/base/dds.dart';
|
import 'package:flutter_tools/src/base/dds.dart';
|
||||||
@ -40,7 +39,7 @@ void main() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getSupportedProtocols includes DDS', () async {
|
testWithoutContext('getSupportedProtocols includes DDS', () async {
|
||||||
final ProtocolList protocolList =
|
final ProtocolList protocolList =
|
||||||
await vmService.getSupportedProtocols();
|
await vmService.getSupportedProtocols();
|
||||||
expect(protocolList.protocols, hasLength(2));
|
expect(protocolList.protocols, hasLength(2));
|
||||||
@ -49,7 +48,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
}, skip: DartDevelopmentService.ddsDisabled);
|
}, skip: DartDevelopmentService.ddsDisabled);
|
||||||
|
|
||||||
test('flutterVersion can be called', () async {
|
testWithoutContext('flutterVersion can be called', () async {
|
||||||
final Response response =
|
final Response response =
|
||||||
await vmService.callServiceExtension('s0.flutterVersion');
|
await vmService.callServiceExtension('s0.flutterVersion');
|
||||||
expect(response.type, 'Success');
|
expect(response.type, 'Success');
|
||||||
@ -57,13 +56,13 @@ void main() {
|
|||||||
expect(response.json, containsPair('engineRevisionShort', isNotNull));
|
expect(response.json, containsPair('engineRevisionShort', isNotNull));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutterMemoryInfo can be called', () async {
|
testWithoutContext('flutterMemoryInfo can be called', () async {
|
||||||
final Response response =
|
final Response response =
|
||||||
await vmService.callServiceExtension('s0.flutterMemoryInfo');
|
await vmService.callServiceExtension('s0.flutterMemoryInfo');
|
||||||
expect(response.type, 'Success');
|
expect(response.type, 'Success');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('reloadSources can be called', () async {
|
testWithoutContext('reloadSources can be called', () async {
|
||||||
final VM vm = await vmService.getVM();
|
final VM vm = await vmService.getVM();
|
||||||
final IsolateRef isolateRef = vm.isolates.first;
|
final IsolateRef isolateRef = vm.isolates.first;
|
||||||
|
|
||||||
@ -72,13 +71,13 @@ void main() {
|
|||||||
expect(response.type, 'Success');
|
expect(response.type, 'Success');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('reloadSources fails on bad params', () async {
|
testWithoutContext('reloadSources fails on bad params', () async {
|
||||||
final Future<Response> response =
|
final Future<Response> response =
|
||||||
vmService.callMethod('s0.reloadSources', isolateId: '');
|
vmService.callMethod('s0.reloadSources', isolateId: '');
|
||||||
expect(response, throwsA(const TypeMatcher<RPCError>()));
|
expect(response, throwsA(const TypeMatcher<RPCError>()));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('hotRestart can be called', () async {
|
testWithoutContext('hotRestart can be called', () async {
|
||||||
final VM vm = await vmService.getVM();
|
final VM vm = await vmService.getVM();
|
||||||
final IsolateRef isolateRef = vm.isolates.first;
|
final IsolateRef isolateRef = vm.isolates.first;
|
||||||
|
|
||||||
@ -87,19 +86,19 @@ void main() {
|
|||||||
expect(response.type, 'Success');
|
expect(response.type, 'Success');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('hotRestart fails on bad params', () async {
|
testWithoutContext('hotRestart fails on bad params', () async {
|
||||||
final Future<Response> response = vmService.callMethod('s0.hotRestart',
|
final Future<Response> response = vmService.callMethod('s0.hotRestart',
|
||||||
args: <String, dynamic>{'pause': 'not_a_bool'});
|
args: <String, dynamic>{'pause': 'not_a_bool'});
|
||||||
expect(response, throwsA(const TypeMatcher<RPCError>()));
|
expect(response, throwsA(const TypeMatcher<RPCError>()));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutterGetSkSL can be called', () async {
|
testWithoutContext('flutterGetSkSL can be called', () async {
|
||||||
final Response response = await vmService.callMethod('s0.flutterGetSkSL');
|
final Response response = await vmService.callMethod('s0.flutterGetSkSL');
|
||||||
|
|
||||||
expect(response.type, 'Success');
|
expect(response.type, 'Success');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('ext.flutter.brightnessOverride can toggle window brightness', () async {
|
testWithoutContext('ext.flutter.brightnessOverride can toggle window brightness', () async {
|
||||||
final Isolate isolate = await waitForExtension(vmService);
|
final Isolate isolate = await waitForExtension(vmService);
|
||||||
final Response response = await vmService.callServiceExtension(
|
final Response response = await vmService.callServiceExtension(
|
||||||
'ext.flutter.brightnessOverride',
|
'ext.flutter.brightnessOverride',
|
||||||
@ -138,5 +137,5 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// TODO(devoncarew): These tests fail on cirrus-ci windows.
|
// TODO(devoncarew): These tests fail on cirrus-ci windows.
|
||||||
}, skip: Platform.isWindows);
|
}, skip: platform.isWindows);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ void main() {
|
|||||||
tryToDelete(tempDir);
|
tryToDelete(tempDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('flutter run works on web devices with a unary main function', () async {
|
testWithoutContext('flutter run works on web devices with a unary main function', () async {
|
||||||
await flutter.run(chrome: true);
|
await flutter.run(chrome: true);
|
||||||
}, skip: 'Web CI skipped');
|
}, skip: 'Web CI skipped');
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,10 @@ import 'dart:async';
|
|||||||
import 'package:args/args.dart';
|
import 'package:args/args.dart';
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:flutter_tools/src/base/logger.dart';
|
import 'package:flutter_tools/src/base/logger.dart';
|
||||||
|
import 'package:flutter_tools/src/base/platform.dart';
|
||||||
import 'package:flutter_tools/src/convert.dart';
|
import 'package:flutter_tools/src/convert.dart';
|
||||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||||
|
import 'package:path/path.dart' as path; // ignore: package_path_import
|
||||||
|
|
||||||
import 'package:flutter_tools/src/base/common.dart';
|
import 'package:flutter_tools/src/base/common.dart';
|
||||||
import 'package:flutter_tools/src/base/context.dart';
|
import 'package:flutter_tools/src/base/context.dart';
|
||||||
@ -48,8 +50,9 @@ void tryToDelete(Directory directory) {
|
|||||||
/// environment variable is set, it will be returned. Otherwise, this will
|
/// environment variable is set, it will be returned. Otherwise, this will
|
||||||
/// deduce the path from `platform.script`.
|
/// deduce the path from `platform.script`.
|
||||||
String getFlutterRoot() {
|
String getFlutterRoot() {
|
||||||
if (globals.platform.environment.containsKey('FLUTTER_ROOT')) {
|
const Platform platform = LocalPlatform();
|
||||||
return globals.platform.environment['FLUTTER_ROOT'];
|
if (platform.environment.containsKey('FLUTTER_ROOT')) {
|
||||||
|
return platform.environment['FLUTTER_ROOT'];
|
||||||
}
|
}
|
||||||
|
|
||||||
Error invalidScript() => StateError('Could not determine flutter_tools/ path from script URL (${globals.platform.script}); consider setting FLUTTER_ROOT explicitly.');
|
Error invalidScript() => StateError('Could not determine flutter_tools/ path from script URL (${globals.platform.script}); consider setting FLUTTER_ROOT explicitly.');
|
||||||
@ -71,13 +74,13 @@ String getFlutterRoot() {
|
|||||||
throw invalidScript();
|
throw invalidScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<String> parts = globals.fs.path.split(globals.fs.path.fromUri(scriptUri));
|
final List<String> parts = path.split(globals.fs.path.fromUri(scriptUri));
|
||||||
final int toolsIndex = parts.indexOf('flutter_tools');
|
final int toolsIndex = parts.indexOf('flutter_tools');
|
||||||
if (toolsIndex == -1) {
|
if (toolsIndex == -1) {
|
||||||
throw invalidScript();
|
throw invalidScript();
|
||||||
}
|
}
|
||||||
final String toolsPath = globals.fs.path.joinAll(parts.sublist(0, toolsIndex + 1));
|
final String toolsPath = path.joinAll(parts.sublist(0, toolsIndex + 1));
|
||||||
return globals.fs.path.normalize(globals.fs.path.join(toolsPath, '..', '..'));
|
return path.normalize(path.join(toolsPath, '..', '..'));
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandRunner<void> createTestCommandRunner([ FlutterCommand command ]) {
|
CommandRunner<void> createTestCommandRunner([ FlutterCommand command ]) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user