mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Closes https://github.com/flutter/flutter/issues/169598 (which explains
the integration test failure).
Closes https://github.com/flutter/flutter/issues/169160.
Closes https://github.com/flutter/flutter/issues/165803.
This is the only diff from 5d013c73ba
:
```diff
diff --git a/packages/flutter_tools/lib/src/build_system/targets/common.dart b/packages/flutter_tools/lib/src/build_system/targets/common.dart
index 61583210e47..67731019a05 100644
--- a/packages/flutter_tools/lib/src/build_system/targets/common.dart
+++ b/packages/flutter_tools/lib/src/build_system/targets/common.dart
@@ -308,10 +308,18 @@ class KernelSnapshot extends Target {
if (flavor == null) {
return;
}
- if (!dartDefines.any((String element) => element.startsWith(kAppFlavor))) {
- // If the flavor is not already in the dart defines, add it.
- dartDefines.add('$kAppFlavor=$flavor');
- }
+
+ // It is possible there is a flavor already in dartDefines, from another
+ // part of the build process, but this should take precedence as it happens
+ // last (xcodebuild execution).
+ //
+ // See https://github.com/flutter/flutter/issues/169598.
+
+ // If the flavor is already in the dart defines, remove it.
+ dartDefines.removeWhere((String define) => define.startsWith(kAppFlavor));
+
+ // Then, add it to the end.
+ dartDefines.add('$kAppFlavor=$flavor');
}
}
```
75 lines
1.7 KiB
Dart
75 lines
1.7 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
@Tags(<String>['flutter-test-driver'])
|
|
library;
|
|
|
|
import 'package:flutter_tools/src/base/file_system.dart';
|
|
|
|
import '../src/common.dart';
|
|
import 'test_data/project.dart';
|
|
import 'test_driver.dart';
|
|
import 'test_utils.dart';
|
|
|
|
void main() {
|
|
final Project project = _DefaultFlavorProject();
|
|
late Directory tempDir;
|
|
late FlutterTestTestDriver flutter;
|
|
|
|
setUp(() async {
|
|
tempDir = createResolvedTempDirectorySync('default_flavor_test.');
|
|
await project.setUpIn(tempDir);
|
|
flutter = FlutterTestTestDriver(tempDir);
|
|
});
|
|
|
|
tearDown(() async {
|
|
tryToDelete(tempDir);
|
|
});
|
|
|
|
testWithoutContext('Reads "default-flavor" in "flutter test"', () async {
|
|
await flutter.test();
|
|
|
|
// Without an assertion, this test always passes.
|
|
final int? exitCode = await flutter.done;
|
|
expect(exitCode, 0, reason: 'flutter test failed with exit code $exitCode');
|
|
});
|
|
}
|
|
|
|
final class _DefaultFlavorProject extends Project {
|
|
@override
|
|
final String main = r'''
|
|
// Irrelevant to this test.
|
|
void main() {}
|
|
''';
|
|
|
|
@override
|
|
final String pubspec = r'''
|
|
name: test
|
|
environment:
|
|
sdk: ^3.7.0-0
|
|
|
|
flutter:
|
|
default-flavor: dev
|
|
|
|
dependencies:
|
|
flutter:
|
|
sdk: flutter
|
|
dev_dependencies:
|
|
flutter_test:
|
|
sdk: flutter
|
|
''';
|
|
|
|
@override
|
|
final String test = r'''
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
test('receives default-flavor with flutter test', () async {
|
|
expect(appFlavor, 'dev');
|
|
});
|
|
}
|
|
''';
|
|
}
|