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
3393566b
Unverified
Commit
3393566b
authored
Oct 16, 2020
by
Lau Ching Jun
Committed by
GitHub
Oct 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use multiroot scheme for initial compilation in ResidentRunner recompile (#68280)
parent
dd93ee30
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
12 deletions
+89
-12
compile.dart
packages/flutter_tools/lib/src/compile.dart
+4
-6
compile_batch_test.dart
.../flutter_tools/test/general.shard/compile_batch_test.dart
+1
-1
compile_incremental_test.dart
...er_tools/test/general.shard/compile_incremental_test.dart
+84
-5
No files found.
packages/flutter_tools/lib/src/compile.dart
View file @
3393566b
...
...
@@ -584,15 +584,13 @@ class DefaultResidentCompiler implements ResidentCompiler {
_compileRequestNeedsConfirmation
=
true
;
_stdoutHandler
.
_suppressCompilerMessages
=
request
.
suppressErrors
;
final
String
mainUri
=
request
.
packageConfig
.
toPackageUri
(
request
.
mainUri
)?.
toString
()
??
toMultiRootPath
(
request
.
mainUri
,
fileSystemScheme
,
fileSystemRoots
,
_platform
.
isWindows
);
if
(
_server
==
null
)
{
return
_compile
(
request
.
packageConfig
.
toPackageUri
(
request
.
mainUri
)?.
toString
()
??
request
.
mainUri
.
toString
(),
request
.
outputPath
,
);
return
_compile
(
mainUri
,
request
.
outputPath
);
}
final
String
inputKey
=
Uuid
().
generateV4
();
final
String
mainUri
=
request
.
packageConfig
.
toPackageUri
(
request
.
mainUri
)?.
toString
()
??
toMultiRootPath
(
request
.
mainUri
,
fileSystemScheme
,
fileSystemRoots
,
_platform
.
isWindows
);
_server
.
stdin
.
writeln
(
'recompile
$mainUri
$inputKey
'
);
_logger
.
printTrace
(
'<- recompile
$mainUri
$inputKey
'
);
...
...
packages/flutter_tools/test/general.shard/compile_batch_test.dart
View file @
3393566b
...
...
@@ -240,7 +240,7 @@ void main() {
expect
(
latestCommand
,
containsAllInOrder
(<
String
>[
'-DFOO=bar'
,
'-DBAZ=qux'
]));
});
testWithoutContext
(
'maps a file to a multiroot scheme if provid
f
ed'
,
()
async
{
testWithoutContext
(
'maps a file to a multiroot scheme if provided'
,
()
async
{
// Use unsuccessful result because it's easier to setup in test. We only care about arguments passed to the compiler.
when
(
mockFrontendServer
.
exitCode
).
thenAnswer
((
_
)
async
=>
255
);
when
(
mockFrontendServer
.
stdout
).
thenAnswer
((
Invocation
invocation
)
=>
Stream
<
List
<
int
>>.
fromFuture
(
...
...
packages/flutter_tools/test/general.shard/compile_incremental_test.dart
View file @
3393566b
...
...
@@ -23,6 +23,7 @@ import '../src/mocks.dart';
void
main
(
)
{
ProcessManager
mockProcessManager
;
ResidentCompiler
generator
;
ResidentCompiler
generatorWithScheme
;
MockProcess
mockFrontendServer
;
MockStdIn
mockFrontendServerStdIn
;
MockStream
mockFrontendServerStdErr
;
...
...
@@ -43,6 +44,18 @@ void main() {
artifacts:
Artifacts
.
test
(),
platform:
FakePlatform
(
operatingSystem:
'linux'
),
);
generatorWithScheme
=
ResidentCompiler
(
'sdkroot'
,
buildMode:
BuildMode
.
debug
,
logger:
testLogger
,
processManager:
mockProcessManager
,
artifacts:
Artifacts
.
test
(),
platform:
FakePlatform
(
operatingSystem:
'linux'
),
fileSystemRoots:
<
String
>[
'/foo/bar/fizz'
,
],
fileSystemScheme:
'scheme'
,
);
when
(
mockFrontendServer
.
stdin
).
thenReturn
(
mockFrontendServerStdIn
);
when
(
mockFrontendServer
.
stderr
)
...
...
@@ -80,6 +93,26 @@ void main() {
expect
(
output
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
});
testWithoutContext
(
'incremental compile single dart compile with filesystem scheme'
,
()
async
{
when
(
mockFrontendServer
.
stdout
)
.
thenAnswer
((
Invocation
invocation
)
=>
Stream
<
List
<
int
>>.
fromFuture
(
Future
<
List
<
int
>>.
value
(
utf8
.
encode
(
'result abc
\n
line1
\n
line2
\n
abc
\n
abc /path/to/main.dart.dill 0'
))
));
final
CompilerOutput
output
=
await
generatorWithScheme
.
recompile
(
Uri
.
parse
(
'file:///foo/bar/fizz/main.dart'
),
null
/* invalidatedFiles */
,
outputPath:
'/build/'
,
packageConfig:
PackageConfig
.
empty
,
);
expect
(
mockFrontendServerStdIn
.
getAndClear
(),
'compile scheme:///main.dart
\n
'
);
verifyNoMoreInteractions
(
mockFrontendServerStdIn
);
expect
(
testLogger
.
errorText
,
equals
(
'line1
\n
line2
\n
'
));
expect
(
output
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
});
testWithoutContext
(
'incremental compile single dart compile abnormally terminates'
,
()
async
{
when
(
mockFrontendServer
.
stdout
)
.
thenAnswer
((
Invocation
invocation
)
=>
const
Stream
<
List
<
int
>>.
empty
()
...
...
@@ -145,6 +178,47 @@ void main() {
));
});
testWithoutContext
(
'incremental compile and recompile with filesystem scheme'
,
()
async
{
final
StreamController
<
List
<
int
>>
streamController
=
StreamController
<
List
<
int
>>();
when
(
mockFrontendServer
.
stdout
)
.
thenAnswer
((
Invocation
invocation
)
=>
streamController
.
stream
);
streamController
.
add
(
utf8
.
encode
(
'result abc
\n
line0
\n
line1
\n
abc
\n
abc /path/to/main.dart.dill 0
\n
'
));
await
generatorWithScheme
.
recompile
(
Uri
.
parse
(
'file:///foo/bar/fizz/main.dart'
),
null
,
/* invalidatedFiles */
outputPath:
'/build/'
,
packageConfig:
PackageConfig
.
empty
,
);
expect
(
mockFrontendServerStdIn
.
getAndClear
(),
'compile scheme:///main.dart
\n
'
);
// No accept or reject commands should be issued until we
// send recompile request.
await
_accept
(
streamController
,
generatorWithScheme
,
mockFrontendServerStdIn
,
''
);
await
_reject
(
streamController
,
generatorWithScheme
,
mockFrontendServerStdIn
,
''
,
''
);
await
_recompile
(
streamController
,
generatorWithScheme
,
mockFrontendServerStdIn
,
'result abc
\n
line1
\n
line2
\n
abc
\n
abc /path/to/main.dart.dill 0
\n
'
,
mainUri:
Uri
.
parse
(
'file:///foo/bar/fizz/main.dart'
),
expectedUri:
'scheme:///main.dart'
);
await
_accept
(
streamController
,
generatorWithScheme
,
mockFrontendServerStdIn
,
r'^accept\n$'
);
await
_recompile
(
streamController
,
generatorWithScheme
,
mockFrontendServerStdIn
,
'result abc
\n
line1
\n
line2
\n
abc
\n
abc /path/to/main.dart.dill 0
\n
'
,
mainUri:
Uri
.
parse
(
'file:///foo/bar/fizz/main.dart'
),
expectedUri:
'scheme:///main.dart'
);
// No sources returned from reject command.
await
_reject
(
streamController
,
generatorWithScheme
,
mockFrontendServerStdIn
,
'result abc
\n
abc
\n
'
,
r'^reject\n$'
);
verifyNoMoreInteractions
(
mockFrontendServerStdIn
);
expect
(
mockFrontendServerStdIn
.
getAndClear
(),
isEmpty
);
expect
(
testLogger
.
errorText
,
equals
(
'line0
\n
line1
\n
'
'line1
\n
line2
\n
'
'line1
\n
line2
\n
'
));
});
testWithoutContext
(
'incremental compile can suppress errors'
,
()
async
{
final
StreamController
<
List
<
int
>>
stdoutController
=
StreamController
<
List
<
int
>>();
when
(
mockFrontendServer
.
stdout
)
...
...
@@ -214,17 +288,21 @@ Future<void> _recompile(
StreamController
<
List
<
int
>>
streamController
,
ResidentCompiler
generator
,
MockStdIn
mockFrontendServerStdIn
,
String
mockCompilerOutput
,
{
bool
suppressErrors
=
false
}
)
async
{
String
mockCompilerOutput
,
{
bool
suppressErrors
=
false
,
Uri
mainUri
,
String
expectedUri
=
'/path/to/main.dart'
,
})
async
{
mainUri
??=
Uri
.
parse
(
'/path/to/main.dart'
);
// Put content into the output stream after generator.recompile gets
// going few lines below, resets completer.
scheduleMicrotask
(()
{
streamController
.
add
(
utf8
.
encode
(
mockCompilerOutput
));
});
final
CompilerOutput
output
=
await
generator
.
recompile
(
Uri
.
parse
(
'/path/to/main.dart'
)
,
<
Uri
>[
Uri
.
parse
(
'/path/to/main.dart'
)
],
mainUri
,
<
Uri
>[
mainUri
],
outputPath:
'/build/'
,
packageConfig:
PackageConfig
.
empty
,
suppressErrors:
suppressErrors
,
...
...
@@ -236,6 +314,7 @@ Future<void> _recompile(
// Test that uuid matches at beginning and end.
expect
(
parts
[
2
],
equals
(
parts
[
4
]));
expect
(
parts
[
1
],
equals
(
expectedUri
));
mockFrontendServerStdIn
.
stdInWrites
.
clear
();
}
...
...
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