more UI-as-code (#35516)

This commit is contained in:
Alexandre Ardhuin
2019-09-17 16:23:44 +02:00
committed by GitHub
parent d03aecab58
commit df4bf453ab
117 changed files with 1728 additions and 2132 deletions

View File

@@ -208,23 +208,20 @@ class SampleChecker {
/// Computes the headers needed for each sample file.
List<Line> get headers {
if (_headers == null) {
final List<String> buffer = <String>[];
buffer.add('// generated code');
buffer.add('import \'dart:async\';');
buffer.add('import \'dart:convert\';');
buffer.add('import \'dart:math\' as math;');
buffer.add('import \'dart:typed_data\';');
buffer.add('import \'dart:ui\' as ui;');
buffer.add('import \'package:flutter_test/flutter_test.dart\';');
for (File file in _listDartFiles(Directory(_defaultFlutterPackage))) {
buffer.add('');
buffer.add('// ${file.path}');
buffer.add('import \'package:flutter/${path.basename(file.path)}\';');
}
_headers = buffer.map<Line>((String code) => Line(code)).toList();
}
return _headers;
return _headers ??= <String>[
'// generated code',
"import 'dart:async';",
"import 'dart:convert';",
"import 'dart:math' as math;",
"import 'dart:typed_data';",
"import 'dart:ui' as ui;",
"import 'package:flutter_test/flutter_test.dart';",
for (File file in _listDartFiles(Directory(_defaultFlutterPackage))) ...<String>[
'',
'// ${file.path}',
"import 'package:flutter/${path.basename(file.path)}';",
],
].map<Line>((String code) => Line(code)).toList();
}
List<Line> _headers;

View File

@@ -177,7 +177,7 @@ Future<void> _checkForTrailingSpaces() async {
'*.dart', '*.cxx', '*.cpp', '*.cc', '*.c', '*.C', '*.h', '*.java', '*.mm', '*.m', '*.yml',
];
final EvalResult changedFilesResult = await _evalCommand(
'git', <String>['diff', '-U0', '--no-color', '--name-only', commitRange, '--'] + fileTypes,
'git', <String>['diff', '-U0', '--no-color', '--name-only', commitRange, '--', ...fileTypes],
workingDirectory: flutterRoot,
);
if (changedFilesResult.stdout == null || changedFilesResult.stdout.trim().isEmpty) {
@@ -195,7 +195,8 @@ Future<void> _checkForTrailingSpaces() async {
'--line-number',
'--extended-regexp',
r'[[:blank:]]$',
] + changedFiles,
...changedFiles,
],
workingDirectory: flutterRoot,
failureMessage: '${red}Whitespace detected at the end of source code lines.$reset\nPlease remove:',
expectNonZeroExit: true, // Just means a non-zero exit code is expected.

View File

@@ -527,20 +527,16 @@ class ArchivePublisher {
// Search for any entries with the same hash and channel and remove them.
final List<dynamic> releases = jsonData['releases'];
final List<Map<String, dynamic>> prunedReleases = <Map<String, dynamic>>[];
for (Map<String, dynamic> entry in releases) {
if (entry['hash'] != newEntry['hash'] || entry['channel'] != newEntry['channel']) {
prunedReleases.add(entry);
}
}
prunedReleases.add(newEntry);
prunedReleases.sort((Map<String, dynamic> a, Map<String, dynamic> b) {
jsonData['releases'] = <Map<String, dynamic>>[
for (Map<String, dynamic> entry in releases)
if (entry['hash'] != newEntry['hash'] || entry['channel'] != newEntry['channel'])
entry,
newEntry,
]..sort((Map<String, dynamic> a, Map<String, dynamic> b) {
final DateTime aDate = DateTime.parse(a['release_date']);
final DateTime bDate = DateTime.parse(b['release_date']);
return bDate.compareTo(aDate);
});
jsonData['releases'] = prunedReleases;
return jsonData;
}

View File

@@ -184,17 +184,16 @@ Future<bq.BigqueryApi> _getBigqueryApi() async {
// Partition tool tests into two groups, see explanation on `_runToolCoverage`.
List<List<String>> _partitionToolTests() {
final List<String> pending = <String>[];
final String toolTestDir = path.join(toolRoot, 'test');
for (FileSystemEntity entity in Directory(toolTestDir).listSync(recursive: true)) {
if (entity is File && entity.path.endsWith('_test.dart')) {
final String relativePath = path.relative(entity.path, from: toolRoot);
pending.add(relativePath);
}
}
final List<String> pending = <String>[
for (FileSystemEntity entity in Directory(toolTestDir).listSync(recursive: true))
if (entity is File && entity.path.endsWith('_test.dart'))
path.relative(entity.path, from: toolRoot),
];
// Shuffle the tests to avoid giving an expensive test directory like
// integration to a single run of tests.
pending..shuffle();
pending.shuffle();
final int aboutHalf = pending.length ~/ 2;
final List<String> groupA = pending.take(aboutHalf).toList();
final List<String> groupB = pending.skip(aboutHalf).toList();
@@ -512,19 +511,20 @@ Future<void> _buildRunnerTest(
bool enableFlutterToolAsserts = false,
bq.TabledataResourceApi tableData,
}) async {
final List<String> args = <String>['run', 'build_runner', 'test', '--', useFlutterTestFormatter ? '-rjson' : '-rcompact', '-j1'];
if (!hasColor) {
args.add('--no-color');
}
if (testPath != null) {
args.add(testPath);
}
final List<String> args = <String>[
'run',
'build_runner',
'test',
'--',
if (useFlutterTestFormatter) '-rjson' else '-rcompact',
'-j1',
if (!hasColor) '--no-color',
if (testPath != null) testPath,
];
final Map<String, String> pubEnvironment = <String, String>{
'FLUTTER_ROOT': flutterRoot,
if (Directory(pubCache).existsSync()) 'PUB_CACHE': pubCache,
};
if (Directory(pubCache).existsSync()) {
pubEnvironment['PUB_CACHE'] = pubCache;
}
if (enableFlutterToolAsserts) {
// If an existing env variable exists append to it, but only if
// it doesn't appear to already include enable-asserts.
@@ -574,15 +574,17 @@ Future<void> _pubRunTest(
bool enableFlutterToolAsserts = false,
bq.TabledataResourceApi tableData,
}) async {
final List<String> args = <String>['run', 'test', useFlutterTestFormatter ? '-rjson' : '-rcompact', '-j1'];
if (!hasColor)
args.add('--no-color');
if (testPath != null)
args.add(testPath);
final Map<String, String> pubEnvironment = <String, String>{};
if (Directory(pubCache).existsSync()) {
pubEnvironment['PUB_CACHE'] = pubCache;
}
final List<String> args = <String>[
'run',
'test',
if (useFlutterTestFormatter) '-rjson' else '-rcompact',
'-j1',
if (!hasColor) '--no-color',
if (testPath != null) testPath,
];
final Map<String, String> pubEnvironment = <String, String>{
if (Directory(pubCache).existsSync()) 'PUB_CACHE': pubCache,
};
if (enableFlutterToolAsserts) {
// If an existing env variable exists append to it, but only if
// it doesn't appear to already include enable-asserts.