refactor(build): 统一本地与 CI 构建入口及平台发布工具 #9
No files matched your search
@@ -1,4 +1,5 @@
|
|||||||
import 'support/creation_names.dart';
|
import 'support/creation_names.dart';
|
||||||
|
import 'support/dart_executable.dart';
|
||||||
|
|
||||||
import 'package:cutdex/app/editor_theme.dart';
|
import 'package:cutdex/app/editor_theme.dart';
|
||||||
import 'package:cutdex/l10n/app_localizations.dart';
|
import 'package:cutdex/l10n/app_localizations.dart';
|
||||||
@@ -1790,12 +1791,14 @@ void main() {
|
|||||||
);
|
);
|
||||||
addTearDown(bridge.close);
|
addTearDown(bridge.close);
|
||||||
final process = await Process.start(
|
final process = await Process.start(
|
||||||
'dart',
|
flutterTestDartExecutable(),
|
||||||
['run', 'tool/mcp_stdio.dart'],
|
['tool/mcp_stdio.dart'],
|
||||||
runInShell: Platform.isWindows,
|
|
||||||
environment: {
|
environment: {
|
||||||
'CUTDEX_MCP_PORT': '${bridge.port}',
|
'CUTDEX_MCP_PORT': '${bridge.port}',
|
||||||
'CUTDEX_MCP_TOKEN': token,
|
'CUTDEX_MCP_TOKEN': token,
|
||||||
|
// This standard-library launcher must not need a Dart/Flutter wrapper
|
||||||
|
// on PATH, or compete with parallel generators for startup/pub locks.
|
||||||
|
'PATH': root.path,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
addTearDown(process.kill);
|
addTearDown(process.kill);
|
||||||
@@ -1809,13 +1812,19 @@ void main() {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final response = jsonDecode(
|
final String responseLine;
|
||||||
await process.stdout
|
try {
|
||||||
|
responseLine = await process.stdout
|
||||||
.transform(utf8.decoder)
|
.transform(utf8.decoder)
|
||||||
.transform(const LineSplitter())
|
.transform(const LineSplitter())
|
||||||
.first
|
.first
|
||||||
.timeout(const Duration(seconds: 15)),
|
.timeout(const Duration(seconds: 15));
|
||||||
) as Map;
|
} on TimeoutException {
|
||||||
|
process.kill();
|
||||||
|
await process.exitCode.timeout(const Duration(seconds: 5));
|
||||||
|
fail('MCP launcher did not respond within 15 seconds.\n${await errors}');
|
||||||
|
}
|
||||||
|
final response = jsonDecode(responseLine) as Map;
|
||||||
expect((response['result'] as Map)['isError'], false, reason: '$response');
|
expect((response['result'] as Map)['isError'], false, reason: '$response');
|
||||||
expect(transform().x, closeTo(320 / session.canvas.width, 1e-9));
|
expect(transform().x, closeTo(320 / session.canvas.width, 1e-9));
|
||||||
await process.stdin.close();
|
await process.stdin.close();
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import 'dart:io';
|
|||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
|
|
||||||
|
import 'support/dart_executable.dart';
|
||||||
|
|
||||||
const _generatedFiles = [
|
const _generatedFiles = [
|
||||||
':(glob)lib/**/*.g.dart',
|
':(glob)lib/**/*.g.dart',
|
||||||
':(glob)lib/**/*.freezed.dart',
|
':(glob)lib/**/*.freezed.dart',
|
||||||
@@ -15,10 +17,7 @@ void main() {
|
|||||||
test('workspace generated code is up to date', () async {
|
test('workspace generated code is up to date', () async {
|
||||||
await _expectNoUntrackedGeneratedFiles();
|
await _expectNoUntrackedGeneratedFiles();
|
||||||
final before = await _generatedContents();
|
final before = await _generatedContents();
|
||||||
final flutterRoot = Platform.environment['FLUTTER_ROOT'];
|
final dart = flutterTestDartExecutable();
|
||||||
final dart = flutterRoot == null
|
|
||||||
? (Platform.isWindows ? 'dart.exe' : 'dart')
|
|
||||||
: '$flutterRoot/bin/cache/dart-sdk/bin/${Platform.isWindows ? 'dart.exe' : 'dart'}';
|
|
||||||
for (final directory in _generatorRoots()) {
|
for (final directory in _generatorRoots()) {
|
||||||
final result = await Process.run(dart, [
|
final result = await Process.run(dart, [
|
||||||
'run',
|
'run',
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:path/path.dart' as p;
|
||||||
|
|
||||||
|
/// Uses the SDK running Flutter tests without invoking its shell launcher.
|
||||||
|
String flutterTestDartExecutable() {
|
||||||
|
final root = Platform.environment['FLUTTER_ROOT'];
|
||||||
|
if (root == null || root.isEmpty) {
|
||||||
|
throw StateError(
|
||||||
|
'Flutter tests require FLUTTER_ROOT to select their Dart SDK.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final executable = p.join(
|
||||||
|
root,
|
||||||
|
'bin',
|
||||||
|
'cache',
|
||||||
|
'dart-sdk',
|
||||||
|
'bin',
|
||||||
|
Platform.isWindows ? 'dart.exe' : 'dart',
|
||||||
|
);
|
||||||
|
if (!File(executable).existsSync()) {
|
||||||
|
throw StateError(
|
||||||
|
'The Flutter test SDK is missing its native Dart executable.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return executable;
|
||||||
|
}
|
||||||
@@ -2392,9 +2392,16 @@ void main() {
|
|||||||
targetLanguage: 'zh',
|
targetLanguage: 'zh',
|
||||||
);
|
);
|
||||||
await backend.started.future;
|
await backend.started.future;
|
||||||
|
final completed = Completer<void>();
|
||||||
|
void checkCompletion() {
|
||||||
|
if (job.terminal && !completed.isCompleted) completed.complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
session.addListener(checkCompletion);
|
||||||
|
addTearDown(() => session.removeListener(checkCompletion));
|
||||||
await session.subtitleWorkflows.cancel(job);
|
await session.subtitleWorkflows.cancel(job);
|
||||||
await settle(session);
|
checkCompletion();
|
||||||
await Future<void>.delayed(const Duration(milliseconds: 10));
|
await completed.future.timeout(const Duration(seconds: 5));
|
||||||
expect(job.status, TranscriptionStatus.cancelled);
|
expect(job.status, TranscriptionStatus.cancelled);
|
||||||
expect(job.terminal, true);
|
expect(job.terminal, true);
|
||||||
expect(session.subtitleWorkflows.runningCount, 0);
|
expect(session.subtitleWorkflows.runningCount, 0);
|
||||||
|
|||||||
Reference in new issue
Block a user