Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -36,85 +36,75 @@ void main() {
|
||||
});
|
||||
|
||||
test('getBranchName does not call git if env LUCI_BRANCH provided', () {
|
||||
setUpWithEnvironment(
|
||||
<String, String>{
|
||||
'LUCI_BRANCH': branchName,
|
||||
},
|
||||
setUpWithEnvironment(<String, String>{'LUCI_BRANCH': branchName});
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(
|
||||
command: <Pattern>['flutter', '--version', '--machine'],
|
||||
stdout: testVersionInfo,
|
||||
),
|
||||
);
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['flutter', '--version', '--machine'],
|
||||
stdout: testVersionInfo,
|
||||
));
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['git', 'rev-parse', 'HEAD'],
|
||||
));
|
||||
expect(
|
||||
apidocs.FlutterInformation.instance.getBranchName(),
|
||||
branchName,
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(command: <Pattern>['git', 'rev-parse', 'HEAD']),
|
||||
);
|
||||
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',
|
||||
));
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['git', 'rev-parse', 'HEAD'],
|
||||
));
|
||||
|
||||
expect(
|
||||
apidocs.FlutterInformation.instance.getBranchName(),
|
||||
branchName,
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(
|
||||
command: <Pattern>['flutter', '--version', '--machine'],
|
||||
stdout: testVersionInfo,
|
||||
),
|
||||
);
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
),
|
||||
);
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(command: <Pattern>['git', 'rev-parse', 'HEAD']),
|
||||
);
|
||||
|
||||
expect(apidocs.FlutterInformation.instance.getBranchName(), branchName);
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
});
|
||||
|
||||
test('getBranchName calls git if env LUCI_BRANCH is empty', () {
|
||||
setUpWithEnvironment(
|
||||
<String, String>{
|
||||
'LUCI_BRANCH': '',
|
||||
},
|
||||
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',
|
||||
),
|
||||
);
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(command: <Pattern>['git', 'rev-parse', 'HEAD']),
|
||||
);
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['flutter', '--version', '--machine'],
|
||||
stdout: testVersionInfo,
|
||||
));
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
));
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['git', 'rev-parse', 'HEAD'],
|
||||
));
|
||||
|
||||
expect(
|
||||
apidocs.FlutterInformation.instance.getBranchName(),
|
||||
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',
|
||||
},
|
||||
environment: <String, String>{'FLUTTER_ROOT': '/flutter'},
|
||||
);
|
||||
final ProcessManager processManager = FakeProcessManager.list(
|
||||
<FakeCommand>[
|
||||
const FakeCommand(
|
||||
command: <String>['/flutter/bin/flutter', 'pub', '--one', '--two'],
|
||||
),
|
||||
],
|
||||
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.FlutterInformation.instance =
|
||||
apidocs.FlutterInformation(platform: platform, processManager: processManager, filesystem: memoryFileSystem);
|
||||
|
||||
apidocs.runPubProcess(
|
||||
arguments: <String>['--one', '--two'],
|
||||
@@ -126,48 +116,56 @@ void main() {
|
||||
});
|
||||
|
||||
test('calls out to flutter if FLUTTER_VERSION is not set', () async {
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['flutter', '--version', '--machine'],
|
||||
stdout: testVersionInfo,
|
||||
));
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
));
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['git', 'rev-parse', 'HEAD'],
|
||||
));
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(
|
||||
command: <Pattern>['flutter', '--version', '--machine'],
|
||||
stdout: testVersionInfo,
|
||||
),
|
||||
);
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
),
|
||||
);
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(command: <Pattern>['git', 'rev-parse', 'HEAD']),
|
||||
);
|
||||
final Map<String, dynamic> info = flutterInformation.getFlutterInformation();
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
expect(info['frameworkVersion'], equals(Version.parse('2.5.0')));
|
||||
});
|
||||
test("doesn't call out to flutter if FLUTTER_VERSION is set", () async {
|
||||
setUpWithEnvironment(<String, String>{
|
||||
'FLUTTER_VERSION': testVersionInfo,
|
||||
});
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
));
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['git', 'rev-parse', 'HEAD'],
|
||||
));
|
||||
setUpWithEnvironment(<String, String>{'FLUTTER_VERSION': testVersionInfo});
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
),
|
||||
);
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(command: <Pattern>['git', 'rev-parse', 'HEAD']),
|
||||
);
|
||||
final Map<String, dynamic> info = flutterInformation.getFlutterInformation();
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
expect(info['frameworkVersion'], equals(Version.parse('2.5.0')));
|
||||
});
|
||||
test('getFlutterRoot calls out to flutter if FLUTTER_ROOT is not set', () async {
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['flutter', '--version', '--machine'],
|
||||
stdout: testVersionInfo,
|
||||
));
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
));
|
||||
fakeProcessManager.addCommand(const FakeCommand(
|
||||
command: <Pattern>['git', 'rev-parse', 'HEAD'],
|
||||
));
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(
|
||||
command: <Pattern>['flutter', '--version', '--machine'],
|
||||
stdout: testVersionInfo,
|
||||
),
|
||||
);
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
),
|
||||
);
|
||||
fakeProcessManager.addCommand(
|
||||
const FakeCommand(command: <Pattern>['git', 'rev-parse', 'HEAD']),
|
||||
);
|
||||
final Directory root = flutterInformation.getFlutterRoot();
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
expect(root.path, equals('/home/user/flutter'));
|
||||
@@ -185,9 +183,7 @@ void main() {
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD']),
|
||||
]);
|
||||
final Map<String, dynamic> info = flutterInformation.getFlutterInformation();
|
||||
expect(info['frameworkVersion'], isNotNull);
|
||||
@@ -215,9 +211,7 @@ void main() {
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD']),
|
||||
]);
|
||||
final Map<String, dynamic> info = flutterInformation.getFlutterInformation();
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
@@ -286,12 +280,8 @@ void main() {
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['/flutter/bin/flutter', 'pub', 'global', 'list'],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD']),
|
||||
const FakeCommand(command: <String>['/flutter/bin/flutter', 'pub', 'global', 'list']),
|
||||
FakeCommand(
|
||||
command: <Pattern>[
|
||||
'/flutter/bin/flutter',
|
||||
@@ -349,30 +339,51 @@ void main() {
|
||||
configurator.generateConfiguration();
|
||||
expect(packageRoot.childFile('pubspec.yaml').existsSync(), isTrue);
|
||||
expect(packageRoot.childFile('pubspec.yaml').readAsStringSync(), contains('flutter_gpu:'));
|
||||
expect(packageRoot.childFile('pubspec.yaml').readAsStringSync(), contains('dependency_overrides:'));
|
||||
expect(packageRoot.childFile('pubspec.yaml').readAsStringSync(), contains('platform_integration:'));
|
||||
expect(
|
||||
packageRoot.childFile('pubspec.yaml').readAsStringSync(),
|
||||
contains('dependency_overrides:'),
|
||||
);
|
||||
expect(
|
||||
packageRoot.childFile('pubspec.yaml').readAsStringSync(),
|
||||
contains('platform_integration:'),
|
||||
);
|
||||
});
|
||||
|
||||
test('.generateConfiguration generates fake lib', () async {
|
||||
configurator.generateConfiguration();
|
||||
expect(packageRoot.childDirectory('lib').existsSync(), isTrue);
|
||||
expect(packageRoot.childDirectory('lib').childFile('temp_doc.dart').existsSync(), isTrue);
|
||||
expect(packageRoot.childDirectory('lib').childFile('temp_doc.dart').readAsStringSync(), contains('library temp_doc;'));
|
||||
expect(packageRoot.childDirectory('lib').childFile('temp_doc.dart').readAsStringSync(), contains("import 'package:flutter_gpu/gpu.dart';"));
|
||||
expect(
|
||||
packageRoot.childDirectory('lib').childFile('temp_doc.dart').readAsStringSync(),
|
||||
contains('library temp_doc;'),
|
||||
);
|
||||
expect(
|
||||
packageRoot.childDirectory('lib').childFile('temp_doc.dart').readAsStringSync(),
|
||||
contains("import 'package:flutter_gpu/gpu.dart';"),
|
||||
);
|
||||
});
|
||||
|
||||
test('.generateConfiguration generates page footer', () async {
|
||||
configurator.generateConfiguration();
|
||||
expect(packageRoot.childFile('footer.html').existsSync(), isTrue);
|
||||
expect(packageRoot.childFile('footer.html').readAsStringSync(), contains('<script src="footer.js">'));
|
||||
expect(
|
||||
packageRoot.childFile('footer.html').readAsStringSync(),
|
||||
contains('<script src="footer.js">'),
|
||||
);
|
||||
expect(publishRoot.childDirectory('flutter').childFile('footer.js').existsSync(), isTrue);
|
||||
expect(publishRoot.childDirectory('flutter').childFile('footer.js').readAsStringSync(), contains(RegExp(r'Flutter 2.5.0 •.*• stable')));
|
||||
expect(
|
||||
publishRoot.childDirectory('flutter').childFile('footer.js').readAsStringSync(),
|
||||
contains(RegExp(r'Flutter 2.5.0 •.*• stable')),
|
||||
);
|
||||
});
|
||||
|
||||
test('.generateConfiguration generates search metadata', () async {
|
||||
configurator.generateConfiguration();
|
||||
expect(publishRoot.childFile('opensearch.xml').existsSync(), isTrue);
|
||||
expect(publishRoot.childFile('opensearch.xml').readAsStringSync(), contains('https://api.flutter.dev/'));
|
||||
expect(
|
||||
publishRoot.childFile('opensearch.xml').readAsStringSync(),
|
||||
contains('https://api.flutter.dev/'),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -398,9 +409,7 @@ void main() {
|
||||
apidocs.FlutterInformation.instance = apidocs.FlutterInformation(
|
||||
filesystem: fs,
|
||||
processManager: processManager,
|
||||
platform: FakePlatform(environment: <String, String>{
|
||||
'FLUTTER_ROOT': repoRoot.path,
|
||||
}),
|
||||
platform: FakePlatform(environment: <String, String>{'FLUTTER_ROOT': repoRoot.path}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -415,12 +424,8 @@ void main() {
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['/flutter/bin/flutter', 'pub', 'global', 'list'],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD']),
|
||||
const FakeCommand(command: <String>['/flutter/bin/flutter', 'pub', 'global', 'list']),
|
||||
FakeCommand(
|
||||
command: <Pattern>[
|
||||
'/flutter/bin/flutter',
|
||||
@@ -480,7 +485,11 @@ void main() {
|
||||
isA<Exception>().having(
|
||||
(Exception e) => e.toString(),
|
||||
'message',
|
||||
contains(RegExp(r'Missing .* which probably means the documentation failed to build correctly.')),
|
||||
contains(
|
||||
RegExp(
|
||||
r'Missing .* which probably means the documentation failed to build correctly.',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -499,12 +508,8 @@ void main() {
|
||||
command: <Pattern>['git', 'status', '-b', '--porcelain'],
|
||||
stdout: '## $branchName',
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['git', 'rev-parse', 'HEAD'],
|
||||
),
|
||||
const FakeCommand(
|
||||
command: <String>['/flutter/bin/flutter', 'pub', 'global', 'list'],
|
||||
),
|
||||
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD']),
|
||||
const FakeCommand(command: <String>['/flutter/bin/flutter', 'pub', 'global', 'list']),
|
||||
FakeCommand(
|
||||
command: <Pattern>[
|
||||
'/flutter/bin/flutter',
|
||||
@@ -562,28 +567,26 @@ void main() {
|
||||
publishRoot.childDirectory('flutter').childFile(path).createSync(recursive: true);
|
||||
}
|
||||
for (final String path in dartdocDirectiveCanaryLibraries) {
|
||||
publishRoot.childDirectory('flutter').childDirectory(path).createSync(recursive: true);
|
||||
publishRoot
|
||||
.childDirectory('flutter')
|
||||
.childDirectory(path)
|
||||
.createSync(recursive: true);
|
||||
}
|
||||
publishRoot.childDirectory('flutter').childFile('index.html').createSync();
|
||||
|
||||
final Directory widgetsDir = publishRoot
|
||||
.childDirectory('flutter')
|
||||
.childDirectory('widgets')
|
||||
..createSync(recursive: true);
|
||||
.childDirectory('flutter')
|
||||
.childDirectory('widgets')..createSync(recursive: true);
|
||||
widgetsDir.childFile('showGeneralDialog.html').writeAsStringSync('''
|
||||
<pre id="longSnippet1">
|
||||
<code class="language-dart">
|
||||
import 'package:flutter/material.dart';
|
||||
</code>
|
||||
</pre>
|
||||
''',
|
||||
);
|
||||
''');
|
||||
expect(publishRoot.childDirectory('flutter').existsSync(), isTrue);
|
||||
(widgetsDir
|
||||
.childDirectory('ModalRoute')
|
||||
..createSync(recursive: true))
|
||||
.childFile('barrierColor.html')
|
||||
.writeAsStringSync('''
|
||||
(widgetsDir.childDirectory('ModalRoute')
|
||||
..createSync(recursive: true)).childFile('barrierColor.html').writeAsStringSync('''
|
||||
<pre id="sample-code">
|
||||
<code class="language-dart">
|
||||
class FooClass {
|
||||
@@ -592,12 +595,13 @@ void main() {
|
||||
</code>
|
||||
</pre>
|
||||
''');
|
||||
const String queryParams = 'split=1&run=true&sample_id=widgets.Listener.123&channel=main';
|
||||
const String queryParams =
|
||||
'split=1&run=true&sample_id=widgets.Listener.123&channel=main';
|
||||
widgetsDir.childFile('Listener-class.html').writeAsStringSync('''
|
||||
<iframe class="snippet-dartpad" src="https://dartpad.dev/embed-flutter.html?$queryParams">
|
||||
</iframe>
|
||||
''');
|
||||
}
|
||||
},
|
||||
),
|
||||
]);
|
||||
|
||||
|
||||
@@ -11,25 +11,26 @@ import '../bin/engine_hash.dart' show GitRevisionStrategy, engineHash;
|
||||
|
||||
void main() {
|
||||
test('Produces an engine hash for merge-base', () async {
|
||||
final Future<io.ProcessResult> Function(List<String>) runProcess =
|
||||
_fakeProcesses(processes: <FakeProcess>[
|
||||
(
|
||||
exe: 'git',
|
||||
command: 'merge-base',
|
||||
rest: <String>['upstream/master', 'HEAD'],
|
||||
exitCode: 0,
|
||||
stdout: 'abcdef1234',
|
||||
stderr: null
|
||||
),
|
||||
(
|
||||
exe: 'git',
|
||||
command: 'ls-tree',
|
||||
rest: <String>['-r', 'abcdef1234', 'engine', 'DEPS'],
|
||||
exitCode: 0,
|
||||
stdout: 'one\r\ntwo\r\n',
|
||||
stderr: null
|
||||
),
|
||||
]);
|
||||
final Future<io.ProcessResult> Function(List<String>) runProcess = _fakeProcesses(
|
||||
processes: <FakeProcess>[
|
||||
(
|
||||
exe: 'git',
|
||||
command: 'merge-base',
|
||||
rest: <String>['upstream/master', 'HEAD'],
|
||||
exitCode: 0,
|
||||
stdout: 'abcdef1234',
|
||||
stderr: null,
|
||||
),
|
||||
(
|
||||
exe: 'git',
|
||||
command: 'ls-tree',
|
||||
rest: <String>['-r', 'abcdef1234', 'engine', 'DEPS'],
|
||||
exitCode: 0,
|
||||
stdout: 'one\r\ntwo\r\n',
|
||||
stderr: null,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final Future<String> result = engineHash(runProcess);
|
||||
|
||||
@@ -37,8 +38,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('Produces an engine hash for HEAD', () async {
|
||||
final Future<io.ProcessResult> Function(List<String>) runProcess =
|
||||
_fakeProcesses(
|
||||
final Future<io.ProcessResult> Function(List<String>) runProcess = _fakeProcesses(
|
||||
processes: <FakeProcess>[
|
||||
(
|
||||
exe: 'git',
|
||||
@@ -46,57 +46,54 @@ void main() {
|
||||
rest: <String>['-r', 'HEAD', 'engine', 'DEPS'],
|
||||
exitCode: 0,
|
||||
stdout: 'one\ntwo\n',
|
||||
stderr: null
|
||||
stderr: null,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final Future<String> result =
|
||||
engineHash(runProcess, revisionStrategy: GitRevisionStrategy.head);
|
||||
final Future<String> result = engineHash(
|
||||
runProcess,
|
||||
revisionStrategy: GitRevisionStrategy.head,
|
||||
);
|
||||
|
||||
expect(result, completion('c708d7ef841f7e1748436b8ef5670d0b2de1a227'));
|
||||
});
|
||||
|
||||
test('Returns error in non-monorepo', () async {
|
||||
final Future<io.ProcessResult> Function(List<String>) runProcess =
|
||||
_fakeProcesses(processes: <FakeProcess>[
|
||||
(
|
||||
exe: 'git',
|
||||
command: 'ls-tree',
|
||||
rest: <String>['-r', 'HEAD', 'engine', 'DEPS'],
|
||||
exitCode: 0,
|
||||
stdout: '',
|
||||
stderr: null
|
||||
),
|
||||
]);
|
||||
final Future<io.ProcessResult> Function(List<String>) runProcess = _fakeProcesses(
|
||||
processes: <FakeProcess>[
|
||||
(
|
||||
exe: 'git',
|
||||
command: 'ls-tree',
|
||||
rest: <String>['-r', 'HEAD', 'engine', 'DEPS'],
|
||||
exitCode: 0,
|
||||
stdout: '',
|
||||
stderr: null,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final Future<String> result =
|
||||
engineHash(runProcess, revisionStrategy: GitRevisionStrategy.head);
|
||||
final Future<String> result = engineHash(
|
||||
runProcess,
|
||||
revisionStrategy: GitRevisionStrategy.head,
|
||||
);
|
||||
|
||||
expect(result, throwsA('Not in a monorepo'));
|
||||
});
|
||||
}
|
||||
|
||||
typedef FakeProcess = ({
|
||||
String exe,
|
||||
String command,
|
||||
List<String> rest,
|
||||
dynamic stdout,
|
||||
dynamic stderr,
|
||||
int exitCode
|
||||
});
|
||||
typedef FakeProcess =
|
||||
({String exe, String command, List<String> rest, dynamic stdout, dynamic stderr, int exitCode});
|
||||
|
||||
Future<io.ProcessResult> Function(List<String>) _fakeProcesses({
|
||||
required List<FakeProcess> processes,
|
||||
}) =>
|
||||
(List<String> cmd) async {
|
||||
for (final FakeProcess process in processes) {
|
||||
if (process.exe.endsWith(cmd[0]) &&
|
||||
process.command.endsWith(cmd[1]) &&
|
||||
process.rest.equals(cmd.sublist(2))) {
|
||||
return io.ProcessResult(
|
||||
1, process.exitCode, process.stdout, process.stderr);
|
||||
}
|
||||
}
|
||||
return io.ProcessResult(1, -42, '', '404 command not found: $cmd');
|
||||
};
|
||||
}) => (List<String> cmd) async {
|
||||
for (final FakeProcess process in processes) {
|
||||
if (process.exe.endsWith(cmd[0]) &&
|
||||
process.command.endsWith(cmd[1]) &&
|
||||
process.rest.equals(cmd.sublist(2))) {
|
||||
return io.ProcessResult(1, process.exitCode, process.stdout, process.stderr);
|
||||
}
|
||||
}
|
||||
return io.ProcessResult(1, -42, '', '404 command not found: $cmd');
|
||||
};
|
||||
|
||||
@@ -75,38 +75,47 @@ void main() {
|
||||
'format.${io.Platform.isWindows ? 'bat' : 'sh'}',
|
||||
);
|
||||
|
||||
test('Can fix Dart formatting errors', () {
|
||||
final TestFileFixture fixture = TestFileFixture(<FileContentPair>[
|
||||
dartContentPair,
|
||||
], flutterRoot);
|
||||
try {
|
||||
fixture.gitAdd();
|
||||
io.Process.runSync(formatterPath, <String>['--fix'], workingDirectory: flutterRoot.path);
|
||||
test(
|
||||
'Can fix Dart formatting errors',
|
||||
() {
|
||||
final TestFileFixture fixture = TestFileFixture(<FileContentPair>[
|
||||
dartContentPair,
|
||||
], flutterRoot);
|
||||
try {
|
||||
fixture.gitAdd();
|
||||
io.Process.runSync(formatterPath, <String>['--fix'], workingDirectory: flutterRoot.path);
|
||||
|
||||
final Iterable<FileContentPair> files = fixture.getFileContents();
|
||||
for (final FileContentPair pair in files) {
|
||||
expect(pair.original, equals(pair.formatted));
|
||||
final Iterable<FileContentPair> files = fixture.getFileContents();
|
||||
for (final FileContentPair pair in files) {
|
||||
expect(pair.original, equals(pair.formatted));
|
||||
}
|
||||
} finally {
|
||||
fixture.gitRemove();
|
||||
}
|
||||
} finally {
|
||||
fixture.gitRemove();
|
||||
}
|
||||
});
|
||||
},
|
||||
// TODO(goderbauer): Re-enable after the formatting changes have landed.
|
||||
skip: true,
|
||||
);
|
||||
|
||||
test('Prints error if dart formatter fails', () {
|
||||
final TestFileFixture fixture = TestFileFixture(<FileContentPair>[], flutterRoot);
|
||||
final io.File dartFile = io.File('${flutterRoot.path}/format_test2.dart');
|
||||
dartFile.writeAsStringSync('P\n');
|
||||
fixture.files.add(dartFile);
|
||||
test(
|
||||
'Prints error if dart formatter fails',
|
||||
() {
|
||||
final TestFileFixture fixture = TestFileFixture(<FileContentPair>[], flutterRoot);
|
||||
final io.File dartFile = io.File('${flutterRoot.path}/format_test2.dart');
|
||||
dartFile.writeAsStringSync('P\n');
|
||||
fixture.files.add(dartFile);
|
||||
|
||||
try {
|
||||
fixture.gitAdd();
|
||||
final io.ProcessResult result = io.Process.runSync(formatterPath, <String>[
|
||||
'--fix',
|
||||
], workingDirectory: flutterRoot.path);
|
||||
expect(result.stdout, contains('format_test2.dart produced the following error'));
|
||||
expect(result.exitCode, isNot(0));
|
||||
} finally {
|
||||
fixture.gitRemove();
|
||||
}
|
||||
});
|
||||
try {
|
||||
fixture.gitAdd();
|
||||
final io.ProcessResult result = io.Process.runSync(formatterPath, <String>[
|
||||
'--fix',
|
||||
], workingDirectory: flutterRoot.path);
|
||||
expect(result.stdout, contains('format_test2.dart produced the following error'));
|
||||
expect(result.exitCode, isNot(0));
|
||||
} finally {
|
||||
fixture.gitRemove();
|
||||
}
|
||||
}, // TODO(goderbauer): Re-enable after the formatting changes have landed.
|
||||
skip: true,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,20 +6,10 @@ import 'package:test/test.dart';
|
||||
|
||||
import '../update_icons.dart';
|
||||
|
||||
Map<String, String> codepointsA = <String, String>{
|
||||
'airplane': '111',
|
||||
'boat': '222',
|
||||
};
|
||||
Map<String, String> codepointsB = <String, String>{
|
||||
'airplane': '333',
|
||||
};
|
||||
Map<String, String> codepointsC = <String, String>{
|
||||
'airplane': '111',
|
||||
'train': '444',
|
||||
};
|
||||
Map<String, String> codepointsUnderscore = <String, String>{
|
||||
'airplane__123': '111',
|
||||
};
|
||||
Map<String, String> codepointsA = <String, String>{'airplane': '111', 'boat': '222'};
|
||||
Map<String, String> codepointsB = <String, String>{'airplane': '333'};
|
||||
Map<String, String> codepointsC = <String, String>{'airplane': '111', 'train': '444'};
|
||||
Map<String, String> codepointsUnderscore = <String, String>{'airplane__123': '111'};
|
||||
|
||||
void main() {
|
||||
group('safety checks', () {
|
||||
@@ -45,17 +35,11 @@ void main() {
|
||||
});
|
||||
|
||||
test('usage string is correct', () {
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('abc', '')).usage,
|
||||
'Icon(Icons.abc),',
|
||||
);
|
||||
expect(Icon(const MapEntry<String, String>('abc', '')).usage, 'Icon(Icons.abc),');
|
||||
});
|
||||
|
||||
test('usage string is correct with replacement', () {
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('123', '')).usage,
|
||||
'Icon(Icons.onetwothree),',
|
||||
);
|
||||
expect(Icon(const MapEntry<String, String>('123', '')).usage, 'Icon(Icons.onetwothree),');
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('123_rounded', '')).usage,
|
||||
'Icon(Icons.onetwothree_rounded),',
|
||||
@@ -64,58 +48,22 @@ void main() {
|
||||
|
||||
test('certain icons should be mirrored in RTL', () {
|
||||
// Exact match
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('help', '')).isMirroredInRTL,
|
||||
true,
|
||||
);
|
||||
expect(Icon(const MapEntry<String, String>('help', '')).isMirroredInRTL, true);
|
||||
// Variant
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('help_rounded', '')).isMirroredInRTL,
|
||||
true,
|
||||
);
|
||||
expect(Icon(const MapEntry<String, String>('help_rounded', '')).isMirroredInRTL, true);
|
||||
// Common suffixes
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('help_alt', '')).isMirroredInRTL,
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('help_new', '')).isMirroredInRTL,
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('help_off', '')).isMirroredInRTL,
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('help_on', '')).isMirroredInRTL,
|
||||
true,
|
||||
);
|
||||
expect(Icon(const MapEntry<String, String>('help_alt', '')).isMirroredInRTL, true);
|
||||
expect(Icon(const MapEntry<String, String>('help_new', '')).isMirroredInRTL, true);
|
||||
expect(Icon(const MapEntry<String, String>('help_off', '')).isMirroredInRTL, true);
|
||||
expect(Icon(const MapEntry<String, String>('help_on', '')).isMirroredInRTL, true);
|
||||
// Common suffixes + variant
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('help_alt_rounded', '')).isMirroredInRTL,
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('help_new_rounded', '')).isMirroredInRTL,
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('help_off_rounded', '')).isMirroredInRTL,
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('help_on_rounded', '')).isMirroredInRTL,
|
||||
true,
|
||||
);
|
||||
expect(Icon(const MapEntry<String, String>('help_alt_rounded', '')).isMirroredInRTL, true);
|
||||
expect(Icon(const MapEntry<String, String>('help_new_rounded', '')).isMirroredInRTL, true);
|
||||
expect(Icon(const MapEntry<String, String>('help_off_rounded', '')).isMirroredInRTL, true);
|
||||
expect(Icon(const MapEntry<String, String>('help_on_rounded', '')).isMirroredInRTL, true);
|
||||
// No match
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('help_center_rounded', '')).isMirroredInRTL,
|
||||
false,
|
||||
);
|
||||
expect(Icon(const MapEntry<String, String>('help_center_rounded', '')).isMirroredInRTL, false);
|
||||
// No match
|
||||
expect(
|
||||
Icon(const MapEntry<String, String>('arrow', '')).isMirroredInRTL,
|
||||
false,
|
||||
);
|
||||
expect(Icon(const MapEntry<String, String>('arrow', '')).isMirroredInRTL, false);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user