Skip to content

Commit

Permalink
Merge branch 'master' of github.com:flutter/devtools into perf
Browse files Browse the repository at this point in the history
  • Loading branch information
polina-c committed Sep 28, 2024
2 parents 7dfab2f + f1117d3 commit 7e0eb83
Show file tree
Hide file tree
Showing 150 changed files with 3,533 additions and 1,893 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ jobs:
wget -qO- https://dcm.dev/pgp-key.public | sudo gpg --dearmor -o /usr/share/keyrings/dcm.gpg
echo 'deb [signed-by=/usr/share/keyrings/dcm.gpg arch=amd64] https://dcm.dev/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list
sudo apt-get update
sudo apt-get install dcm=1.18.1-1 # To avoid errors add `-1` (build number) to the version
sudo apt-get install dcm=1.22.0-1 # To avoid errors add `-1` (build number) to the version
sudo chmod +x /usr/bin/dcm
echo "$(dcm --version)"
- name: Setup Dart SDK
uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
- name: Run DCM on root
run: |
dcm analyze packages/devtools_app packages/devtools_shared packages/devtools_test
dcm analyze packages/devtools_app packages/devtools_app_shared packages/devtools_extensions packages/devtools_shared packages/devtools_test
test-packages:
name: ${{ matrix.package }} test
Expand Down
35 changes: 20 additions & 15 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Testing for DevTools
=======================
# Testing for DevTools

DevTools is test covered by multiple types of tests, all of which are run on the CI for each DevTools PR / commit:

Expand All @@ -24,15 +23,21 @@ before writing new integration tests, which are slower to run and are not as eas
Before running tests, make sure your Flutter SDK matches the version that will be used on
the CI. To update your local flutter version, run:

```shell
devtools_tool update-flutter-sdk --update-on-path
```
./tool/update_flutter_sdk.sh --local

> Note: Running this command requires that you have followed the [set up instructions](CONTRIBUTING.md#set-up-your-devtools-environment) in the DevTools contributing guide regarding cloning the Flutter SDK from GitHub, adding the `devtools_tool` executable to your PATH, and running `dart pub get` in the `tool` directory.
You may need to re-generate the testing mocks before running the tests:

```shell
devtools_tool generate-code --upgrade
```
> Note: Running this command requires that you have followed the [set up instructions](CONTRIBUTING.md#set-up-your-devtools-environment)
in the DevTools contributing guide regarding cloning the Flutter SDK from GitHub.

Now you can proceed with running DevTools tests:

```
```shell
cd packages/devtools_app
flutter test test/
```
Expand All @@ -51,11 +56,11 @@ For valid golden image updates (1 and 2 above), the failing golden images will n
be done in one of two ways:

1. If the tests failed on the CI for a PR, we can download the generated golden images directly from GitHub.
> If you are developing on a non-MacOS machine, this is the only way you'll be able to update the golden images.
- Natvigate to the failed Actions run for your PR on GitHub. Example:
> If you are developing on a non-MacOS machine, this is the only way you'll be able to update the golden images.
- Navigate to the failed Actions run for your PR on GitHub. Example:

![Failed actions run](_markdown_images/failed_actions_run.png)

- Scroll to the bottom of the Summary view to see the errors from the `macos goldens` job, and the notice containing the golden update command:

![Failed goldens notice](_markdown_images/failed_goldens_notice.png)
Expand All @@ -65,18 +70,19 @@ be done in one of two ways:
- Before updating the goldens, ensure your version of Flutter matches the version of Flutter that is used
on the CI. To update your local flutter version, run:

```
./tool/update_flutter_sdk.sh --local
```shell
devtools_tool update-flutter-sdk --update-on-path
```

- Then proceed with updating the goldens:

```
```shell
flutter test <path/to/my/test> --update-goldens
```

or to update goldens for all tests:
```

```shell
flutter test test/ --update-goldens
```

Expand All @@ -85,7 +91,6 @@ be done in one of two ways:
When you add a new feature or fix a bug, please add a corresponding test for your change.

- If there is an existing test file for the feature your code touches, you can add the test case
there.
there.
- Otherwise, create a new test file with the `_test.dart` suffix, and place it in an appropriate
location under the `test/` directory for the DevTools package you are working on.

2 changes: 1 addition & 1 deletion flutter-candidate.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b74fa8afc7e2365f96098e6ff0fb150beb22682a
8925e1ffdfe880b06a8bc5877f017083d6652f5b
4 changes: 4 additions & 0 deletions packages/devtools_app/benchmark/devtools_benchmarks_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ void main() {
await _runBenchmarks(useWasm: useWasm);
},
timeout: const Timeout(Duration(minutes: 10)),
// TODO(https://github.com/dart-lang/sdk/issues/56664): unskip the wasm
// benchmarks once this issue is resolved and we can bump DevTools to a
// version of Flutter that includes the fix.
skip: useWasm,
);
}

