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
07e5cf00
Unverified
Commit
07e5cf00
authored
Sep 28, 2019
by
Jonah Williams
Committed by
GitHub
Sep 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reland: Exit resident web runner on compilation failure (#41505)
parent
7a487b2c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
6 deletions
+64
-6
resident_web_runner.dart
...utter_tools/lib/src/build_runner/resident_web_runner.dart
+1
-3
web_fs.dart
packages/flutter_tools/lib/src/build_runner/web_fs.dart
+22
-2
web_fs_test.dart
...ges/flutter_tools/test/general.shard/web/web_fs_test.dart
+41
-1
No files found.
packages/flutter_tools/lib/src/build_runner/resident_web_runner.dart
View file @
07e5cf00
...
...
@@ -192,9 +192,7 @@ class ResidentWebRunner extends ResidentRunner {
_connectionResult
=
await
_webFs
.
connect
(
debuggingOptions
);
unawaited
(
_connectionResult
.
debugConnection
.
onDone
.
whenComplete
(
exit
));
}
}
catch
(
err
,
stackTrace
)
{
printError
(
err
.
toString
());
printError
(
stackTrace
.
toString
());
}
catch
(
err
)
{
throwToolExit
(
'Failed to build application for the web.'
);
}
finally
{
buildStatus
.
stop
();
...
...
packages/flutter_tools/lib/src/build_runner/web_fs.dart
View file @
07e5cf00
...
...
@@ -135,7 +135,7 @@ class WebFs {
_client
.
startBuild
();
await
for
(
BuildResults
results
in
_client
.
buildResults
)
{
final
BuildResult
result
=
results
.
results
.
firstWhere
((
BuildResult
result
)
{
return
result
.
target
==
'web'
;
return
result
.
target
==
kBuildTargetName
;
});
if
(
result
.
status
==
BuildStatus
.
failed
)
{
return
false
;
...
...
@@ -164,6 +164,7 @@ class WebFs {
final
bool
hasWebPlugins
=
findPlugins
(
flutterProject
)
.
any
((
Plugin
p
)
=>
p
.
platforms
.
containsKey
(
WebPlugin
.
kConfigKey
));
// Start the build daemon and run an initial build.
final
Completer
<
bool
>
inititalBuild
=
Completer
<
bool
>();
final
BuildDaemonClient
client
=
await
buildDaemonCreator
.
startBuildDaemon
(
fs
.
currentDirectory
.
path
,
release:
buildInfo
.
isRelease
,
...
...
@@ -178,6 +179,20 @@ class WebFs {
return
results
.
results
.
firstWhere
((
BuildResult
result
)
=>
result
.
target
==
kBuildTargetName
);
});
final
StreamSubscription
<
void
>
firstBuild
=
client
.
buildResults
.
listen
((
BuildResults
buildResults
)
{
if
(
inititalBuild
.
isCompleted
)
{
return
;
}
final
BuildResult
result
=
buildResults
.
results
.
firstWhere
((
BuildResult
result
)
{
return
result
.
target
==
kBuildTargetName
;
});
if
(
result
.
status
==
BuildStatus
.
failed
)
{
inititalBuild
.
complete
(
false
);
}
if
(
result
.
status
==
BuildStatus
.
succeeded
)
{
inititalBuild
.
complete
(
true
);
}
});
final
int
daemonAssetPort
=
buildDaemonCreator
.
assetServerPort
(
fs
.
currentDirectory
);
// Initialize the asset bundle.
...
...
@@ -249,13 +264,18 @@ class WebFs {
cascade
=
cascade
.
add
(
assetServer
.
handle
);
final
HttpServer
server
=
await
httpMultiServerFactory
(
hostname
??
_kHostName
,
hostPort
);
shelf_io
.
serveRequests
(
server
,
cascade
.
handler
);
return
WebFs
(
final
WebFs
webFS
=
WebFs
(
client
,
server
,
dwds
,
'http://
$_kHostName
:
$hostPort
/'
,
assetServer
,
);
if
(!
await
inititalBuild
.
future
)
{
throw
Exception
(
'Failed to compile for the web.'
);
}
await
firstBuild
.
cancel
();
return
webFS
;
}
}
...
...
packages/flutter_tools/test/general.shard/web/web_fs_test.dart
View file @
07e5cf00
...
...
@@ -4,6 +4,7 @@
import
'package:build_daemon/client.dart'
;
import
'package:build_daemon/data/build_status.dart'
;
import
'package:built_collection/built_collection.dart'
;
import
'package:dwds/dwds.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
...
...
@@ -49,7 +50,18 @@ void main() {
return
1234
;
});
when
(
mockBuildDaemonClient
.
buildResults
).
thenAnswer
((
Invocation
_
)
{
return
const
Stream
<
BuildResults
>.
empty
();
return
Stream
<
BuildResults
>.
fromFuture
(
Future
<
BuildResults
>.
value
(
BuildResults
((
BuildResultsBuilder
builder
)
{
builder
.
results
=
ListBuilder
<
BuildResult
>(
<
BuildResult
>[
DefaultBuildResult
((
DefaultBuildResultBuilder
builder
)
{
builder
.
target
=
'web'
;
builder
.
status
=
BuildStatus
.
succeeded
;
})
]
);
})
));
});
when
(
mockBuildDaemonCreator
.
assetServerPort
(
any
)).
thenReturn
(
4321
);
testbed
=
Testbed
(
...
...
@@ -141,6 +153,34 @@ void main() {
expect
(
lastPort
,
1234
);
expect
(
lastAddress
,
contains
(
'foo'
));
}));
test
(
'Throws exception if build fails'
,
()
=>
testbed
.
run
(()
async
{
when
(
mockBuildDaemonClient
.
buildResults
).
thenAnswer
((
Invocation
_
)
{
return
Stream
<
BuildResults
>.
fromFuture
(
Future
<
BuildResults
>.
value
(
BuildResults
((
BuildResultsBuilder
builder
)
{
builder
.
results
=
ListBuilder
<
BuildResult
>(
<
BuildResult
>[
DefaultBuildResult
((
DefaultBuildResultBuilder
builder
)
{
builder
.
target
=
'web'
;
builder
.
status
=
BuildStatus
.
failed
;
})
]
);
})
));
});
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
expect
(
WebFs
.
start
(
skipDwds:
false
,
target:
fs
.
path
.
join
(
'lib'
,
'main.dart'
),
buildInfo:
BuildInfo
.
debug
,
flutterProject:
flutterProject
,
initializePlatform:
false
,
hostname:
'foo'
,
port:
'1234'
,
),
throwsA
(
isInstanceOf
<
Exception
>()));
}));
}
class
MockBuildDaemonCreator
extends
Mock
implements
BuildDaemonCreator
{}
...
...
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