[flutter_tools] Reland: fix multiple dart defines (#54973)
This commit is contained in:
@@ -360,12 +360,14 @@ void main() {
|
||||
|
||||
test('Dart2JSTarget calls dart2js with Dart defines in release mode', () => testbed.run(() async {
|
||||
environment.defines[kBuildMode] = 'release';
|
||||
environment.defines[kDartDefines] = '["FOO=bar","BAZ=qux"]';
|
||||
environment.defines[kDartDefines] = 'FOO=bar,BAZ=qux';
|
||||
processManager.addCommand(FakeCommand(
|
||||
command: <String>[
|
||||
...kDart2jsLinuxArgs,
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
'-DFOO=bar',
|
||||
'-DBAZ=qux',
|
||||
'--packages=${globals.fs.path.join('foo', '.packages')}',
|
||||
'--cfe-only',
|
||||
environment.buildDir.childFile('main.dart').absolute.path,
|
||||
@@ -391,12 +393,14 @@ void main() {
|
||||
|
||||
test('Dart2JSTarget calls dart2js with Dart defines in profile mode', () => testbed.run(() async {
|
||||
environment.defines[kBuildMode] = 'profile';
|
||||
environment.defines[kDartDefines] = '["FOO=bar","BAZ=qux"]';
|
||||
environment.defines[kDartDefines] = 'FOO=bar,BAZ=qux';
|
||||
processManager.addCommand(FakeCommand(
|
||||
command: <String>[
|
||||
...kDart2jsLinuxArgs,
|
||||
'-o',
|
||||
environment.buildDir.childFile('app.dill').absolute.path,
|
||||
'-DFOO=bar',
|
||||
'-DBAZ=qux',
|
||||
'--packages=${globals.fs.path.join('foo', '.packages')}',
|
||||
'--cfe-only',
|
||||
environment.buildDir.childFile('main.dart').absolute.path,
|
||||
@@ -421,27 +425,6 @@ void main() {
|
||||
ProcessManager: () => processManager,
|
||||
}));
|
||||
|
||||
test('Dart2JSTarget throws developer-friendly exception on misformatted DartDefines', () => testbed.run(() async {
|
||||
environment.defines[kBuildMode] = 'profile';
|
||||
environment.defines[kDartDefines] = '[misformatted json';
|
||||
try {
|
||||
await const Dart2JSTarget().build(environment);
|
||||
fail('Call to build() must not have succeeded.');
|
||||
} on Exception catch(exception) {
|
||||
expect(
|
||||
'$exception',
|
||||
'Exception: The value of -D$kDartDefines is not formatted correctly.\n'
|
||||
'The value must be a JSON-encoded list of strings but was:\n'
|
||||
'[misformatted json',
|
||||
);
|
||||
}
|
||||
|
||||
// Should not attempt to run any processes.
|
||||
verifyNever(globals.processManager.run(any));
|
||||
}, overrides: <Type, Generator>{
|
||||
ProcessManager: () => MockProcessManager(),
|
||||
}));
|
||||
|
||||
test('Generated service worker correctly inlines file hashes', () {
|
||||
final String result = generateServiceWorker(<String, String>{'/foo': 'abcd'});
|
||||
|
||||
|
||||
@@ -109,7 +109,8 @@ void main() {
|
||||
});
|
||||
|
||||
testUsingContext('build aot outputs timing info', () async {
|
||||
globals.fs.file('.dart_tool/flutter_build/cce09742720db17ffec62331bd7e42d5/app.so')
|
||||
globals.fs
|
||||
.file('.dart_tool/flutter_build/0c21fd4ab3b8bde8b385ff01d08e0093/app.so')
|
||||
.createSync(recursive: true);
|
||||
when(globals.buildSystem.build(any, any))
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
|
||||
Reference in New Issue
Block a user