Move gradle_non_android_plugin_test from its own test builders into tools integration.shard (#80161)
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
// Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
Directory tempDir;
|
||||
|
||||
setUp(() {
|
||||
tempDir = createResolvedTempDirectorySync('flutter_plugin_test.');
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
testUsingContext('flutter app that depends on a non-Android plugin can still build for Android', () {
|
||||
final String flutterRoot = getFlutterRoot();
|
||||
final String flutterBin = fileSystem.path.join(
|
||||
flutterRoot,
|
||||
'bin',
|
||||
'flutter',
|
||||
);
|
||||
processManager.runSync(<String>[
|
||||
flutterBin,
|
||||
...getLocalEngineArguments(),
|
||||
'create',
|
||||
'-t',
|
||||
'plugin',
|
||||
'--platforms=ios,android',
|
||||
'ios_only',
|
||||
], workingDirectory: tempDir.path);
|
||||
|
||||
// Delete plugin's Android folder
|
||||
final Directory projectRoot = tempDir.childDirectory('ios_only');
|
||||
projectRoot.childDirectory('android').deleteSync(recursive: true);
|
||||
|
||||
// Update pubspec.yaml to iOS only plugin
|
||||
final File pubspecFile = projectRoot.childFile('pubspec.yaml');
|
||||
final String pubspecString = pubspecFile.readAsStringSync();
|
||||
|
||||
final StringBuffer iosOnlyPubspec = StringBuffer();
|
||||
bool inAndroidSection = false;
|
||||
const String pluginPlatformIndentation = ' ';
|
||||
for (final String line in pubspecString.split('\n')) {
|
||||
// Skip everything in the Android section of the plugin platforms list.
|
||||
if (line.startsWith('${pluginPlatformIndentation}android:')) {
|
||||
inAndroidSection = true;
|
||||
continue;
|
||||
}
|
||||
if (inAndroidSection) {
|
||||
if (line.startsWith('$pluginPlatformIndentation ')) {
|
||||
continue;
|
||||
} else {
|
||||
inAndroidSection = false;
|
||||
}
|
||||
}
|
||||
iosOnlyPubspec.write('$line\n');
|
||||
}
|
||||
|
||||
pubspecFile.writeAsStringSync(iosOnlyPubspec.toString());
|
||||
|
||||
// Build example APK
|
||||
final Directory exampleDir = projectRoot.childDirectory('example');
|
||||
|
||||
processManager.runSync(<String>[
|
||||
flutterBin,
|
||||
...getLocalEngineArguments(),
|
||||
'build',
|
||||
'apk',
|
||||
'--target-platform',
|
||||
'android-arm',
|
||||
'--verbose',
|
||||
], workingDirectory: exampleDir.path);
|
||||
|
||||
final String exampleAppApk = fileSystem.path.join(
|
||||
exampleDir.path,
|
||||
'build',
|
||||
'app',
|
||||
'outputs',
|
||||
'apk',
|
||||
'release',
|
||||
'app-release.apk',
|
||||
);
|
||||
expect(fileSystem.file(exampleAppApk), exists);
|
||||
}, timeout: const Timeout(Duration(minutes: 5)));
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
final String toolBackend = fileSystem.path.join(getFlutterRoot(), 'packages', 'flutter_tools', 'bin', 'tool_backend.dart');
|
||||
@@ -14,7 +15,7 @@ final String examplePath = fileSystem.path.join(getFlutterRoot(), 'examples', 'h
|
||||
final String dart = fileSystem.path.join(getFlutterRoot(), 'bin', platform.isWindows ? 'dart.bat' : 'dart');
|
||||
|
||||
void main() {
|
||||
testWithoutContext('tool_backend.dart exits if PROJECT_DIR is not set', () async {
|
||||
testUsingContext('tool_backend.dart exits if PROJECT_DIR is not set', () async {
|
||||
final ProcessResult result = await processManager.run(<String>[
|
||||
dart,
|
||||
toolBackend,
|
||||
@@ -23,10 +24,10 @@ void main() {
|
||||
]);
|
||||
|
||||
expect(result.exitCode, 1);
|
||||
expect(result.stderr, 'PROJECT_DIR environment variable must be set to the location of Flutter project to be built.');
|
||||
expect(result.stderr, contains('PROJECT_DIR environment variable must be set to the location of Flutter project to be built.'));
|
||||
});
|
||||
|
||||
testWithoutContext('tool_backend.dart exits if FLUTTER_ROOT is not set', () async {
|
||||
testUsingContext('tool_backend.dart exits if FLUTTER_ROOT is not set', () async {
|
||||
// Removing parent environment means that batch script cannot be run.
|
||||
final String dart = fileSystem.path.join(getFlutterRoot(), 'bin', 'cache', 'dart-sdk', 'bin', platform.isWindows ? 'dart.exe' : 'dart');
|
||||
|
||||
@@ -40,10 +41,10 @@ void main() {
|
||||
}, includeParentEnvironment: false); // Prevent FLUTTER_ROOT set by test environment from leaking
|
||||
|
||||
expect(result.exitCode, 1);
|
||||
expect(result.stderr, 'FLUTTER_ROOT environment variable must be set to the location of the Flutter SDK.');
|
||||
expect(result.stderr, contains('FLUTTER_ROOT environment variable must be set to the location of the Flutter SDK.'));
|
||||
});
|
||||
|
||||
testWithoutContext('tool_backend.dart exits if local engine does not match build mode', () async {
|
||||
testUsingContext('tool_backend.dart exits if local engine does not match build mode', () async {
|
||||
final ProcessResult result = await processManager.run(<String>[
|
||||
dart,
|
||||
toolBackend,
|
||||
|
||||
Reference in New Issue
Block a user