Expand Down
21 changes: 12 additions & 9 deletions packages/devtools_app/integration_test/run_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ import 'test_infra/run/run_test.dart';
const _testDirectory = 'integration_test/test';
const _offlineIndicator = 'integration_test/test/offline';

/// The key in [_skipTestsForDevice] that will hold a set of tests that should
/// The key in [_disabledTestsForDevice] that will hold a set of tests that should
/// be skipped for all test devices.
const _testDeviceAll = 'all';

/// The set of tests that should be skipped for each type of test target.
/// The set of tests that are temporarily disabled for each type of test device.
///
/// This list should be empty most of the time, but may contain a broken test
/// while a fix being worked on.
///
/// Format: `'my_example_test.dart'`.
final _skipTestsForDevice = <String, Set<String>>{
final _disabledTestsForDevice = <String, Set<String>>{
_testDeviceAll: {
// https://github.com/flutter/devtools/issues/6592
'eval_and_browse_test.dart',
Expand Down Expand Up @@ -67,14 +67,17 @@ Future<void> _runTest(
final testTarget = testRunnerArgs.testTarget!;
final testDevice = testRunnerArgs.testAppDevice.name;

final skipAll = _skipTestsForDevice[_testDeviceAll]!;
final skipForDevice = _skipTestsForDevice[testDevice] ?? {};
final shouldSkip =
{...skipAll, ...skipForDevice}.any((t) => testTarget.endsWith(t));
if (shouldSkip) return;
final disabledForAllDevices = _disabledTestsForDevice[_testDeviceAll]!;
final disabledForDevice = _disabledTestsForDevice[testDevice] ?? {};
final disabled = {...disabledForAllDevices, ...disabledForDevice}
.any((t) => testTarget.endsWith(t));
if (disabled) {
debugLog('Disabled test - skipping $testTarget for $testDevice.');
return;
}

if (!testRunnerArgs.testAppDevice.supportsTest(testTarget)) {
// Skip test, since it is not supported for device.
debugLog('Unsupported test - skipping $testTarget for $testDevice.');
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ Future<void> runFlutterIntegrationTest(

if (!offline) {
if (testRunnerArgs.testAppUri == null) {
debugLog('Starting a test application');
// Create the test app and start it.
try {
if (testRunnerArgs.testAppDevice == TestAppDevice.cli) {
debugLog(
'Creating a TestDartCliApp with path ${testFileArgs.appPath}',
'creating a TestDartCliApp with path ${testFileArgs.appPath}',
);
testApp = TestDartCliApp(appPath: testFileArgs.appPath);
} else {
debugLog(
'Creating a TestFlutterApp with path ${testFileArgs.appPath} and '
'creating a TestFlutterApp with path ${testFileArgs.appPath} and '
'device ${testRunnerArgs.testAppDevice}',
);
testApp = TestFlutterApp(
appPath: testFileArgs.appPath,
appDevice: testRunnerArgs.testAppDevice,
);
}
debugLog('starting the test app');
await testApp.start();
} catch (e) {
// ignore: avoid-throw-in-catch-block, by design
Expand All @@ -63,8 +63,10 @@ Future<void> runFlutterIntegrationTest(
final testArgs = <String, Object>{
if (!offline) 'service_uri': testAppUri,
};
final testTarget = testRunnerArgs.testTarget!;
debugLog('starting test run for $testTarget');
await testRunner.run(
testRunnerArgs.testTarget!,
testTarget,
testDriver: 'test_driver/integration_test.dart',
headless: testRunnerArgs.headless,
dartDefineArgs: [
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools_app/lib/devtools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
// the constant declaration `const version =`.
// If you change the declaration you must also modify the regex in
// tools/update_version.dart.
const version = '2.39.0-dev.18';
const version = '2.40.0-dev.2';
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:web/web.dart';
import '../../shared/development_helpers.dart';
import '../../shared/globals.dart';
import '../../shared/primitives/utils.dart';
import '../../shared/query_parameters.dart';
import '../../shared/server/server.dart';
import '../../shared/utils.dart';
import 'controller.dart';
Expand Down Expand Up @@ -55,7 +56,7 @@ class EmbeddedExtensionControllerImpl extends EmbeddedExtensionController
'index.html',
);
final queryParams = {
...loadQueryParams(),
...DevToolsQueryParams.load().params,
ExtensionEventParameters.theme: isDarkThemeEnabled()
? ExtensionEventParameters.themeValueDark
: ExtensionEventParameters.themeValueLight,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@ class _ExtensionIFrameController extends DisposableController
final message = event.toJson();
assert(
embeddedExtensionController.extensionIFrame.contentWindow != null,
'Something went wrong. The iFrame\'s contentWindow is null after the'
' _iFrameReady future completed.',
'Something went wrong. The '
'${embeddedExtensionController.extensionConfig.name} extension\'s iFrame '
'contentWindow is null after the _iFrameReady future completed. The '
'message that was being posted when the error occurred was:\n'
'${message.toString()}',
);
embeddedExtensionController.extensionIFrame.contentWindow!.postMessage(
message.jsify(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ void setupErrorHandling(Future Function() appStartCallback) {
return appStartCallback();
},
(Object error, StackTrace stack) {
// TODO(https://github.com/flutter/devtools/issues/7856): can we detect
// severe errors here that are related to dart2wasm? Otherwise we may
// crash DevTools for the user without any way for them to force reload
// with JS.
reportError(error, stack: stack, errorType: 'zoneGuarded');
throw error;
},
Expand Down
7 changes: 5 additions & 2 deletions packages/devtools_app/lib/src/framework/framework_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:devtools_app_shared/ui.dart';
import 'package:devtools_app_shared/utils.dart';
import 'package:devtools_shared/devtools_shared.dart';
import 'package:devtools_shared/service.dart';
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
import 'package:vm_service/vm_service.dart';

Expand Down Expand Up @@ -46,8 +47,10 @@ abstract class FrameworkCore {

await initializePlatform();

// Print the version number at startup.
_log.info('DevTools version $devToolsVersion.');
// Print DevTools info at startup.
_log.info(
'Version: $devToolsVersion, Renderer: ${kIsWasm ? 'skwasm' : 'canvaskit'}',
);

await _initDTDConnection();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class ReleaseNotesController extends SidePanelController {
if (server.isDevToolsServerAvailable) {
final lastReleaseNotesShownVersion =
await server.getLastShownReleaseNotesVersion();
_log.fine('lastReleaseNotesShownVersion: $lastReleaseNotesShownVersion');
if (lastReleaseNotesShownVersion.isNotEmpty) {
previousVersion = SemanticVersion.parse(lastReleaseNotesShownVersion);
}
Expand Down Expand Up @@ -119,10 +120,16 @@ class ReleaseNotesController extends SidePanelController {
// strip off any build metadata (any characters following a '+' character).
// Release notes will be hosted on the Flutter website with a version number
// that does not contain any build metadata.
final parsedVersion = SemanticVersion.parse(devToolsVersion);
final notesVersion = latestVersionToCheckForReleaseNotes(parsedVersion);
final parsedDevToolsVersion = SemanticVersion.parse(devToolsVersion);
final checkVersion =
latestVersionToCheckForReleaseNotes(parsedDevToolsVersion);

if (notesVersion <= versionFloor) {
_log.fine(
'attempting to fetch and show release notes for DevTools $checkVersion '
'with version floor $versionFloor.',
);

if (checkVersion <= versionFloor) {
// If the current version is equal to or below the version floor,
// no need to show the release notes.
_emptyAndClose();
Expand All @@ -134,23 +141,30 @@ class ReleaseNotesController extends SidePanelController {
return;
}

// If the version floor has the same major and minor version,
// don't check below its patch version.
// If the version floor has the same major and minor version as the version
// we are checking for, don't check below the version floor's patch version.
final int minimumPatch;
if (versionFloor.major == notesVersion.major &&
versionFloor.minor == notesVersion.minor) {
if (versionFloor.major == checkVersion.major &&
versionFloor.minor == checkVersion.minor) {
minimumPatch = versionFloor.patch;
} else {
minimumPatch = 0;
}

final majorMinor = '${notesVersion.major}.${notesVersion.minor}';
var patchToCheck = notesVersion.patch;
final majorMinor = '${checkVersion.major}.${checkVersion.minor}';
var patchToCheck = checkVersion.patch;

// Try each patch version in this major.minor combination until we find
// release notes (e.g. 2.11.4 -> 2.11.3 -> 2.11.2 -> ...).
while (patchToCheck >= minimumPatch) {
final releaseToCheck = '$majorMinor.$patchToCheck';

final releaseToCheckVersion = SemanticVersion.parse(releaseToCheck);
if (releaseToCheckVersion <= versionFloor) {
_emptyAndClose();
return;
}

if (releases[releaseToCheck] case final releaseNotePath?) {
final String releaseNotesMarkdown;
try {
Expand All @@ -175,8 +189,7 @@ class ReleaseNotesController extends SidePanelController {

toggleVisibility(true);
if (server.isDevToolsServerAvailable) {
// Only set the last release notes version
// if we are not debugging.
// Only set the last release notes version if we are not debugging.
unawaited(
server.setLastShownReleaseNotesVersion(releaseToCheck),
);
Expand All @@ -188,7 +201,7 @@ class ReleaseNotesController extends SidePanelController {
}

_emptyAndClose(
'Could not find release notes for DevTools version $notesVersion.',
'Could not find release notes for DevTools version $checkVersion.',
);
return;
}
Expand Down
Loading

0 comments on commit 7e0eb83

Please sign in to comment.