|
|
|
|
@@ -4,10 +4,10 @@
|
|
|
|
|
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
|
|
import 'package:file/memory.dart';
|
|
|
|
|
import 'package:flutter_tools/src/artifacts.dart';
|
|
|
|
|
import 'package:flutter_tools/src/base/io.dart';
|
|
|
|
|
import 'package:flutter_tools/src/base/logger.dart';
|
|
|
|
|
import 'package:flutter_tools/src/base/platform.dart';
|
|
|
|
|
import 'package:flutter_tools/src/base/terminal.dart';
|
|
|
|
|
import 'package:flutter_tools/src/build_info.dart';
|
|
|
|
|
import 'package:flutter_tools/src/compile.dart';
|
|
|
|
|
import 'package:flutter_tools/src/convert.dart';
|
|
|
|
|
@@ -47,22 +47,14 @@ void main() {
|
|
|
|
|
when(mockFrontendServer.exitCode).thenAnswer((_) async => 0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWithoutContext('batch compile single dart successful compilation', () async {
|
|
|
|
|
testUsingContext('batch compile single dart successful compilation', () async {
|
|
|
|
|
when(mockFrontendServer.stdout)
|
|
|
|
|
.thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
|
|
|
|
|
Future<List<int>>.value(utf8.encode(
|
|
|
|
|
'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0'
|
|
|
|
|
))
|
|
|
|
|
));
|
|
|
|
|
final BufferLogger logger = BufferLogger.test();
|
|
|
|
|
final KernelCompiler kernelCompiler = KernelCompiler(
|
|
|
|
|
artifacts: Artifacts.test(),
|
|
|
|
|
fileSystem: MemoryFileSystem.test(),
|
|
|
|
|
fileSystemRoots: <String>[],
|
|
|
|
|
fileSystemScheme: '',
|
|
|
|
|
logger: logger,
|
|
|
|
|
processManager: mockProcessManager
|
|
|
|
|
);
|
|
|
|
|
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null);
|
|
|
|
|
final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
|
|
|
|
|
mainPath: '/path/to/main.dart',
|
|
|
|
|
buildMode: BuildMode.debug,
|
|
|
|
|
@@ -73,29 +65,27 @@ void main() {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
|
|
|
|
|
expect(logger.errorText, equals('line1\nline2\n'));
|
|
|
|
|
expect(testLogger.errorText, equals('line1\nline2\n'));
|
|
|
|
|
expect(output.outputFilename, equals('/path/to/main.dart.dill'));
|
|
|
|
|
final VerificationResult argVerification = verify(mockProcessManager.start(captureAny));
|
|
|
|
|
expect(argVerification.captured.single, containsAll(<String>[
|
|
|
|
|
'-Ddart.developer.causal_async_stacks=true',
|
|
|
|
|
]));
|
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
|
ProcessManager: () => mockProcessManager,
|
|
|
|
|
OutputPreferences: () => OutputPreferences(showColor: false),
|
|
|
|
|
Platform: kNoColorTerminalPlatform,
|
|
|
|
|
Artifacts: () => Artifacts.test(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWithoutContext('passes correct AOT config to kernel compiler in aot/profile mode', () async {
|
|
|
|
|
testUsingContext('passes correct AOT config to kernel compiler in aot/profile mode', () async {
|
|
|
|
|
when(mockFrontendServer.stdout)
|
|
|
|
|
.thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
|
|
|
|
|
Future<List<int>>.value(utf8.encode(
|
|
|
|
|
'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0'
|
|
|
|
|
))
|
|
|
|
|
));
|
|
|
|
|
final KernelCompiler kernelCompiler = KernelCompiler(
|
|
|
|
|
artifacts: Artifacts.test(),
|
|
|
|
|
fileSystem: MemoryFileSystem.test(),
|
|
|
|
|
fileSystemRoots: <String>[],
|
|
|
|
|
fileSystemScheme: '',
|
|
|
|
|
logger: BufferLogger.test(),
|
|
|
|
|
processManager: mockProcessManager
|
|
|
|
|
);
|
|
|
|
|
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null);
|
|
|
|
|
await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
|
|
|
|
|
mainPath: '/path/to/main.dart',
|
|
|
|
|
buildMode: BuildMode.profile,
|
|
|
|
|
@@ -116,23 +106,22 @@ void main() {
|
|
|
|
|
'--bytecode-options=source-positions',
|
|
|
|
|
'-Ddart.developer.causal_async_stacks=false',
|
|
|
|
|
]));
|
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
|
ProcessManager: () => mockProcessManager,
|
|
|
|
|
OutputPreferences: () => OutputPreferences(showColor: false),
|
|
|
|
|
Platform: kNoColorTerminalPlatform,
|
|
|
|
|
Artifacts: () => Artifacts.test(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWithoutContext('passes correct AOT config to kernel compiler in aot/release mode', () async {
|
|
|
|
|
|
|
|
|
|
testUsingContext('passes correct AOT config to kernel compiler in aot/release mode', () async {
|
|
|
|
|
when(mockFrontendServer.stdout)
|
|
|
|
|
.thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
|
|
|
|
|
Future<List<int>>.value(utf8.encode(
|
|
|
|
|
'result abc\nline1\nline2\nabc\nabc /path/to/main.dart.dill 0'
|
|
|
|
|
))
|
|
|
|
|
));
|
|
|
|
|
final KernelCompiler kernelCompiler = KernelCompiler(
|
|
|
|
|
artifacts: Artifacts.test(),
|
|
|
|
|
fileSystem: MemoryFileSystem.test(),
|
|
|
|
|
fileSystemRoots: <String>[],
|
|
|
|
|
fileSystemScheme: '',
|
|
|
|
|
logger: BufferLogger.test(),
|
|
|
|
|
processManager: mockProcessManager
|
|
|
|
|
);
|
|
|
|
|
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null);
|
|
|
|
|
await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
|
|
|
|
|
mainPath: '/path/to/main.dart',
|
|
|
|
|
buildMode: BuildMode.release,
|
|
|
|
|
@@ -153,24 +142,21 @@ void main() {
|
|
|
|
|
'--bytecode-options=source-positions',
|
|
|
|
|
'-Ddart.developer.causal_async_stacks=false',
|
|
|
|
|
]));
|
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
|
ProcessManager: () => mockProcessManager,
|
|
|
|
|
OutputPreferences: () => OutputPreferences(showColor: false),
|
|
|
|
|
Platform: kNoColorTerminalPlatform,
|
|
|
|
|
Artifacts: () => Artifacts.test(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWithoutContext('batch compile single dart failed compilation', () async {
|
|
|
|
|
testUsingContext('batch compile single dart failed compilation', () async {
|
|
|
|
|
when(mockFrontendServer.stdout)
|
|
|
|
|
.thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
|
|
|
|
|
Future<List<int>>.value(utf8.encode(
|
|
|
|
|
'result abc\nline1\nline2\nabc\nabc'
|
|
|
|
|
))
|
|
|
|
|
));
|
|
|
|
|
final BufferLogger logger = BufferLogger.test();
|
|
|
|
|
final KernelCompiler kernelCompiler = KernelCompiler(
|
|
|
|
|
artifacts: Artifacts.test(),
|
|
|
|
|
fileSystem: MemoryFileSystem.test(),
|
|
|
|
|
fileSystemRoots: <String>[],
|
|
|
|
|
fileSystemScheme: '',
|
|
|
|
|
logger: logger,
|
|
|
|
|
processManager: mockProcessManager
|
|
|
|
|
);
|
|
|
|
|
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null);
|
|
|
|
|
final CompilerOutput output = await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
|
|
|
|
|
mainPath: '/path/to/main.dart',
|
|
|
|
|
buildMode: BuildMode.debug,
|
|
|
|
|
@@ -181,27 +167,25 @@ void main() {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
|
|
|
|
|
expect(logger.errorText, equals('line1\nline2\n'));
|
|
|
|
|
expect(testLogger.errorText, equals('line1\nline2\n'));
|
|
|
|
|
expect(output, equals(null));
|
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
|
ProcessManager: () => mockProcessManager,
|
|
|
|
|
OutputPreferences: () => OutputPreferences(showColor: false),
|
|
|
|
|
Platform: kNoColorTerminalPlatform,
|
|
|
|
|
Artifacts: () => Artifacts.test(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWithoutContext('batch compile single dart abnormal compiler termination', () async {
|
|
|
|
|
testUsingContext('batch compile single dart abnormal compiler termination', () async {
|
|
|
|
|
when(mockFrontendServer.exitCode).thenAnswer((_) async => 255);
|
|
|
|
|
|
|
|
|
|
when(mockFrontendServer.stdout)
|
|
|
|
|
.thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
|
|
|
|
|
Future<List<int>>.value(utf8.encode(
|
|
|
|
|
'result abc\nline1\nline2\nabc\nabc'
|
|
|
|
|
))
|
|
|
|
|
));
|
|
|
|
|
final BufferLogger logger = BufferLogger.test();
|
|
|
|
|
final KernelCompiler kernelCompiler = KernelCompiler(
|
|
|
|
|
artifacts: Artifacts.test(),
|
|
|
|
|
fileSystem: MemoryFileSystem.test(),
|
|
|
|
|
fileSystemRoots: <String>[],
|
|
|
|
|
fileSystemScheme: '',
|
|
|
|
|
logger: logger,
|
|
|
|
|
processManager: mockProcessManager
|
|
|
|
|
);
|
|
|
|
|
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null);
|
|
|
|
|
final CompilerOutput output = await kernelCompiler.compile(
|
|
|
|
|
sdkRoot: '/path/to/sdkroot',
|
|
|
|
|
mainPath: '/path/to/main.dart',
|
|
|
|
|
@@ -212,24 +196,22 @@ void main() {
|
|
|
|
|
packagesPath: '.packages',
|
|
|
|
|
);
|
|
|
|
|
expect(mockFrontendServerStdIn.getAndClear(), isEmpty);
|
|
|
|
|
expect(logger.errorText, equals('line1\nline2\n'));
|
|
|
|
|
expect(testLogger.errorText, equals('line1\nline2\n'));
|
|
|
|
|
expect(output, equals(null));
|
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
|
ProcessManager: () => mockProcessManager,
|
|
|
|
|
OutputPreferences: () => OutputPreferences(showColor: false),
|
|
|
|
|
Platform: kNoColorTerminalPlatform,
|
|
|
|
|
Artifacts: () => Artifacts.test(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWithoutContext('passes dartDefines to the kernel compiler', () async {
|
|
|
|
|
testUsingContext('passes dartDefines to the kernel compiler', () async {
|
|
|
|
|
// Use unsuccessful result because it's easier to setup in test. We only care about arguments passed to the compiler.
|
|
|
|
|
when(mockFrontendServer.exitCode).thenAnswer((_) async => 255);
|
|
|
|
|
when(mockFrontendServer.stdout).thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
|
|
|
|
|
Future<List<int>>.value(<int>[])
|
|
|
|
|
));
|
|
|
|
|
final KernelCompiler kernelCompiler = KernelCompiler(
|
|
|
|
|
artifacts: Artifacts.test(),
|
|
|
|
|
fileSystem: MemoryFileSystem.test(),
|
|
|
|
|
fileSystemRoots: <String>[],
|
|
|
|
|
fileSystemScheme: '',
|
|
|
|
|
logger: BufferLogger.test(),
|
|
|
|
|
processManager: mockProcessManager
|
|
|
|
|
);
|
|
|
|
|
final KernelCompiler kernelCompiler = await kernelCompilerFactory.create(null);
|
|
|
|
|
await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
|
|
|
|
|
mainPath: '/path/to/main.dart',
|
|
|
|
|
buildMode: BuildMode.debug,
|
|
|
|
|
@@ -240,34 +222,11 @@ void main() {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(latestCommand, containsAllInOrder(<String>['-DFOO=bar', '-DBAZ=qux']));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWithoutContext('maps a file to a multiroot scheme if providfed', () async {
|
|
|
|
|
// Use unsuccessful result because it's easier to setup in test. We only care about arguments passed to the compiler.
|
|
|
|
|
when(mockFrontendServer.exitCode).thenAnswer((_) async => 255);
|
|
|
|
|
when(mockFrontendServer.stdout).thenAnswer((Invocation invocation) => Stream<List<int>>.fromFuture(
|
|
|
|
|
Future<List<int>>.value(<int>[])
|
|
|
|
|
));
|
|
|
|
|
final KernelCompiler kernelCompiler = KernelCompiler(
|
|
|
|
|
artifacts: Artifacts.test(),
|
|
|
|
|
fileSystem: MemoryFileSystem.test(),
|
|
|
|
|
fileSystemRoots: <String>[
|
|
|
|
|
'/foo/bar/fizz',
|
|
|
|
|
],
|
|
|
|
|
fileSystemScheme: 'scheme',
|
|
|
|
|
logger: BufferLogger.test(),
|
|
|
|
|
processManager: mockProcessManager
|
|
|
|
|
);
|
|
|
|
|
await kernelCompiler.compile(sdkRoot: '/path/to/sdkroot',
|
|
|
|
|
mainPath: '/foo/bar/fizz/main.dart',
|
|
|
|
|
buildMode: BuildMode.debug,
|
|
|
|
|
trackWidgetCreation: false,
|
|
|
|
|
dartDefines: const <String>[],
|
|
|
|
|
packageConfig: PackageConfig.empty,
|
|
|
|
|
packagesPath: '.packages',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(latestCommand, containsAll(<String>['scheme:///main.dart']));
|
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
|
ProcessManager: () => mockProcessManager,
|
|
|
|
|
OutputPreferences: () => OutputPreferences(showColor: false),
|
|
|
|
|
Platform: kNoColorTerminalPlatform,
|
|
|
|
|
Artifacts: () => Artifacts.test(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|