@@ -58,123 +58,135 @@ String get message => p.join('hello', 'world');
58
58
await client.shutdown ();
59
59
});
60
60
61
- test ('can compile, recompile, and hot reload a vm app' , () async {
62
- var entrypoint = p.join (packageRoot, 'bin' , 'main.dart' );
63
- client = await FrontendServerClient .start (
64
- entrypoint, p.join (packageRoot, 'out.dill' ), vmPlatformDill);
65
- var result = await client.compile ();
66
- client.accept ();
67
- expect (result.compilerOutputLines, isEmpty);
68
- expect (result.errorCount, 0 );
69
- expect (
70
- result.newSources,
71
- containsAll ([
72
- File (entrypoint).uri,
73
- packageConfig.resolve (Uri .parse ('package:path/path.dart' )),
74
- ]));
75
- expect (result.removedSources, isEmpty);
76
- expect (result.dillOutput, isNotNull);
77
- expect (File (result.dillOutput! ).existsSync (), true );
78
- var process = await Process .start (Platform .resolvedExecutable, [
79
- '--observe' ,
80
- '--no-pause-isolates-on-exit' ,
81
- '--pause-isolates-on-start' ,
82
- result.dillOutput!
83
- ]);
84
- addTearDown (process.kill);
85
- var stdoutLines = StreamQueue (
86
- process.stdout.transform (utf8.decoder).transform (const LineSplitter ()));
87
-
88
- var observatoryLine = await stdoutLines.next;
89
- var observatoryUri =
90
- '${observatoryLine .split (' ' ).last .replaceFirst ('http' , 'ws' )}ws' ;
91
- var vmService = await vmServiceConnectUri (observatoryUri);
92
- var isolate = await waitForIsolatesAndResume (vmService);
93
-
94
- await expectLater (stdoutLines, emitsThrough (p.join ('hello' , 'world' )));
95
-
96
- var appFile = File (entrypoint);
97
- var originalContent = await appFile.readAsString ();
98
- var newContent = originalContent.replaceFirst ('hello' , 'goodbye' );
99
- await appFile.writeAsString (newContent);
100
-
101
- result = await client.compile ([File (entrypoint).uri]);
102
-
103
- client.accept ();
104
- expect (result.newSources, isEmpty);
105
- expect (result.removedSources, isEmpty);
106
- expect (result.compilerOutputLines, isEmpty);
107
- expect (result.errorCount, 0 );
108
- expect (result.dillOutput, endsWith ('.incremental.dill' ));
109
-
110
- await vmService.reloadSources (isolate.id! , rootLibUri: result.dillOutput);
111
-
112
- expect (await stdoutLines.next, p.join ('goodbye' , 'world' ));
113
- expect (await process.exitCode, 0 );
114
- });
115
-
116
- test ('can handle compile errors and reload fixes' , () async {
117
- var entrypoint = p.join (packageRoot, 'bin' , 'main.dart' );
118
- var entrypointFile = File (entrypoint);
119
- var originalContent = await entrypointFile.readAsString ();
120
- // append two compile errors to the bottom
121
- await entrypointFile
122
- .writeAsString ('$originalContent \n int foo = 1.0;\n String bar = 4;' );
123
-
124
- client = await FrontendServerClient .start (
125
- entrypoint, p.join (packageRoot, 'out.dill' ), vmPlatformDill);
126
- var result = await client.compile ();
127
-
128
- client.accept ();
129
- expect (result.errorCount, 2 );
130
- expect (result.compilerOutputLines,
131
- allOf (contains ('int foo = 1.0;' ), contains ('String bar = 4;' )));
132
- expect (
133
- result.newSources,
134
- containsAll ([
135
- File (entrypoint).uri,
136
- packageConfig.resolve (Uri .parse ('package:path/path.dart' )),
137
- ]));
138
- expect (result.removedSources, isEmpty);
139
- expect (result.dillOutput, isNotNull);
140
- expect (File (result.dillOutput! ).existsSync (), true );
141
-
142
- var process = await Process .start (Platform .resolvedExecutable, [
143
- '--observe' ,
144
- '--no-pause-isolates-on-exit' ,
145
- '--pause-isolates-on-start' ,
146
- result.dillOutput!
147
- ]);
148
- addTearDown (process.kill);
149
- var stdoutLines = StreamQueue (
150
- process.stdout.transform (utf8.decoder).transform (const LineSplitter ()));
151
-
152
- var observatoryLine = await stdoutLines.next;
153
- var observatoryUri =
154
- '${observatoryLine .split (' ' ).last .replaceFirst ('http' , 'ws' )}ws' ;
155
- var vmService = await vmServiceConnectUri (observatoryUri);
156
- var isolate = await waitForIsolatesAndResume (vmService);
157
-
158
- // The program actually runs regardless of the errors, as they don't affect
159
- // the runtime behavior.
160
- await expectLater (stdoutLines, emitsThrough (p.join ('hello' , 'world' )));
161
-
162
- await entrypointFile
163
- .writeAsString (originalContent.replaceFirst ('hello' , 'goodbye' ));
164
- result = await client.compile ([entrypointFile.uri]);
165
- client.accept ();
166
- expect (result.errorCount, 0 );
167
- expect (result.compilerOutputLines, isEmpty);
168
- expect (result.newSources, isEmpty);
169
- expect (result.removedSources, isEmpty);
170
- expect (result.dillOutput, isNotNull);
171
- expect (File (result.dillOutput! ).existsSync (), true );
172
-
173
- await vmService.reloadSources (isolate.id! , rootLibUri: result.dillOutput);
174
-
175
- expect (await stdoutLines.next, p.join ('goodbye' , 'world' ));
176
- expect (await process.exitCode, 0 );
177
- });
61
+ test (
62
+ 'can compile, recompile, and hot reload a vm app' ,
63
+ () async {
64
+ var entrypoint = p.join (packageRoot, 'bin' , 'main.dart' );
65
+ client = await FrontendServerClient .start (
66
+ entrypoint, p.join (packageRoot, 'out.dill' ), vmPlatformDill);
67
+ var result = await client.compile ();
68
+ client.accept ();
69
+ expect (result.compilerOutputLines, isEmpty);
70
+ expect (result.errorCount, 0 );
71
+ expect (
72
+ result.newSources,
73
+ containsAll ([
74
+ File (entrypoint).uri,
75
+ packageConfig.resolve (Uri .parse ('package:path/path.dart' )),
76
+ ]));
77
+ expect (result.removedSources, isEmpty);
78
+ expect (result.dillOutput, isNotNull);
79
+ expect (File (result.dillOutput! ).existsSync (), true );
80
+ var process = await Process .start (Platform .resolvedExecutable, [
81
+ '--observe' ,
82
+ '--no-pause-isolates-on-exit' ,
83
+ '--pause-isolates-on-start' ,
84
+ result.dillOutput!
85
+ ]);
86
+ addTearDown (process.kill);
87
+ var stdoutLines = StreamQueue (process.stdout
88
+ .transform (utf8.decoder)
89
+ .transform (const LineSplitter ()));
90
+
91
+ var observatoryLine = await stdoutLines.next;
92
+ var observatoryUri =
93
+ '${observatoryLine .split (' ' ).last .replaceFirst ('http' , 'ws' )}ws' ;
94
+ var vmService = await vmServiceConnectUri (observatoryUri);
95
+ var isolate = await waitForIsolatesAndResume (vmService);
96
+
97
+ await expectLater (stdoutLines, emitsThrough (p.join ('hello' , 'world' )));
98
+
99
+ var appFile = File (entrypoint);
100
+ var originalContent = await appFile.readAsString ();
101
+ var newContent = originalContent.replaceFirst ('hello' , 'goodbye' );
102
+ await appFile.writeAsString (newContent);
103
+
104
+ result = await client.compile ([File (entrypoint).uri]);
105
+
106
+ client.accept ();
107
+ expect (result.newSources, isEmpty);
108
+ expect (result.removedSources, isEmpty);
109
+ expect (result.compilerOutputLines, isEmpty);
110
+ expect (result.errorCount, 0 );
111
+ expect (result.dillOutput, endsWith ('.incremental.dill' ));
112
+
113
+ await vmService.reloadSources (isolate.id! , rootLibUri: result.dillOutput);
114
+
115
+ expect (await stdoutLines.next, p.join ('goodbye' , 'world' ));
116
+ expect (await process.exitCode, 0 );
117
+ },
118
+ // Issue: https://github.com/dart-lang/webdev/issues/2377
119
+ skip: Platform .isWindows,
120
+ );
121
+
122
+ test (
123
+ 'can handle compile errors and reload fixes' ,
124
+ () async {
125
+ var entrypoint = p.join (packageRoot, 'bin' , 'main.dart' );
126
+ var entrypointFile = File (entrypoint);
127
+ var originalContent = await entrypointFile.readAsString ();
128
+ // append two compile errors to the bottom
129
+ await entrypointFile
130
+ .writeAsString ('$originalContent \n int foo = 1.0;\n String bar = 4;' );
131
+
132
+ client = await FrontendServerClient .start (
133
+ entrypoint, p.join (packageRoot, 'out.dill' ), vmPlatformDill);
134
+ var result = await client.compile ();
135
+
136
+ client.accept ();
137
+ expect (result.errorCount, 2 );
138
+ expect (result.compilerOutputLines,
139
+ allOf (contains ('int foo = 1.0;' ), contains ('String bar = 4;' )));
140
+ expect (
141
+ result.newSources,
142
+ containsAll ([
143
+ File (entrypoint).uri,
144
+ packageConfig.resolve (Uri .parse ('package:path/path.dart' )),
145
+ ]));
146
+ expect (result.removedSources, isEmpty);
147
+ expect (result.dillOutput, isNotNull);
148
+ expect (File (result.dillOutput! ).existsSync (), true );
149
+
150
+ var process = await Process .start (Platform .resolvedExecutable, [
151
+ '--observe' ,
152
+ '--no-pause-isolates-on-exit' ,
153
+ '--pause-isolates-on-start' ,
154
+ result.dillOutput!
155
+ ]);
156
+ addTearDown (process.kill);
157
+ var stdoutLines = StreamQueue (process.stdout
158
+ .transform (utf8.decoder)
159
+ .transform (const LineSplitter ()));
160
+
161
+ var observatoryLine = await stdoutLines.next;
162
+ var observatoryUri =
163
+ '${observatoryLine .split (' ' ).last .replaceFirst ('http' , 'ws' )}ws' ;
164
+ var vmService = await vmServiceConnectUri (observatoryUri);
165
+ var isolate = await waitForIsolatesAndResume (vmService);
166
+
167
+ // The program actually runs regardless of the errors, as they don't affect
168
+ // the runtime behavior.
169
+ await expectLater (stdoutLines, emitsThrough (p.join ('hello' , 'world' )));
170
+
171
+ await entrypointFile
172
+ .writeAsString (originalContent.replaceFirst ('hello' , 'goodbye' ));
173
+ result = await client.compile ([entrypointFile.uri]);
174
+ client.accept ();
175
+ expect (result.errorCount, 0 );
176
+ expect (result.compilerOutputLines, isEmpty);
177
+ expect (result.newSources, isEmpty);
178
+ expect (result.removedSources, isEmpty);
179
+ expect (result.dillOutput, isNotNull);
180
+ expect (File (result.dillOutput! ).existsSync (), true );
181
+
182
+ await vmService.reloadSources (isolate.id! , rootLibUri: result.dillOutput);
183
+
184
+ expect (await stdoutLines.next, p.join ('goodbye' , 'world' ));
185
+ expect (await process.exitCode, 0 );
186
+ },
187
+ // Issue: https://github.com/dart-lang/webdev/issues/2377
188
+ skip: Platform .isWindows,
189
+ );
178
190
179
191
test ('can compile and recompile a dartdevc app' , () async {
180
192
var entrypoint =
0 commit comments