Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plumbing flags required for running tests with the DDC module system. #2295

Merged
merged 29 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
61f964b
Updating the legacy loader to use the new DDC module loader API
Markzipan Nov 27, 2023
e17f872
Adding tests and plumbing for the DDC module system.
Markzipan Nov 27, 2023
6a01aad
updating changelog
Markzipan Dec 1, 2023
2e4d0a2
Merge branch 'dart-lang:master' into ddc-test-plumbing
Markzipan Dec 1, 2023
188a5ae
Restructuring asset bundling and flags
Markzipan Dec 4, 2023
c055748
Restructuring asset bundling and flags
Markzipan Dec 4, 2023
cc66e55
Updating test sdk paths
Markzipan Dec 5, 2023
e37da6b
Moving the module format specifier to an enum and unioning static ass…
Markzipan Dec 7, 2023
dcbea77
Fixing analysis errors
Markzipan Dec 7, 2023
40ac194
Exposing utilities/ddc_names.dart
Markzipan Dec 7, 2023
83d5feb
removing extraneous export
Markzipan Dec 7, 2023
6d5bcfe
Fixing race condition without extraneous plumbing.
Markzipan Dec 12, 2023
2cff2ce
Extending tests and restructuring logic into helpers
Markzipan Dec 12, 2023
84ee640
Merge branch 'master' into ddc-test-plumbing
Markzipan Dec 12, 2023
77bd6eb
Extending sdk config tests and moving autorun functionality into the …
Markzipan Dec 13, 2023
43e6446
Merge branch 'master' into ddc-test-plumbing
Markzipan Dec 13, 2023
69fa508
Merge branch 'master' into ddc-test-plumbing
Markzipan Dec 14, 2023
7330d99
Fixing analysis errors
Markzipan Dec 14, 2023
b30a41f
adding missing DDC sound sdks to asset generator test
Markzipan Dec 14, 2023
5b9854e
Fixing ddc and amd paths
Markzipan Dec 14, 2023
c606696
Keeping the first instance of an app connection and extending timeouts
Markzipan Dec 18, 2023
dafca8a
formatting files
Markzipan Dec 19, 2023
819bcf5
Merge remote-tracking branch 'origin' into ddc-test-plumbing
Markzipan Jan 9, 2024
42c674e
Exposing utilities/ddc_names.dart
Markzipan Dec 7, 2023
f4ae7e2
Loosen `vm_service` constraints and prepare DWDS for release to 23.1.…
elliette Jan 9, 2024
4f143c9
Reset DWDS to version `23.2.0-wip` after release (#2334)
elliette Jan 10, 2024
ac28b96
Adding changelog
Markzipan Jan 10, 2024
e4c7df0
Merge remote-tracking branch 'origin/master' into ddc-test-plumbing
Markzipan Jan 10, 2024
dbcb892
Merge remote-tracking branch 'origin' into ddc-test-plumbing
Markzipan Jan 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Add `FrontendServerLegacyStrategyProvider` and update bootstrap generation logic for `LegacyStrategy` - [#2285](https://github.com/dart-lang/webdev/pull/2285)
- Tolerate failures to detect a dart execution context. - [#2286](https://github.com/dart-lang/webdev/pull/2286)
- Fix a null cast error when debugging a `Class` from VS Code. - [#2303](https://github.com/dart-lang/webdev/pull/2303)
- Enabling tests that run with the DDC module system and exposing `utilities/ddc_names.dart` - [#2295](https://github.com/dart-lang/webdev/pull/2295)

## 22.1.0
- Update `package:vm_service` constraint to `^13.0.0`. - [#2265](https://github.com/dart-lang/webdev/pull/2265)
Expand Down
1 change: 1 addition & 0 deletions dwds/lib/expression_compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export 'src/services/expression_compiler.dart'
ExpressionCompilationResult,
ExpressionCompiler,
CompilerOptions,
ModuleFormat,
ModuleInfo;
6 changes: 5 additions & 1 deletion dwds/lib/src/loaders/legacy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ class LegacyStrategy extends LoadStrategy {
return '''
$_baseUrlScript
var scripts = ${const JsonEncoder.withIndent(" ").convert(scripts)};
window.\$dartLoader.loadScripts(scripts);
window.\$dartLoader.loadConfig.loadScriptFn = function(loader) {
loader.addScriptsToQueue(scripts, null);
loader.loadEnqueuedModules();
};
window.\$dartLoader.loader.nextAttempt();
''';
}

Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/services/chrome_proxy_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class ChromeProxyService implements VmServiceInterface {
'with sound null safety: $soundNullSafety');

final compilerOptions = CompilerOptions(
moduleFormat: moduleFormat,
moduleFormat: ModuleFormat.values.byName(moduleFormat),
Markzipan marked this conversation as resolved.
Show resolved Hide resolved
soundNullSafety: soundNullSafety,
canaryFeatures: canaryFeatures,
experiments: experiments,
Expand Down
5 changes: 4 additions & 1 deletion dwds/lib/src/services/expression_compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

/// Options passed to DDC and the expression compiler.
class CompilerOptions {
final String moduleFormat;
final ModuleFormat moduleFormat;
final bool soundNullSafety;
final bool canaryFeatures;
final List<String> experiments;
Expand All @@ -17,6 +17,9 @@ class CompilerOptions {
});
}

/// Indicates the module system DDC is targeting.
enum ModuleFormat { amd, ddc, es6 }

/// Result of compilation of dart expression to JavaScript
class ExpressionCompilationResult {
final bool isError;
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/services/expression_compiler_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class _Compiler {
'--asset-server-port',
'$port',
'--module-format',
compilerOptions.moduleFormat,
compilerOptions.moduleFormat.name,
if (verbose) '--verbose',
compilerOptions.soundNullSafety
? '--sound-null-safety'
Expand Down
5 changes: 5 additions & 0 deletions dwds/lib/utilities.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

export 'src/utilities/ddc_names.dart';
196 changes: 101 additions & 95 deletions dwds/test/devtools_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,110 +32,115 @@ void main() {

final context = TestContext(TestProject.testWithSoundNullSafety, provider);

group('Injected client', () {
setUp(() async {
await context.setUp(
debugSettings: TestDebugSettings.withDevTools(context),
);
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
// Wait for DevTools to actually open.
await Future.delayed(const Duration(seconds: 2));
});

tearDown(() async {
await context.tearDown();
});

test(
'can launch devtools',
() async {
final windows = await context.webDriver.windows.toList();
await context.webDriver.driver.switchTo.window(windows.last);
expect(await context.webDriver.pageSource, contains('DevTools'));
expect(await context.webDriver.currentUrl, contains('ide=Dwds'));
// TODO(https://github.com/dart-lang/webdev/issues/1888): Re-enable.
},
skip: Platform.isWindows,
);

test('can not launch devtools for the same app in multiple tabs', () async {
final appUrl = await context.webDriver.currentUrl;
// Open a new tab, select it, and navigate to the app
await context.webDriver.driver
.execute("window.open('$appUrl', '_blank');", []);
await Future.delayed(const Duration(seconds: 2));
final newAppWindow = await context.webDriver.windows.last;
await newAppWindow.setAsActive();
group(
'Injected client',
() {
setUp(() async {
await context.setUp(
debugSettings: TestDebugSettings.withDevTools(context),
);
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
// Wait for DevTools to actually open.
await Future.delayed(const Duration(seconds: 2));
});

// Wait for the page to be ready before trying to open DevTools again.
await _waitForPageReady(context);
tearDown(() async {
await context.tearDown();
});

// Try to open devtools and check for the alert.
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
await Future.delayed(const Duration(seconds: 2));
final alert = context.webDriver.driver.switchTo.alert;
expect(alert, isNotNull);
expect(
await alert.text,
contains('This app is already being debugged in a different tab'),
test(
'can launch devtools',
() async {
final windows = await context.webDriver.windows.toList();
await context.webDriver.driver.switchTo.window(windows.last);
expect(await context.webDriver.pageSource, contains('DevTools'));
expect(await context.webDriver.currentUrl, contains('ide=Dwds'));
// TODO(https://github.com/dart-lang/webdev/issues/1888): Re-enable.
},
skip: Platform.isWindows,
);
await alert.accept();

var windows = await context.webDriver.windows.toList();
for (final window in windows) {
if (window.id != newAppWindow.id) {
await window.setAsActive();
await window.close();
}
}
test('can not launch devtools for the same app in multiple tabs',
() async {
final appUrl = await context.webDriver.currentUrl;
// Open a new tab, select it, and navigate to the app
await context.webDriver.driver
.execute("window.open('$appUrl', '_blank');", []);
await Future.delayed(const Duration(seconds: 2));
final newAppWindow = await context.webDriver.windows.last;
await newAppWindow.setAsActive();

await newAppWindow.setAsActive();
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
await Future.delayed(const Duration(seconds: 2));
windows = await context.webDriver.windows.toList();
final devToolsWindow =
windows.firstWhere((window) => window != newAppWindow);
await devToolsWindow.setAsActive();
expect(await context.webDriver.pageSource, contains('DevTools'));
});
// Wait for the page to be ready before trying to open DevTools again.
await _waitForPageReady(context);

test(
'destroys and recreates the isolate during a page refresh',
() async {
// This test is the same as one in reload_test, but runs here when there
// is a connected client (DevTools) since it can behave differently.
// https://github.com/dart-lang/webdev/pull/901#issuecomment-586438132
final client = context.debugConnection.vmService;
await client.streamListen('Isolate');
context.makeEditToDartEntryFile(
toReplace: 'Hello World!',
replaceWith: 'Bonjour le monde!',
);
await context.waitForSuccessfulBuild(propagateToBrowser: true);

final eventsDone = expectLater(
client.onIsolateEvent,
emitsThrough(
emitsInOrder([
_hasKind(EventKind.kIsolateExit),
_hasKind(EventKind.kIsolateStart),
_hasKind(EventKind.kIsolateRunnable),
]),
),
// Try to open devtools and check for the alert.
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
await Future.delayed(const Duration(seconds: 2));
final alert = context.webDriver.driver.switchTo.alert;
expect(alert, isNotNull);
expect(
await alert.text,
contains('This app is already being debugged in a different tab'),
);
await alert.accept();

await context.webDriver.driver.refresh();
var windows = await context.webDriver.windows.toList();
for (final window in windows) {
if (window.id != newAppWindow.id) {
await window.setAsActive();
await window.close();
}
}

await eventsDone;
// Re-set the edited file:
context.makeEditToDartEntryFile(
toReplace: 'Bonjour le monde!',
replaceWith: 'Hello World!',
);
},
skip: 'https://github.com/dart-lang/webdev/issues/1888',
);
});
await newAppWindow.setAsActive();
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
await Future.delayed(const Duration(seconds: 2));
windows = await context.webDriver.windows.toList();
final devToolsWindow =
windows.firstWhere((window) => window != newAppWindow);
await devToolsWindow.setAsActive();
expect(await context.webDriver.pageSource, contains('DevTools'));
});

test(
'destroys and recreates the isolate during a page refresh',
() async {
// This test is the same as one in reload_test, but runs here when there
// is a connected client (DevTools) since it can behave differently.
// https://github.com/dart-lang/webdev/pull/901#issuecomment-586438132
final client = context.debugConnection.vmService;
await client.streamListen('Isolate');
context.makeEditToDartEntryFile(
toReplace: 'Hello World!',
replaceWith: 'Bonjour le monde!',
);
await context.waitForSuccessfulBuild(propagateToBrowser: true);

final eventsDone = expectLater(
client.onIsolateEvent,
emitsThrough(
emitsInOrder([
_hasKind(EventKind.kIsolateExit),
_hasKind(EventKind.kIsolateStart),
_hasKind(EventKind.kIsolateRunnable),
]),
),
);

await context.webDriver.driver.refresh();

await eventsDone;
// Re-set the edited file:
context.makeEditToDartEntryFile(
toReplace: 'Bonjour le monde!',
replaceWith: 'Hello World!',
);
},
skip: 'https://github.com/dart-lang/webdev/issues/1888',
);
},
timeout: Timeout.factor(2),
);

group('Injected client without a DevTools server', () {
setUp(() async {
Expand Down Expand Up @@ -193,6 +198,7 @@ void main() {
},
tags: ['extension'],
skip: 'https://github.com/dart-lang/webdev/issues/2114',
timeout: Timeout.factor(2),
);
}

Expand Down
2 changes: 2 additions & 0 deletions dwds/test/evaluate_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void testAll({
await context.setUp(
testSettings: TestSettings(
compilationMode: compilationMode,
moduleFormat: provider.ddcModuleFormat,
enableExpressionEvaluation: true,
useDebuggerModuleNames: useDebuggerModuleNames,
verboseCompiler: debug,
Expand Down Expand Up @@ -821,6 +822,7 @@ void testAll({
await context.setUp(
testSettings: TestSettings(
compilationMode: compilationMode,
moduleFormat: provider.ddcModuleFormat,
enableExpressionEvaluation: false,
verboseCompiler: debug,
),
Expand Down
2 changes: 1 addition & 1 deletion dwds/test/expression_compiler_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void main() async {
);

final compilerOptions = CompilerOptions(
moduleFormat: 'amd',
moduleFormat: ModuleFormat.amd,
soundNullSafety: true,
canaryFeatures: false,
experiments: const <String>[],
Expand Down
Loading
Loading