Recover releases from independently retried CI packaging #15
No files matched your search
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
@@ -14,29 +15,83 @@ const _generatedFiles = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
test('workspace generated code is up to date', () async {
|
test(
|
||||||
await _expectNoUntrackedGeneratedFiles();
|
'workspace generated code is up to date',
|
||||||
final before = await _generatedContents();
|
() async {
|
||||||
final dart = flutterTestDartExecutable();
|
await _expectNoUntrackedGeneratedFiles();
|
||||||
for (final directory in _generatorRoots()) {
|
final before = await _generatedContents();
|
||||||
final result = await Process.run(dart, [
|
final dart = flutterTestDartExecutable();
|
||||||
'run',
|
final elapsed = Stopwatch()..start();
|
||||||
'build_runner',
|
for (final directory in _generatorRoots()) {
|
||||||
'build',
|
await _generate(
|
||||||
], workingDirectory: directory);
|
dart,
|
||||||
|
directory,
|
||||||
|
const Duration(minutes: 5) -
|
||||||
|
const Duration(seconds: 10) -
|
||||||
|
elapsed.elapsed,
|
||||||
|
);
|
||||||
|
}
|
||||||
expect(
|
expect(
|
||||||
result.exitCode,
|
await _generatedContents(),
|
||||||
0,
|
before,
|
||||||
reason: '$directory\n${result.stdout}\n${result.stderr}',
|
reason: 'Generated files changed. Run dart run build_runner build and review the output.',
|
||||||
);
|
);
|
||||||
|
await _expectNoUntrackedGeneratedFiles();
|
||||||
|
},
|
||||||
|
timeout: const Timeout(Duration(minutes: 5)),
|
||||||
|
tags: ['codegen'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _generate(
|
||||||
|
String dart,
|
||||||
|
String directory,
|
||||||
|
Duration remaining,
|
||||||
|
) async {
|
||||||
|
if (remaining <= Duration.zero) {
|
||||||
|
throw TimeoutException('Generated-code verification budget exhausted');
|
||||||
|
}
|
||||||
|
final elapsed = Stopwatch()..start();
|
||||||
|
stdout.writeln(
|
||||||
|
'Generating $directory; remaining budget: ${remaining.inSeconds}s',
|
||||||
|
);
|
||||||
|
final process = await Process.start(dart, [
|
||||||
|
'run',
|
||||||
|
'build_runner',
|
||||||
|
'build',
|
||||||
|
], workingDirectory: directory);
|
||||||
|
final output = StringBuffer();
|
||||||
|
Future<void> read(Stream<List<int>> stream) async {
|
||||||
|
await for (final line
|
||||||
|
in stream.transform(utf8.decoder).transform(const LineSplitter())) {
|
||||||
|
output.writeln(line);
|
||||||
|
stdout.writeln('[$directory] $line');
|
||||||
}
|
}
|
||||||
expect(
|
}
|
||||||
await _generatedContents(),
|
|
||||||
before,
|
final streams = Future.wait([read(process.stdout), read(process.stderr)]);
|
||||||
reason: 'Generated files changed. Run dart run build_runner build and review the output.',
|
var exited = false;
|
||||||
|
try {
|
||||||
|
final exitCode = await process.exitCode.timeout(remaining);
|
||||||
|
exited = true;
|
||||||
|
await streams;
|
||||||
|
expect(exitCode, 0, reason: '$directory\n$output');
|
||||||
|
} finally {
|
||||||
|
if (!exited) {
|
||||||
|
// Flutter's outer test timeout cannot terminate Process.run children.
|
||||||
|
// End the generator before leaving the test, including on Windows.
|
||||||
|
if (Platform.isWindows) {
|
||||||
|
await Process.run('taskkill', ['/PID', '${process.pid}', '/T', '/F']);
|
||||||
|
} else {
|
||||||
|
process.kill(ProcessSignal.sigkill);
|
||||||
|
}
|
||||||
|
await process.exitCode;
|
||||||
|
await streams;
|
||||||
|
}
|
||||||
|
stdout.writeln(
|
||||||
|
'Generation $directory ended after ${elapsed.elapsed.inMilliseconds}ms',
|
||||||
);
|
);
|
||||||
await _expectNoUntrackedGeneratedFiles();
|
}
|
||||||
}, timeout: const Timeout(Duration(minutes: 5)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _expectNoUntrackedGeneratedFiles() async {
|
Future<void> _expectNoUntrackedGeneratedFiles() async {
|
||||||
|
|||||||
+6
-1
@@ -45,7 +45,12 @@ def check_analyze():
|
|||||||
def check_flutter():
|
def check_flutter():
|
||||||
package_tests = sorted(str(path.relative_to(ROOT)) for pattern in ('*/test', '*/example/test')
|
package_tests = sorted(str(path.relative_to(ROOT)) for pattern in ('*/test', '*/example/test')
|
||||||
for path in (ROOT / 'packages').glob(pattern))
|
for path in (ROOT / 'packages').glob(pattern))
|
||||||
run(tool_command('flutter', ['test', '--reporter', 'expanded', 'test', *package_tests]))
|
run(tool_command('flutter', ['test', '--reporter', 'expanded', '--exclude-tags', 'codegen',
|
||||||
|
'test', *package_tests]))
|
||||||
|
# build_runner compiles generators and performs repository-wide file I/O.
|
||||||
|
# Keep this gate serial with widget tests to avoid competing with their isolates.
|
||||||
|
run(tool_command('flutter', ['test', '--reporter', 'expanded', '--tags', 'codegen',
|
||||||
|
'test/generated_code_test.dart']))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in new issue
Block a user