Use flutter pub get instead of dart pub get in create_api_docs.dart (#133493)
This commit is contained in:
parent
e8df434956
commit
5bd8579bc8
@ -77,7 +77,7 @@ Future<void> main(List<String> arguments) async {
|
|||||||
configurator.generateConfiguration();
|
configurator.generateConfiguration();
|
||||||
|
|
||||||
final PlatformDocGenerator platformGenerator = PlatformDocGenerator(outputDir: publishRoot, filesystem: filesystem);
|
final PlatformDocGenerator platformGenerator = PlatformDocGenerator(outputDir: publishRoot, filesystem: filesystem);
|
||||||
platformGenerator.generatePlatformDocs();
|
await platformGenerator.generatePlatformDocs();
|
||||||
|
|
||||||
final DartdocGenerator dartdocGenerator = DartdocGenerator(
|
final DartdocGenerator dartdocGenerator = DartdocGenerator(
|
||||||
publishRoot: publishRoot,
|
publishRoot: publishRoot,
|
||||||
@ -465,7 +465,7 @@ class DartdocGenerator {
|
|||||||
|
|
||||||
// Verify which version of snippets and dartdoc we're using.
|
// Verify which version of snippets and dartdoc we're using.
|
||||||
final ProcessResult snippetsResult = Process.runSync(
|
final ProcessResult snippetsResult = Process.runSync(
|
||||||
FlutterInformation.instance.getDartBinaryPath().path,
|
FlutterInformation.instance.getFlutterBinaryPath().path,
|
||||||
<String>[
|
<String>[
|
||||||
'pub',
|
'pub',
|
||||||
'global',
|
'global',
|
||||||
@ -779,16 +779,16 @@ class PlatformDocGenerator {
|
|||||||
|
|
||||||
/// This downloads an archive of platform docs for the engine from the artifact
|
/// This downloads an archive of platform docs for the engine from the artifact
|
||||||
/// store and extracts them to the location used for Dartdoc.
|
/// store and extracts them to the location used for Dartdoc.
|
||||||
void generatePlatformDocs() {
|
Future<void> generatePlatformDocs() async {
|
||||||
final String realm = engineRealm.isNotEmpty ? '$engineRealm/' : '';
|
final String realm = engineRealm.isNotEmpty ? '$engineRealm/' : '';
|
||||||
|
|
||||||
final String javadocUrl =
|
final String javadocUrl =
|
||||||
'https://storage.googleapis.com/${realm}flutter_infra_release/flutter/$engineRevision/android-javadoc.zip';
|
'https://storage.googleapis.com/${realm}flutter_infra_release/flutter/$engineRevision/android-javadoc.zip';
|
||||||
_extractDocs(javadocUrl, 'javadoc', 'io/flutter/view/FlutterView.html', outputDir);
|
await _extractDocs(javadocUrl, 'javadoc', 'io/flutter/view/FlutterView.html', outputDir);
|
||||||
|
|
||||||
final String objcdocUrl =
|
final String objcdocUrl =
|
||||||
'https://storage.googleapis.com/${realm}flutter_infra_release/flutter/$engineRevision/ios-objcdoc.zip';
|
'https://storage.googleapis.com/${realm}flutter_infra_release/flutter/$engineRevision/ios-objcdoc.zip';
|
||||||
_extractDocs(objcdocUrl, 'objcdoc', 'Classes/FlutterViewController.html', outputDir);
|
await _extractDocs(objcdocUrl, 'objcdoc', 'Classes/FlutterViewController.html', outputDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fetches the zip archive at the specified url.
|
/// Fetches the zip archive at the specified url.
|
||||||
@ -935,7 +935,7 @@ Future<Process> runPubProcess({
|
|||||||
@visibleForTesting FileSystem filesystem = const LocalFileSystem(),
|
@visibleForTesting FileSystem filesystem = const LocalFileSystem(),
|
||||||
}) {
|
}) {
|
||||||
return processManager.start(
|
return processManager.start(
|
||||||
<Object>[FlutterInformation.instance.getDartBinaryPath().path, 'pub', ...arguments],
|
<Object>[FlutterInformation.instance.getFlutterBinaryPath().path, 'pub', ...arguments],
|
||||||
workingDirectory: (workingDirectory ?? filesystem.currentDirectory).path,
|
workingDirectory: (workingDirectory ?? filesystem.currentDirectory).path,
|
||||||
environment: environment,
|
environment: environment,
|
||||||
);
|
);
|
||||||
@ -968,21 +968,13 @@ List<Directory> findPackages(FileSystem filesystem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An exception class used to indicate problems when collecting information.
|
/// An exception class used to indicate problems when collecting information.
|
||||||
class DartdocException implements Exception {
|
class FlutterInformationException implements Exception {
|
||||||
DartdocException(this.message, {this.file, this.line});
|
FlutterInformationException(this.message);
|
||||||
final String message;
|
final String message;
|
||||||
final String? file;
|
|
||||||
final int? line;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
if (file != null || line != null) {
|
return '$runtimeType: $message';
|
||||||
final String fileStr = file == null ? '' : '$file:';
|
|
||||||
final String lineStr = line == null ? '' : '$line:';
|
|
||||||
return '$runtimeType: $fileStr$lineStr: $message';
|
|
||||||
} else {
|
|
||||||
return '$runtimeType: $message';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1017,6 +1009,13 @@ class FlutterInformation {
|
|||||||
return getFlutterRoot().childDirectory('bin').childFile('dart');
|
return getFlutterRoot().childDirectory('bin').childFile('dart');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The path to the Dart binary in the Flutter repo.
|
||||||
|
///
|
||||||
|
/// This is probably a shell script.
|
||||||
|
File getFlutterBinaryPath() {
|
||||||
|
return getFlutterRoot().childDirectory('bin').childFile('flutter');
|
||||||
|
}
|
||||||
|
|
||||||
/// The path to the Flutter repo root directory.
|
/// The path to the Flutter repo root directory.
|
||||||
///
|
///
|
||||||
/// If the environment variable `FLUTTER_ROOT` is set, will use that instead
|
/// If the environment variable `FLUTTER_ROOT` is set, will use that instead
|
||||||
@ -1074,11 +1073,12 @@ class FlutterInformation {
|
|||||||
try {
|
try {
|
||||||
result = processManager.runSync(<String>[flutterCommand, '--version', '--machine'], stdoutEncoding: utf8);
|
result = processManager.runSync(<String>[flutterCommand, '--version', '--machine'], stdoutEncoding: utf8);
|
||||||
} on ProcessException catch (e) {
|
} on ProcessException catch (e) {
|
||||||
throw DartdocException(
|
throw FlutterInformationException(
|
||||||
'Unable to determine Flutter information. Either set FLUTTER_ROOT, or place flutter command in your path.\n$e');
|
'Unable to determine Flutter information. Either set FLUTTER_ROOT, or place flutter command in your path.\n$e');
|
||||||
}
|
}
|
||||||
if (result.exitCode != 0) {
|
if (result.exitCode != 0) {
|
||||||
throw DartdocException('Unable to determine Flutter information, because of abnormal exit to flutter command.');
|
throw FlutterInformationException(
|
||||||
|
'Unable to determine Flutter information, because of abnormal exit to flutter command.');
|
||||||
}
|
}
|
||||||
flutterVersionJson = (result.stdout as String)
|
flutterVersionJson = (result.stdout as String)
|
||||||
.replaceAll('Waiting for another flutter command to release the startup lock...', '');
|
.replaceAll('Waiting for another flutter command to release the startup lock...', '');
|
||||||
@ -1088,7 +1088,7 @@ class FlutterInformation {
|
|||||||
if (flutterVersion['flutterRoot'] == null ||
|
if (flutterVersion['flutterRoot'] == null ||
|
||||||
flutterVersion['frameworkVersion'] == null ||
|
flutterVersion['frameworkVersion'] == null ||
|
||||||
flutterVersion['dartSdkVersion'] == null) {
|
flutterVersion['dartSdkVersion'] == null) {
|
||||||
throw DartdocException(
|
throw FlutterInformationException(
|
||||||
'Flutter command output has unexpected format, unable to determine flutter root location.');
|
'Flutter command output has unexpected format, unable to determine flutter root location.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1097,14 +1097,13 @@ class FlutterInformation {
|
|||||||
info['flutterRoot'] = flutterRoot;
|
info['flutterRoot'] = flutterRoot;
|
||||||
info['frameworkVersion'] = Version.parse(flutterVersion['frameworkVersion'] as String);
|
info['frameworkVersion'] = Version.parse(flutterVersion['frameworkVersion'] as String);
|
||||||
info['engineRevision'] = flutterVersion['engineRevision'] as String;
|
info['engineRevision'] = flutterVersion['engineRevision'] as String;
|
||||||
info['engineRealm'] = filesystem.file(
|
final File engineRealm = flutterRoot.childDirectory('bin').childDirectory('internal').childFile('engine.realm');
|
||||||
path.join(flutterRoot.path, 'bin', 'internal', 'engine.realm',
|
info['engineRealm'] = engineRealm.existsSync() ? engineRealm.readAsStringSync().trim() : '';
|
||||||
)).readAsStringSync().trim();
|
|
||||||
|
|
||||||
final RegExpMatch? dartVersionRegex = RegExp(r'(?<base>[\d.]+)(?:\s+\(build (?<detail>[-.\w]+)\))?')
|
final RegExpMatch? dartVersionRegex = RegExp(r'(?<base>[\d.]+)(?:\s+\(build (?<detail>[-.\w]+)\))?')
|
||||||
.firstMatch(flutterVersion['dartSdkVersion'] as String);
|
.firstMatch(flutterVersion['dartSdkVersion'] as String);
|
||||||
if (dartVersionRegex == null) {
|
if (dartVersionRegex == null) {
|
||||||
throw DartdocException(
|
throw FlutterInformationException(
|
||||||
'Flutter command output has unexpected format, unable to parse dart SDK version ${flutterVersion['dartSdkVersion']}.');
|
'Flutter command output has unexpected format, unable to parse dart SDK version ${flutterVersion['dartSdkVersion']}.');
|
||||||
}
|
}
|
||||||
info['dartSdkVersion'] =
|
info['dartSdkVersion'] =
|
||||||
|
@ -17,21 +17,21 @@ import 'package:path/path.dart' as path;
|
|||||||
import 'package:platform/platform.dart';
|
import 'package:platform/platform.dart';
|
||||||
import 'package:process/process.dart';
|
import 'package:process/process.dart';
|
||||||
|
|
||||||
FileSystem filesystem = const LocalFileSystem();
|
const FileSystem _kFilesystem = LocalFileSystem();
|
||||||
ProcessManager processManager = const LocalProcessManager();
|
const ProcessManager _kProcessManager = LocalProcessManager();
|
||||||
Platform platform = const LocalPlatform();
|
const Platform _kPlatform = LocalPlatform();
|
||||||
|
|
||||||
FutureOr<dynamic> main() async {
|
FutureOr<dynamic> main() async {
|
||||||
if (!platform.isLinux && !platform.isWindows && !platform.isMacOS) {
|
if (!_kPlatform.isLinux && !_kPlatform.isWindows && !_kPlatform.isMacOS) {
|
||||||
stderr.writeln('Example smoke tests are only designed to run on desktop platforms');
|
stderr.writeln('Example smoke tests are only designed to run on desktop platforms');
|
||||||
exitCode = 4;
|
exitCode = 4;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Directory flutterDir = filesystem.directory(
|
final Directory flutterDir = _kFilesystem.directory(
|
||||||
path.absolute(
|
path.absolute(
|
||||||
path.dirname(
|
path.dirname(
|
||||||
path.dirname(
|
path.dirname(
|
||||||
path.dirname(platform.script.toFilePath()),
|
path.dirname(_kPlatform.script.toFilePath()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -63,16 +63,16 @@ Future<void> runSmokeTests({
|
|||||||
required Directory apiDir,
|
required Directory apiDir,
|
||||||
}) async {
|
}) async {
|
||||||
final File flutterExe =
|
final File flutterExe =
|
||||||
flutterDir.childDirectory('bin').childFile(platform.isWindows ? 'flutter.bat' : 'flutter');
|
flutterDir.childDirectory('bin').childFile(_kPlatform.isWindows ? 'flutter.bat' : 'flutter');
|
||||||
final List<String> cmd = <String>[
|
final List<String> cmd = <String>[
|
||||||
// If we're in a container with no X display, then use the virtual framebuffer.
|
// If we're in a container with no X display, then use the virtual framebuffer.
|
||||||
if (platform.isLinux &&
|
if (_kPlatform.isLinux &&
|
||||||
(platform.environment['DISPLAY'] == null ||
|
(_kPlatform.environment['DISPLAY'] == null ||
|
||||||
platform.environment['DISPLAY']!.isEmpty)) '/usr/bin/xvfb-run',
|
_kPlatform.environment['DISPLAY']!.isEmpty)) '/usr/bin/xvfb-run',
|
||||||
flutterExe.absolute.path,
|
flutterExe.absolute.path,
|
||||||
'test',
|
'test',
|
||||||
'--reporter=expanded',
|
'--reporter=expanded',
|
||||||
'--device-id=${platform.operatingSystem}',
|
'--device-id=${_kPlatform.operatingSystem}',
|
||||||
integrationTest.absolute.path,
|
integrationTest.absolute.path,
|
||||||
];
|
];
|
||||||
await runCommand(cmd, workingDirectory: apiDir);
|
await runCommand(cmd, workingDirectory: apiDir);
|
||||||
@ -112,7 +112,7 @@ Future<File> generateTest(Directory apiDir) async {
|
|||||||
.trim()
|
.trim()
|
||||||
.split('\n');
|
.split('\n');
|
||||||
final Iterable<File> examples = gitFiles.map<File>((String examplePath) {
|
final Iterable<File> examples = gitFiles.map<File>((String examplePath) {
|
||||||
return filesystem.file(path.join(examplesLibDir.absolute.path, examplePath));
|
return _kFilesystem.file(path.join(examplesLibDir.absolute.path, examplePath));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Collect the examples, and import them all as separate symbols.
|
// Collect the examples, and import them all as separate symbols.
|
||||||
@ -202,7 +202,7 @@ Future<String> runCommand(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
process = await processManager.start(
|
process = await _kProcessManager.start(
|
||||||
cmd,
|
cmd,
|
||||||
workingDirectory: workingDirectory.absolute.path,
|
workingDirectory: workingDirectory.absolute.path,
|
||||||
environment: environment,
|
environment: environment,
|
||||||
|
@ -4,116 +4,14 @@
|
|||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:path/path.dart' as path;
|
|
||||||
import 'package:platform/platform.dart';
|
import 'package:platform/platform.dart';
|
||||||
import 'package:pub_semver/pub_semver.dart';
|
import 'package:pub_semver/pub_semver.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import '../../../packages/flutter_tools/test/src/fake_process_manager.dart';
|
import '../../../packages/flutter_tools/test/src/fake_process_manager.dart';
|
||||||
import '../create_api_docs.dart' as apidocs;
|
import '../create_api_docs.dart' as apidocs;
|
||||||
import '../examples_smoke_test.dart';
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('getBranchName does not call git if env LUCI_BRANCH provided', () {
|
|
||||||
final Platform platform = FakePlatform(
|
|
||||||
environment: <String, String>{
|
|
||||||
'LUCI_BRANCH': branchName,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
final ProcessManager processManager = FakeProcessManager.list(
|
|
||||||
<FakeCommand>[
|
|
||||||
const FakeCommand(
|
|
||||||
command: <String>['flutter', '--version', '--machine'],
|
|
||||||
stdout: testVersionInfo,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
apidocs.FlutterInformation(platform: platform, processManager: processManager).getBranchName(),
|
|
||||||
branchName,
|
|
||||||
);
|
|
||||||
expect(processManager, hasNoRemainingExpectations);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('getBranchName calls git if env LUCI_BRANCH not provided', () {
|
|
||||||
final Platform platform = FakePlatform(
|
|
||||||
environment: <String, String>{},
|
|
||||||
);
|
|
||||||
|
|
||||||
final ProcessManager processManager = FakeProcessManager.list(
|
|
||||||
<FakeCommand>[
|
|
||||||
const FakeCommand(
|
|
||||||
command: <String>['flutter', '--version', '--machine'],
|
|
||||||
stdout: testVersionInfo,
|
|
||||||
),
|
|
||||||
const FakeCommand(
|
|
||||||
command: <String>['git', 'status', '-b', '--porcelain'],
|
|
||||||
stdout: '## $branchName',
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
apidocs.FlutterInformation(platform: platform, processManager: processManager).getBranchName(),
|
|
||||||
branchName,
|
|
||||||
);
|
|
||||||
expect(processManager, hasNoRemainingExpectations);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('getBranchName calls git if env LUCI_BRANCH is empty', () {
|
|
||||||
final Platform platform = FakePlatform(
|
|
||||||
environment: <String, String>{
|
|
||||||
'LUCI_BRANCH': '',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
final ProcessManager processManager = FakeProcessManager.list(
|
|
||||||
<FakeCommand>[
|
|
||||||
const FakeCommand(
|
|
||||||
command: <String>['flutter', '--version', '--machine'],
|
|
||||||
stdout: testVersionInfo,
|
|
||||||
),
|
|
||||||
const FakeCommand(
|
|
||||||
command: <String>['git', 'status', '-b', '--porcelain'],
|
|
||||||
stdout: '## $branchName',
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(
|
|
||||||
apidocs.FlutterInformation(platform: platform, processManager: processManager).getBranchName(),
|
|
||||||
branchName,
|
|
||||||
);
|
|
||||||
expect(processManager, hasNoRemainingExpectations);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("runPubProcess doesn't use the pub binary", () {
|
|
||||||
final Platform platform = FakePlatform(
|
|
||||||
environment: <String, String>{
|
|
||||||
'FLUTTER_ROOT': '/flutter',
|
|
||||||
},
|
|
||||||
);
|
|
||||||
final ProcessManager processManager = FakeProcessManager.list(
|
|
||||||
<FakeCommand>[
|
|
||||||
const FakeCommand(
|
|
||||||
command: <String>['/flutter/bin/dart', 'pub', '--one', '--two'],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
apidocs.FlutterInformation.instance =
|
|
||||||
apidocs.FlutterInformation(platform: platform, processManager: processManager);
|
|
||||||
|
|
||||||
apidocs.runPubProcess(
|
|
||||||
arguments: <String>['--one', '--two'],
|
|
||||||
processManager: processManager,
|
|
||||||
filesystem: filesystem,
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(processManager, hasNoRemainingExpectations);
|
|
||||||
});
|
|
||||||
|
|
||||||
group('FlutterInformation', () {
|
group('FlutterInformation', () {
|
||||||
late FakeProcessManager fakeProcessManager;
|
late FakeProcessManager fakeProcessManager;
|
||||||
late FakePlatform fakePlatform;
|
late FakePlatform fakePlatform;
|
||||||
@ -136,11 +34,96 @@ void main() {
|
|||||||
setUpWithEnvironment(<String, String>{});
|
setUpWithEnvironment(<String, String>{});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('getBranchName does not call git if env LUCI_BRANCH provided', () {
|
||||||
|
setUpWithEnvironment(
|
||||||
|
<String, String>{
|
||||||
|
'LUCI_BRANCH': branchName,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
|
command: <Pattern>['flutter', '--version', '--machine'],
|
||||||
|
stdout: testVersionInfo,
|
||||||
|
));
|
||||||
|
expect(
|
||||||
|
apidocs.FlutterInformation.instance.getBranchName(),
|
||||||
|
branchName,
|
||||||
|
);
|
||||||
|
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getBranchName calls git if env LUCI_BRANCH not provided', () {
|
||||||
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
|
command: <Pattern>['flutter', '--version', '--machine'],
|
||||||
|
stdout: testVersionInfo,
|
||||||
|
));
|
||||||
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
|
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||||
|
stdout: '## $branchName',
|
||||||
|
));
|
||||||
|
|
||||||
|
expect(
|
||||||
|
apidocs.FlutterInformation.instance.getBranchName(),
|
||||||
|
branchName,
|
||||||
|
);
|
||||||
|
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('getBranchName calls git if env LUCI_BRANCH is empty', () {
|
||||||
|
setUpWithEnvironment(
|
||||||
|
<String, String>{
|
||||||
|
'LUCI_BRANCH': '',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
|
command: <Pattern>['flutter', '--version', '--machine'],
|
||||||
|
stdout: testVersionInfo,
|
||||||
|
));
|
||||||
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
|
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||||
|
stdout: '## $branchName',
|
||||||
|
));
|
||||||
|
|
||||||
|
expect(
|
||||||
|
apidocs.FlutterInformation.instance.getBranchName(),
|
||||||
|
branchName,
|
||||||
|
);
|
||||||
|
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("runPubProcess doesn't use the pub binary", () {
|
||||||
|
final Platform platform = FakePlatform(
|
||||||
|
environment: <String, String>{
|
||||||
|
'FLUTTER_ROOT': '/flutter',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
final ProcessManager processManager = FakeProcessManager.list(
|
||||||
|
<FakeCommand>[
|
||||||
|
const FakeCommand(
|
||||||
|
command: <String>['/flutter/bin/flutter', 'pub', '--one', '--two'],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
apidocs.FlutterInformation.instance =
|
||||||
|
apidocs.FlutterInformation(platform: platform, processManager: processManager, filesystem: memoryFileSystem);
|
||||||
|
|
||||||
|
apidocs.runPubProcess(
|
||||||
|
arguments: <String>['--one', '--two'],
|
||||||
|
processManager: processManager,
|
||||||
|
filesystem: memoryFileSystem,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(processManager, hasNoRemainingExpectations);
|
||||||
|
});
|
||||||
|
|
||||||
test('calls out to flutter if FLUTTER_VERSION is not set', () async {
|
test('calls out to flutter if FLUTTER_VERSION is not set', () async {
|
||||||
fakeProcessManager.addCommand(
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
const FakeCommand(command: <Pattern>['flutter', '--version', '--machine'], stdout: testVersionInfo));
|
command: <Pattern>['flutter', '--version', '--machine'],
|
||||||
fakeProcessManager.addCommand(
|
stdout: testVersionInfo,
|
||||||
const FakeCommand(command: <Pattern>['git', 'status', '-b', '--porcelain'], stdout: testVersionInfo));
|
));
|
||||||
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
|
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||||
|
stdout: '## $branchName',
|
||||||
|
));
|
||||||
final Map<String, dynamic> info = flutterInformation.getFlutterInformation();
|
final Map<String, dynamic> info = flutterInformation.getFlutterInformation();
|
||||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||||
expect(info['frameworkVersion'], equals(Version.parse('2.5.0')));
|
expect(info['frameworkVersion'], equals(Version.parse('2.5.0')));
|
||||||
@ -149,17 +132,23 @@ void main() {
|
|||||||
setUpWithEnvironment(<String, String>{
|
setUpWithEnvironment(<String, String>{
|
||||||
'FLUTTER_VERSION': testVersionInfo,
|
'FLUTTER_VERSION': testVersionInfo,
|
||||||
});
|
});
|
||||||
fakeProcessManager.addCommand(
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
const FakeCommand(command: <Pattern>['git', 'status', '-b', '--porcelain'], stdout: testVersionInfo));
|
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||||
|
stdout: '## $branchName',
|
||||||
|
));
|
||||||
final Map<String, dynamic> info = flutterInformation.getFlutterInformation();
|
final Map<String, dynamic> info = flutterInformation.getFlutterInformation();
|
||||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||||
expect(info['frameworkVersion'], equals(Version.parse('2.5.0')));
|
expect(info['frameworkVersion'], equals(Version.parse('2.5.0')));
|
||||||
});
|
});
|
||||||
test('getFlutterRoot calls out to flutter if FLUTTER_ROOT is not set', () async {
|
test('getFlutterRoot calls out to flutter if FLUTTER_ROOT is not set', () async {
|
||||||
fakeProcessManager.addCommand(
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
const FakeCommand(command: <Pattern>['flutter', '--version', '--machine'], stdout: testVersionInfo));
|
command: <Pattern>['flutter', '--version', '--machine'],
|
||||||
fakeProcessManager.addCommand(
|
stdout: testVersionInfo,
|
||||||
const FakeCommand(command: <Pattern>['git', 'status', '-b', '--porcelain'], stdout: testVersionInfo));
|
));
|
||||||
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
|
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||||
|
stdout: '## $branchName',
|
||||||
|
));
|
||||||
final Directory root = flutterInformation.getFlutterRoot();
|
final Directory root = flutterInformation.getFlutterRoot();
|
||||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||||
expect(root.path, equals('/home/user/flutter'));
|
expect(root.path, equals('/home/user/flutter'));
|
||||||
@ -172,8 +161,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
test('parses version properly', () async {
|
test('parses version properly', () async {
|
||||||
fakePlatform.environment['FLUTTER_VERSION'] = testVersionInfo;
|
fakePlatform.environment['FLUTTER_VERSION'] = testVersionInfo;
|
||||||
fakeProcessManager.addCommand(
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
const FakeCommand(command: <Pattern>['git', 'status', '-b', '--porcelain'], stdout: testVersionInfo));
|
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||||
|
stdout: '## $branchName',
|
||||||
|
));
|
||||||
final Map<String, dynamic> info = flutterInformation.getFlutterInformation();
|
final Map<String, dynamic> info = flutterInformation.getFlutterInformation();
|
||||||
expect(info['frameworkVersion'], isNotNull);
|
expect(info['frameworkVersion'], isNotNull);
|
||||||
expect(info['frameworkVersion'], equals(Version.parse('2.5.0')));
|
expect(info['frameworkVersion'], equals(Version.parse('2.5.0')));
|
||||||
@ -181,14 +172,26 @@ void main() {
|
|||||||
expect(info['dartSdkVersion'], equals(Version.parse('2.14.0-360.0.dev')));
|
expect(info['dartSdkVersion'], equals(Version.parse('2.14.0-360.0.dev')));
|
||||||
});
|
});
|
||||||
test('the engine realm is read from the engine.realm file', () async {
|
test('the engine realm is read from the engine.realm file', () async {
|
||||||
const String flutterRoot = '/home/user/flutter';
|
final Directory flutterHome = memoryFileSystem
|
||||||
final File realmFile = memoryFileSystem.file(
|
.directory('/home')
|
||||||
path.join(flutterRoot, 'bin', 'internal', 'engine.realm',
|
.childDirectory('user')
|
||||||
|
.childDirectory('flutter')
|
||||||
|
.childDirectory('bin')
|
||||||
|
.childDirectory('internal');
|
||||||
|
flutterHome.childFile('engine.realm')
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('realm');
|
||||||
|
setUpWithEnvironment(<String, String>{'FLUTTER_ROOT': '/home/user/flutter'});
|
||||||
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
|
command: <Pattern>['/home/user/flutter/bin/flutter', '--version', '--machine'],
|
||||||
|
stdout: testVersionInfo,
|
||||||
|
));
|
||||||
|
fakeProcessManager.addCommand(const FakeCommand(
|
||||||
|
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||||
|
stdout: '## $branchName',
|
||||||
));
|
));
|
||||||
realmFile.writeAsStringSync('realm');
|
|
||||||
setUpWithEnvironment(<String, String>{'FLUTTER_ROOT': flutterRoot});
|
|
||||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
|
||||||
final Map<String, dynamic> info = flutterInformation.getFlutterInformation();
|
final Map<String, dynamic> info = flutterInformation.getFlutterInformation();
|
||||||
|
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||||
expect(info['engineRealm'], equals('realm'));
|
expect(info['engineRealm'], equals('realm'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user