Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
59ca523b
Unverified
Commit
59ca523b
authored
Nov 27, 2019
by
Jonah Williams
Committed by
GitHub
Nov 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support web-server/profile/release mode with incremental compiler support for web (#45713)
parent
598f2ab0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
10 deletions
+72
-10
resident_web_runner.dart
...utter_tools/lib/src/build_runner/resident_web_runner.dart
+11
-10
resident_web_runner_test.dart
...er_tools/test/general.shard/resident_web_runner_test.dart
+61
-0
No files found.
packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
View file @
59ca523b
...
...
@@ -48,7 +48,7 @@ class DwdsWebRunnerFactory extends WebRunnerFactory {
@required
DebuggingOptions
debuggingOptions
,
@required
List
<
String
>
dartDefines
,
})
{
if
(
featureFlags
.
isWebIncrementalCompilerEnabled
)
{
if
(
featureFlags
.
isWebIncrementalCompilerEnabled
&&
debuggingOptions
.
buildInfo
.
isDebug
)
{
return
_ExperimentalResidentWebRunner
(
device
,
target:
target
,
...
...
@@ -448,10 +448,10 @@ class _ExperimentalResidentWebRunner extends ResidentWebRunner {
try
{
if
(
fullRestart
)
{
await
_wipConnection
.
sendCommand
(
'Page.reload'
);
await
_wipConnection
?
.
sendCommand
(
'Page.reload'
);
}
else
{
await
_wipConnection
.
debugger
.
sendCommand
(
'Runtime.evaluate'
,
params:
<
String
,
Object
>{
await
_wipConnection
?
.
debugger
?
.
sendCommand
(
'Runtime.evaluate'
,
params:
<
String
,
Object
>{
'expression'
:
'window.
\
$hotReloadHook
([
$modules
])'
,
'awaitPromise'
:
true
,
'returnByValue'
:
true
,
...
...
@@ -523,12 +523,13 @@ class _ExperimentalResidentWebRunner extends ResidentWebRunner {
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
,
Completer
<
void
>
appStartedCompleter
,
})
async
{
if
(
device
.
device
is
ChromeDevice
)
{
final
Chrome
chrome
=
await
ChromeLauncher
.
connectedInstance
;
final
ChromeTab
chromeTab
=
await
chrome
.
chromeConnection
.
getTab
((
ChromeTab
chromeTab
)
{
final
ChromeTab
chromeTab
=
await
chrome
.
chromeConnection
.
getTab
((
ChromeTab
chromeTab
)
{
return
chromeTab
.
url
.
contains
(
debuggingOptions
.
hostname
);
});
_wipConnection
=
await
chromeTab
.
connect
();
}
appStartedCompleter
?.
complete
();
connectionInfoCompleter
?.
complete
();
if
(
stayResident
)
{
...
...
packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
View file @
59ca523b
...
...
@@ -49,6 +49,7 @@ void main() {
MockChromeTab
mockChromeTab
;
MockWipConnection
mockWipConnection
;
MockWipDebugger
mockWipDebugger
;
MockWebServerDevice
mockWebServerDevice
;
bool
didSkipDwds
;
setUp
(()
{
...
...
@@ -66,6 +67,7 @@ void main() {
mockChromeTab
=
MockChromeTab
();
mockWipConnection
=
MockWipConnection
();
mockWipDebugger
=
MockWipDebugger
();
mockWebServerDevice
=
MockWebServerDevice
();
when
(
mockFlutterDevice
.
device
).
thenReturn
(
mockChromeDevice
);
testbed
=
Testbed
(
setup:
()
{
...
...
@@ -429,6 +431,49 @@ void main() {
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebIncrementalCompilerEnabled:
true
),
}));
test
(
'Can hot restart after attaching - experimental with web-server device'
,
()
=>
testbed
.
run
(()
async
{
_setupMocks
();
when
(
mockFlutterDevice
.
device
).
thenReturn
(
mockWebServerDevice
);
when
(
mockWebDevFS
.
update
(
mainPath:
anyNamed
(
'mainPath'
),
target:
anyNamed
(
'target'
),
bundle:
anyNamed
(
'bundle'
),
firstBuildTime:
anyNamed
(
'firstBuildTime'
),
bundleFirstUpload:
anyNamed
(
'bundleFirstUpload'
),
generator:
anyNamed
(
'generator'
),
fullRestart:
anyNamed
(
'fullRestart'
),
dillOutputPath:
anyNamed
(
'dillOutputPath'
),
trackWidgetCreation:
anyNamed
(
'trackWidgetCreation'
),
projectRootPath:
anyNamed
(
'projectRootPath'
),
pathToReload:
anyNamed
(
'pathToReload'
),
invalidatedFiles:
anyNamed
(
'invalidatedFiles'
),
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
UpdateFSReport
(
success:
true
)
..
invalidatedModules
=
<
String
>[
'example'
];
});
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
unawaited
(
residentWebRunner
.
run
(
connectionInfoCompleter:
connectionInfoCompleter
,
));
await
connectionInfoCompleter
.
future
;
final
OperationResult
result
=
await
residentWebRunner
.
restart
(
fullRestart:
true
);
expect
(
testLogger
.
statusText
,
contains
(
'Restarted application in'
));
expect
(
result
.
code
,
0
);
verify
(
mockResidentCompiler
.
accept
()).
called
(
2
);
// ensure that analytics are sent.
verify
(
Usage
.
instance
.
sendEvent
(
'hot'
,
'restart'
,
parameters:
<
String
,
String
>{
'cd27'
:
'web-javascript'
,
'cd28'
:
null
,
'cd29'
:
'false'
,
'cd30'
:
'true'
,
})).
called
(
1
);
verifyNever
(
Usage
.
instance
.
sendTiming
(
'hot'
,
'web-incremental-restart'
,
any
));
},
overrides:
<
Type
,
Generator
>{
Usage:
()
=>
MockFlutterUsage
(),
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebIncrementalCompilerEnabled:
true
),
}));
test
(
'Can hot restart after attaching'
,
()
=>
testbed
.
run
(()
async
{
_setupMocks
();
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
...
...
@@ -460,6 +505,21 @@ void main() {
Usage:
()
=>
MockFlutterUsage
(),
}));
test
(
'Selects Dwds runner in profile mode with incremental compiler enabled'
,
()
=>
testbed
.
run
(()
async
{
final
ResidentWebRunner
residentWebRunner
=
DwdsWebRunnerFactory
().
createWebRunner
(
mockFlutterDevice
,
flutterProject:
FlutterProject
.
current
(),
debuggingOptions:
DebuggingOptions
.
enabled
(
BuildInfo
.
profile
),
ipv6:
true
,
stayResident:
true
,
dartDefines:
const
<
String
>[],
)
as
ResidentWebRunner
;
expect
(
residentWebRunner
.
runtimeType
.
toString
(),
'_DwdsResidentWebRunner'
);
},
overrides:
<
Type
,
Generator
>{
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebIncrementalCompilerEnabled:
true
),
}));
test
(
'Fails on compilation errors in hot restart'
,
()
=>
testbed
.
run
(()
async
{
_setupMocks
();
final
Completer
<
DebugConnectionInfo
>
connectionInfoCompleter
=
Completer
<
DebugConnectionInfo
>();
...
...
@@ -1022,3 +1082,4 @@ class MockChromeTab extends Mock implements ChromeTab {}
class
MockWipConnection
extends
Mock
implements
WipConnection
{}
class
MockWipDebugger
extends
Mock
implements
WipDebugger
{}
class
MockLogger
extends
Mock
implements
Logger
{}
class
MockWebServerDevice
extends
Mock
implements
WebServerDevice
{}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment