Skip to content

Commit 10131b1

Browse files
Markzipanelliette
andauthored
Plumbing flags required for running tests with the DDC module system. (#2295)
* Updating the legacy loader to use the new DDC module loader API * Adding tests and plumbing for the DDC module system. * updating changelog * Restructuring asset bundling and flags * Restructuring asset bundling and flags * Updating test sdk paths * Moving the module format specifier to an enum and unioning static assets across module formats * Fixing analysis errors * Exposing utilities/ddc_names.dart * removing extraneous export * Fixing race condition without extraneous plumbing. * Extending tests and restructuring logic into helpers * Extending sdk config tests and moving autorun functionality into the test context. * Fixing analysis errors * adding missing DDC sound sdks to asset generator test * Fixing ddc and amd paths * Keeping the first instance of an app connection and extending timeouts * formatting files * Exposing utilities/ddc_names.dart * Loosen `vm_service` constraints and prepare DWDS for release to 23.1.1 (#2329) * Reset DWDS to version `23.2.0-wip` after release (#2334) * Adding changelog --------- Co-authored-by: Elliott Brooks <[email protected]>
1 parent 7c096a2 commit 10131b1

26 files changed

+1383
-655
lines changed

dwds/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 23.2.0-wip
22

33
- Send untruncated `dart:developer` logs to debugging clients. - [#2333](https://github.com/dart-lang/webdev/pull/2333)
4+
- Enabling tests that run with the DDC module system and exposing `utilities/ddc_names.dart` - [#2295](https://github.com/dart-lang/webdev/pull/2295)
45

56
## 23.1.1
67

dwds/lib/dwds.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ export 'src/services/expression_compiler.dart'
4141
CompilerOptions;
4242
export 'src/services/expression_compiler_service.dart'
4343
show ExpressionCompilerService;
44+
export 'src/utilities/ddc_names.dart';
4445
export 'src/utilities/sdk_configuration.dart'
4546
show SdkLayout, SdkConfiguration, SdkConfigurationProvider;

dwds/lib/expression_compiler.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ export 'src/services/expression_compiler.dart'
77
ExpressionCompilationResult,
88
ExpressionCompiler,
99
CompilerOptions,
10+
ModuleFormat,
1011
ModuleInfo;

dwds/lib/src/loaders/legacy.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ class LegacyStrategy extends LoadStrategy {
181181
return '''
182182
$_baseUrlScript
183183
var scripts = ${const JsonEncoder.withIndent(" ").convert(scripts)};
184-
window.\$dartLoader.loadScripts(scripts);
184+
window.\$dartLoader.loadConfig.loadScriptFn = function(loader) {
185+
loader.addScriptsToQueue(scripts, null);
186+
loader.loadEnqueuedModules();
187+
};
188+
window.\$dartLoader.loader.nextAttempt();
185189
''';
186190
}
187191

dwds/lib/src/services/chrome_proxy_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class ChromeProxyService implements VmServiceInterface {
187187
'with sound null safety: $soundNullSafety');
188188

189189
final compilerOptions = CompilerOptions(
190-
moduleFormat: moduleFormat,
190+
moduleFormat: ModuleFormat.values.byName(moduleFormat),
191191
soundNullSafety: soundNullSafety,
192192
canaryFeatures: canaryFeatures,
193193
experiments: experiments,

dwds/lib/src/services/expression_compiler.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/// Options passed to DDC and the expression compiler.
66
class CompilerOptions {
7-
final String moduleFormat;
7+
final ModuleFormat moduleFormat;
88
final bool soundNullSafety;
99
final bool canaryFeatures;
1010
final List<String> experiments;
@@ -17,6 +17,9 @@ class CompilerOptions {
1717
});
1818
}
1919

20+
/// Indicates the module system DDC is targeting.
21+
enum ModuleFormat { amd, ddc, es6 }
22+
2023
/// Result of compilation of dart expression to JavaScript
2124
class ExpressionCompilationResult {
2225
final bool isError;

dwds/lib/src/services/expression_compiler_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class _Compiler {
8989
'--asset-server-port',
9090
'$port',
9191
'--module-format',
92-
compilerOptions.moduleFormat,
92+
compilerOptions.moduleFormat.name,
9393
if (verbose) '--verbose',
9494
compilerOptions.soundNullSafety
9595
? '--sound-null-safety'

dwds/lib/utilities.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
export 'src/utilities/ddc_names.dart';

dwds/test/devtools_test.dart

Lines changed: 101 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -32,110 +32,115 @@ void main() {
3232

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

35-
group('Injected client', () {
36-
setUp(() async {
37-
await context.setUp(
38-
debugSettings: TestDebugSettings.withDevTools(context),
39-
);
40-
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
41-
// Wait for DevTools to actually open.
42-
await Future.delayed(const Duration(seconds: 2));
43-
});
44-
45-
tearDown(() async {
46-
await context.tearDown();
47-
});
48-
49-
test(
50-
'can launch devtools',
51-
() async {
52-
final windows = await context.webDriver.windows.toList();
53-
await context.webDriver.driver.switchTo.window(windows.last);
54-
expect(await context.webDriver.pageSource, contains('DevTools'));
55-
expect(await context.webDriver.currentUrl, contains('ide=Dwds'));
56-
// TODO(https://github.com/dart-lang/webdev/issues/1888): Re-enable.
57-
},
58-
skip: Platform.isWindows,
59-
);
60-
61-
test('can not launch devtools for the same app in multiple tabs', () async {
62-
final appUrl = await context.webDriver.currentUrl;
63-
// Open a new tab, select it, and navigate to the app
64-
await context.webDriver.driver
65-
.execute("window.open('$appUrl', '_blank');", []);
66-
await Future.delayed(const Duration(seconds: 2));
67-
final newAppWindow = await context.webDriver.windows.last;
68-
await newAppWindow.setAsActive();
35+
group(
36+
'Injected client',
37+
() {
38+
setUp(() async {
39+
await context.setUp(
40+
debugSettings: TestDebugSettings.withDevTools(context),
41+
);
42+
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
43+
// Wait for DevTools to actually open.
44+
await Future.delayed(const Duration(seconds: 2));
45+
});
6946

70-
// Wait for the page to be ready before trying to open DevTools again.
71-
await _waitForPageReady(context);
47+
tearDown(() async {
48+
await context.tearDown();
49+
});
7250

73-
// Try to open devtools and check for the alert.
74-
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
75-
await Future.delayed(const Duration(seconds: 2));
76-
final alert = context.webDriver.driver.switchTo.alert;
77-
expect(alert, isNotNull);
78-
expect(
79-
await alert.text,
80-
contains('This app is already being debugged in a different tab'),
51+
test(
52+
'can launch devtools',
53+
() async {
54+
final windows = await context.webDriver.windows.toList();
55+
await context.webDriver.driver.switchTo.window(windows.last);
56+
expect(await context.webDriver.pageSource, contains('DevTools'));
57+
expect(await context.webDriver.currentUrl, contains('ide=Dwds'));
58+
// TODO(https://github.com/dart-lang/webdev/issues/1888): Re-enable.
59+
},
60+
skip: Platform.isWindows,
8161
);
82-
await alert.accept();
8362

84-
var windows = await context.webDriver.windows.toList();
85-
for (final window in windows) {
86-
if (window.id != newAppWindow.id) {
87-
await window.setAsActive();
88-
await window.close();
89-
}
90-
}
63+
test('can not launch devtools for the same app in multiple tabs',
64+
() async {
65+
final appUrl = await context.webDriver.currentUrl;
66+
// Open a new tab, select it, and navigate to the app
67+
await context.webDriver.driver
68+
.execute("window.open('$appUrl', '_blank');", []);
69+
await Future.delayed(const Duration(seconds: 2));
70+
final newAppWindow = await context.webDriver.windows.last;
71+
await newAppWindow.setAsActive();
9172

92-
await newAppWindow.setAsActive();
93-
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
94-
await Future.delayed(const Duration(seconds: 2));
95-
windows = await context.webDriver.windows.toList();
96-
final devToolsWindow =
97-
windows.firstWhere((window) => window != newAppWindow);
98-
await devToolsWindow.setAsActive();
99-
expect(await context.webDriver.pageSource, contains('DevTools'));
100-
});
73+
// Wait for the page to be ready before trying to open DevTools again.
74+
await _waitForPageReady(context);
10175

102-
test(
103-
'destroys and recreates the isolate during a page refresh',
104-
() async {
105-
// This test is the same as one in reload_test, but runs here when there
106-
// is a connected client (DevTools) since it can behave differently.
107-
// https://github.com/dart-lang/webdev/pull/901#issuecomment-586438132
108-
final client = context.debugConnection.vmService;
109-
await client.streamListen('Isolate');
110-
context.makeEditToDartEntryFile(
111-
toReplace: 'Hello World!',
112-
replaceWith: 'Bonjour le monde!',
113-
);
114-
await context.waitForSuccessfulBuild(propagateToBrowser: true);
115-
116-
final eventsDone = expectLater(
117-
client.onIsolateEvent,
118-
emitsThrough(
119-
emitsInOrder([
120-
_hasKind(EventKind.kIsolateExit),
121-
_hasKind(EventKind.kIsolateStart),
122-
_hasKind(EventKind.kIsolateRunnable),
123-
]),
124-
),
76+
// Try to open devtools and check for the alert.
77+
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
78+
await Future.delayed(const Duration(seconds: 2));
79+
final alert = context.webDriver.driver.switchTo.alert;
80+
expect(alert, isNotNull);
81+
expect(
82+
await alert.text,
83+
contains('This app is already being debugged in a different tab'),
12584
);
85+
await alert.accept();
12686

127-
await context.webDriver.driver.refresh();
87+
var windows = await context.webDriver.windows.toList();
88+
for (final window in windows) {
89+
if (window.id != newAppWindow.id) {
90+
await window.setAsActive();
91+
await window.close();
92+
}
93+
}
12894

129-
await eventsDone;
130-
// Re-set the edited file:
131-
context.makeEditToDartEntryFile(
132-
toReplace: 'Bonjour le monde!',
133-
replaceWith: 'Hello World!',
134-
);
135-
},
136-
skip: 'https://github.com/dart-lang/webdev/issues/1888',
137-
);
138-
});
95+
await newAppWindow.setAsActive();
96+
await context.webDriver.driver.keyboard.sendChord([Keyboard.alt, 'd']);
97+
await Future.delayed(const Duration(seconds: 2));
98+
windows = await context.webDriver.windows.toList();
99+
final devToolsWindow =
100+
windows.firstWhere((window) => window != newAppWindow);
101+
await devToolsWindow.setAsActive();
102+
expect(await context.webDriver.pageSource, contains('DevTools'));
103+
});
104+
105+
test(
106+
'destroys and recreates the isolate during a page refresh',
107+
() async {
108+
// This test is the same as one in reload_test, but runs here when there
109+
// is a connected client (DevTools) since it can behave differently.
110+
// https://github.com/dart-lang/webdev/pull/901#issuecomment-586438132
111+
final client = context.debugConnection.vmService;
112+
await client.streamListen('Isolate');
113+
context.makeEditToDartEntryFile(
114+
toReplace: 'Hello World!',
115+
replaceWith: 'Bonjour le monde!',
116+
);
117+
await context.waitForSuccessfulBuild(propagateToBrowser: true);
118+
119+
final eventsDone = expectLater(
120+
client.onIsolateEvent,
121+
emitsThrough(
122+
emitsInOrder([
123+
_hasKind(EventKind.kIsolateExit),
124+
_hasKind(EventKind.kIsolateStart),
125+
_hasKind(EventKind.kIsolateRunnable),
126+
]),
127+
),
128+
);
129+
130+
await context.webDriver.driver.refresh();
131+
132+
await eventsDone;
133+
// Re-set the edited file:
134+
context.makeEditToDartEntryFile(
135+
toReplace: 'Bonjour le monde!',
136+
replaceWith: 'Hello World!',
137+
);
138+
},
139+
skip: 'https://github.com/dart-lang/webdev/issues/1888',
140+
);
141+
},
142+
timeout: Timeout.factor(2),
143+
);
139144

140145
group('Injected client without a DevTools server', () {
141146
setUp(() async {
@@ -193,6 +198,7 @@ void main() {
193198
},
194199
tags: ['extension'],
195200
skip: 'https://github.com/dart-lang/webdev/issues/2114',
201+
timeout: Timeout.factor(2),
196202
);
197203
}
198204

dwds/test/evaluate_common.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ void testAll({
7171
await context.setUp(
7272
testSettings: TestSettings(
7373
compilationMode: compilationMode,
74+
moduleFormat: provider.ddcModuleFormat,
7475
enableExpressionEvaluation: true,
7576
useDebuggerModuleNames: useDebuggerModuleNames,
7677
verboseCompiler: debug,
@@ -821,6 +822,7 @@ void testAll({
821822
await context.setUp(
822823
testSettings: TestSettings(
823824
compilationMode: compilationMode,
825+
moduleFormat: provider.ddcModuleFormat,
824826
enableExpressionEvaluation: false,
825827
verboseCompiler: debug,
826828
),

dwds/test/expression_compiler_service_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void main() async {
8080
);
8181

8282
final compilerOptions = CompilerOptions(
83-
moduleFormat: 'amd',
83+
moduleFormat: ModuleFormat.amd,
8484
soundNullSafety: true,
8585
canaryFeatures: false,
8686
experiments: const <String>[],

0 commit comments

Comments
 (0)