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

This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
111 lines
3.2 KiB
Dart
111 lines
3.2 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.
|
|
|
|
import 'package:flutter_tools/src/base/io.dart';
|
|
|
|
import '../src/common.dart';
|
|
import 'test_utils.dart';
|
|
|
|
final String toolBackend = fileSystem.path.join(
|
|
getFlutterRoot(),
|
|
'packages',
|
|
'flutter_tools',
|
|
'bin',
|
|
'tool_backend.dart',
|
|
);
|
|
final String examplePath = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
|
|
final String dart = fileSystem.path.join(
|
|
getFlutterRoot(),
|
|
'bin',
|
|
platform.isWindows ? 'dart.bat' : 'dart',
|
|
);
|
|
|
|
void main() {
|
|
testWithoutContext('tool_backend.dart exits if PROJECT_DIR is not set', () async {
|
|
final ProcessResult result = await processManager.run(<String>[
|
|
dart,
|
|
toolBackend,
|
|
'linux-x64',
|
|
'debug',
|
|
]);
|
|
|
|
expect(
|
|
result,
|
|
const ProcessResultMatcher(
|
|
exitCode: 1,
|
|
stderrPattern:
|
|
'PROJECT_DIR environment variable must be set to the location of Flutter project to be built.',
|
|
),
|
|
);
|
|
});
|
|
|
|
testWithoutContext('tool_backend.dart exits if FLUTTER_ROOT is not set', () async {
|
|
// Removing parent environment means that batch script cannot be run.
|
|
final String dart = fileSystem.path.join(
|
|
getFlutterRoot(),
|
|
'bin',
|
|
'cache',
|
|
'dart-sdk',
|
|
'bin',
|
|
platform.isWindows ? 'dart.exe' : 'dart',
|
|
);
|
|
|
|
final ProcessResult result = await processManager.run(
|
|
<String>[dart, toolBackend, 'linux-x64', 'debug'],
|
|
environment: <String, String>{'PROJECT_DIR': examplePath},
|
|
includeParentEnvironment: false,
|
|
); // Prevent FLUTTER_ROOT set by test environment from leaking
|
|
|
|
expect(
|
|
result,
|
|
const ProcessResultMatcher(
|
|
exitCode: 1,
|
|
stderrPattern:
|
|
'FLUTTER_ROOT environment variable must be set to the location of the Flutter SDK.',
|
|
),
|
|
);
|
|
});
|
|
|
|
testWithoutContext('tool_backend.dart exits if local engine does not match build mode', () async {
|
|
final ProcessResult result = await processManager.run(
|
|
<String>[dart, toolBackend, 'linux-x64', 'debug'],
|
|
environment: <String, String>{
|
|
'PROJECT_DIR': examplePath,
|
|
'LOCAL_ENGINE': 'release_foo_bar', // Does not contain "debug",
|
|
},
|
|
);
|
|
|
|
expect(
|
|
result,
|
|
const ProcessResultMatcher(
|
|
exitCode: 1,
|
|
stderrPattern: "ERROR: Requested build with Flutter local engine at 'release_foo_bar'",
|
|
),
|
|
);
|
|
});
|
|
|
|
testWithoutContext(
|
|
'tool_backend.dart exits if local engine host does not match build mode',
|
|
() async {
|
|
final ProcessResult result = await processManager.run(
|
|
<String>[dart, toolBackend, 'linux-x64', 'debug'],
|
|
environment: <String, String>{
|
|
'PROJECT_DIR': examplePath,
|
|
'LOCAL_ENGINE': 'debug_foo_bar', // OK
|
|
'LOCAL_ENGINE_HOST': 'release_foo_bar', // Does not contain "debug",
|
|
},
|
|
);
|
|
|
|
expect(
|
|
result,
|
|
const ProcessResultMatcher(
|
|
exitCode: 1,
|
|
stderrPattern:
|
|
"ERROR: Requested build with Flutter local engine host at 'release_foo_bar'",
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|