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
4bcf8fb4
Unverified
Commit
4bcf8fb4
authored
May 24, 2021
by
Jenn Magder
Committed by
GitHub
May 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate compile to null safety (#83153)
parent
ade6e1f9
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
263 additions
and
266 deletions
+263
-266
compile.dart
packages/flutter_tools/lib/src/compile.dart
+185
-180
compile_batch_test.dart
.../flutter_tools/test/general.shard/compile_batch_test.dart
+24
-26
compile_expression_test.dart
...ter_tools/test/general.shard/compile_expression_test.dart
+22
-24
compile_incremental_test.dart
...er_tools/test/general.shard/compile_incremental_test.dart
+19
-21
compile_test.dart
packages/flutter_tools/test/general.shard/compile_test.dart
+13
-15
No files found.
packages/flutter_tools/lib/src/compile.dart
View file @
4bcf8fb4
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/compile_batch_test.dart
View file @
4bcf8fb4
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
...
@@ -24,10 +22,10 @@ void main() {
...
@@ -24,10 +22,10 @@ void main() {
stdoutHandler
.
reset
();
stdoutHandler
.
reset
();
'result abc
\n
line1
\n
line2
\n
abc
\n
abc /path/to/main.dart.dill 0'
.
split
(
'
\n
'
).
forEach
(
stdoutHandler
.
handler
);
'result abc
\n
line1
\n
line2
\n
abc
\n
abc /path/to/main.dart.dill 0'
.
split
(
'
\n
'
).
forEach
(
stdoutHandler
.
handler
);
final
CompilerOutput
output
=
await
stdoutHandler
.
compilerOutput
.
future
;
final
CompilerOutput
?
output
=
await
stdoutHandler
.
compilerOutput
?
.
future
;
expect
(
logger
.
errorText
,
equals
(
'line1
\n
line2
\n
'
));
expect
(
logger
.
errorText
,
equals
(
'line1
\n
line2
\n
'
));
expect
(
output
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
expect
(
output
?
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
});
});
testWithoutContext
(
'StdoutHandler can parse output for failed batch compilation'
,
()
async
{
testWithoutContext
(
'StdoutHandler can parse output for failed batch compilation'
,
()
async
{
...
@@ -36,7 +34,7 @@ void main() {
...
@@ -36,7 +34,7 @@ void main() {
stdoutHandler
.
reset
();
stdoutHandler
.
reset
();
'result abc
\n
line1
\n
line2
\n
abc
\n
abc'
.
split
(
'
\n
'
).
forEach
(
stdoutHandler
.
handler
);
'result abc
\n
line1
\n
line2
\n
abc
\n
abc'
.
split
(
'
\n
'
).
forEach
(
stdoutHandler
.
handler
);
final
CompilerOutput
output
=
await
stdoutHandler
.
compilerOutput
.
future
;
final
CompilerOutput
?
output
=
await
stdoutHandler
.
compilerOutput
?
.
future
;
expect
(
logger
.
errorText
,
equals
(
'line1
\n
line2
\n
'
));
expect
(
logger
.
errorText
,
equals
(
'line1
\n
line2
\n
'
));
expect
(
output
,
equals
(
null
));
expect
(
output
,
equals
(
null
));
...
@@ -73,7 +71,7 @@ void main() {
...
@@ -73,7 +71,7 @@ void main() {
]),
]),
stdoutHandler:
stdoutHandler
,
stdoutHandler:
stdoutHandler
,
);
);
final
Future
<
CompilerOutput
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
final
Future
<
CompilerOutput
?
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
mainPath:
'/path/to/main.dart'
,
mainPath:
'/path/to/main.dart'
,
buildMode:
BuildMode
.
debug
,
buildMode:
BuildMode
.
debug
,
trackWidgetCreation:
false
,
trackWidgetCreation:
false
,
...
@@ -81,10 +79,10 @@ void main() {
...
@@ -81,10 +79,10 @@ void main() {
packageConfig:
PackageConfig
.
empty
,
packageConfig:
PackageConfig
.
empty
,
packagesPath:
'.packages'
,
packagesPath:
'.packages'
,
);
);
stdoutHandler
.
compilerOutput
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
stdoutHandler
.
compilerOutput
?
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
completer
.
complete
();
completer
.
complete
();
expect
((
await
output
).
outputFilename
,
''
);
expect
((
await
output
)
?
.
outputFilename
,
''
);
});
});
testWithoutContext
(
'KernelCompiler returns null if StdoutHandler returns null'
,
()
async
{
testWithoutContext
(
'KernelCompiler returns null if StdoutHandler returns null'
,
()
async
{
...
@@ -118,7 +116,7 @@ void main() {
...
@@ -118,7 +116,7 @@ void main() {
]),
]),
stdoutHandler:
stdoutHandler
,
stdoutHandler:
stdoutHandler
,
);
);
final
Future
<
CompilerOutput
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
final
Future
<
CompilerOutput
?
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
mainPath:
'/path/to/main.dart'
,
mainPath:
'/path/to/main.dart'
,
buildMode:
BuildMode
.
debug
,
buildMode:
BuildMode
.
debug
,
trackWidgetCreation:
false
,
trackWidgetCreation:
false
,
...
@@ -126,7 +124,7 @@ void main() {
...
@@ -126,7 +124,7 @@ void main() {
packageConfig:
PackageConfig
.
empty
,
packageConfig:
PackageConfig
.
empty
,
packagesPath:
'.packages'
,
packagesPath:
'.packages'
,
);
);
stdoutHandler
.
compilerOutput
.
complete
(
null
);
stdoutHandler
.
compilerOutput
?
.
complete
(
null
);
completer
.
complete
();
completer
.
complete
();
expect
(
await
output
,
null
);
expect
(
await
output
,
null
);
...
@@ -163,7 +161,7 @@ void main() {
...
@@ -163,7 +161,7 @@ void main() {
]),
]),
stdoutHandler:
stdoutHandler
,
stdoutHandler:
stdoutHandler
,
);
);
final
Future
<
CompilerOutput
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
final
Future
<
CompilerOutput
?
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
mainPath:
'/path/to/main.dart'
,
mainPath:
'/path/to/main.dart'
,
buildMode:
BuildMode
.
debug
,
buildMode:
BuildMode
.
debug
,
trackWidgetCreation:
false
,
trackWidgetCreation:
false
,
...
@@ -171,7 +169,7 @@ void main() {
...
@@ -171,7 +169,7 @@ void main() {
packageConfig:
PackageConfig
.
empty
,
packageConfig:
PackageConfig
.
empty
,
packagesPath:
'.packages'
,
packagesPath:
'.packages'
,
);
);
stdoutHandler
.
compilerOutput
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
stdoutHandler
.
compilerOutput
?
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
completer
.
complete
();
completer
.
complete
();
expect
(
await
output
,
null
);
expect
(
await
output
,
null
);
...
@@ -209,7 +207,7 @@ void main() {
...
@@ -209,7 +207,7 @@ void main() {
]),
]),
stdoutHandler:
stdoutHandler
,
stdoutHandler:
stdoutHandler
,
);
);
final
Future
<
CompilerOutput
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
final
Future
<
CompilerOutput
?
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
mainPath:
'/path/to/main.dart'
,
mainPath:
'/path/to/main.dart'
,
buildMode:
BuildMode
.
profile
,
buildMode:
BuildMode
.
profile
,
trackWidgetCreation:
false
,
trackWidgetCreation:
false
,
...
@@ -218,10 +216,10 @@ void main() {
...
@@ -218,10 +216,10 @@ void main() {
packageConfig:
PackageConfig
.
empty
,
packageConfig:
PackageConfig
.
empty
,
packagesPath:
'.packages'
,
packagesPath:
'.packages'
,
);
);
stdoutHandler
.
compilerOutput
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
stdoutHandler
.
compilerOutput
?
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
completer
.
complete
();
completer
.
complete
();
expect
((
await
output
).
outputFilename
,
''
);
expect
((
await
output
)
?
.
outputFilename
,
''
);
});
});
testWithoutContext
(
'passes correct AOT config to kernel compiler in aot/release mode'
,
()
async
{
testWithoutContext
(
'passes correct AOT config to kernel compiler in aot/release mode'
,
()
async
{
...
@@ -256,7 +254,7 @@ void main() {
...
@@ -256,7 +254,7 @@ void main() {
]),
]),
stdoutHandler:
stdoutHandler
,
stdoutHandler:
stdoutHandler
,
);
);
final
Future
<
CompilerOutput
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
final
Future
<
CompilerOutput
?
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
mainPath:
'/path/to/main.dart'
,
mainPath:
'/path/to/main.dart'
,
buildMode:
BuildMode
.
release
,
buildMode:
BuildMode
.
release
,
trackWidgetCreation:
false
,
trackWidgetCreation:
false
,
...
@@ -265,10 +263,10 @@ void main() {
...
@@ -265,10 +263,10 @@ void main() {
packageConfig:
PackageConfig
.
empty
,
packageConfig:
PackageConfig
.
empty
,
packagesPath:
'.packages'
,
packagesPath:
'.packages'
,
);
);
stdoutHandler
.
compilerOutput
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
stdoutHandler
.
compilerOutput
?
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
completer
.
complete
();
completer
.
complete
();
expect
((
await
output
).
outputFilename
,
''
);
expect
((
await
output
)
?
.
outputFilename
,
''
);
});
});
testWithoutContext
(
'KernelCompiler passes dartDefines to the frontend_server'
,
()
async
{
testWithoutContext
(
'KernelCompiler passes dartDefines to the frontend_server'
,
()
async
{
...
@@ -305,7 +303,7 @@ void main() {
...
@@ -305,7 +303,7 @@ void main() {
stdoutHandler:
stdoutHandler
,
stdoutHandler:
stdoutHandler
,
);
);
final
Future
<
CompilerOutput
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
final
Future
<
CompilerOutput
?
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
mainPath:
'/path/to/main.dart'
,
mainPath:
'/path/to/main.dart'
,
buildMode:
BuildMode
.
debug
,
buildMode:
BuildMode
.
debug
,
trackWidgetCreation:
false
,
trackWidgetCreation:
false
,
...
@@ -314,10 +312,10 @@ void main() {
...
@@ -314,10 +312,10 @@ void main() {
packagesPath:
'.packages'
,
packagesPath:
'.packages'
,
);
);
stdoutHandler
.
compilerOutput
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
stdoutHandler
.
compilerOutput
?
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
completer
.
complete
();
completer
.
complete
();
expect
((
await
output
).
outputFilename
,
''
);
expect
((
await
output
)
?
.
outputFilename
,
''
);
});
});
testWithoutContext
(
'KernelCompiler maps a file to a multi-root scheme if provided'
,
()
async
{
testWithoutContext
(
'KernelCompiler maps a file to a multi-root scheme if provided'
,
()
async
{
...
@@ -354,7 +352,7 @@ void main() {
...
@@ -354,7 +352,7 @@ void main() {
stdoutHandler:
stdoutHandler
,
stdoutHandler:
stdoutHandler
,
);
);
final
Future
<
CompilerOutput
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
final
Future
<
CompilerOutput
?
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
mainPath:
'/foo/bar/fizz/main.dart'
,
mainPath:
'/foo/bar/fizz/main.dart'
,
buildMode:
BuildMode
.
debug
,
buildMode:
BuildMode
.
debug
,
trackWidgetCreation:
false
,
trackWidgetCreation:
false
,
...
@@ -363,10 +361,10 @@ void main() {
...
@@ -363,10 +361,10 @@ void main() {
packagesPath:
'.packages'
,
packagesPath:
'.packages'
,
);
);
stdoutHandler
.
compilerOutput
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
stdoutHandler
.
compilerOutput
?
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
completer
.
complete
();
completer
.
complete
();
expect
((
await
output
).
outputFilename
,
''
);
expect
((
await
output
)
?
.
outputFilename
,
''
);
});
});
testWithoutContext
(
'KernelCompiler uses generated entrypoint'
,
()
async
{
testWithoutContext
(
'KernelCompiler uses generated entrypoint'
,
()
async
{
...
@@ -409,7 +407,7 @@ void main() {
...
@@ -409,7 +407,7 @@ void main() {
buildDir
.
parent
.
childFile
(
'generated_main.dart'
).
createSync
(
recursive:
true
);
buildDir
.
parent
.
childFile
(
'generated_main.dart'
).
createSync
(
recursive:
true
);
final
Future
<
CompilerOutput
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
final
Future
<
CompilerOutput
?
>
output
=
kernelCompiler
.
compile
(
sdkRoot:
'/path/to/sdkroot'
,
mainPath:
'/foo/bar/fizz/main.dart'
,
mainPath:
'/foo/bar/fizz/main.dart'
,
buildMode:
BuildMode
.
debug
,
buildMode:
BuildMode
.
debug
,
trackWidgetCreation:
false
,
trackWidgetCreation:
false
,
...
@@ -420,7 +418,7 @@ void main() {
...
@@ -420,7 +418,7 @@ void main() {
checkDartPluginRegistry:
true
,
checkDartPluginRegistry:
true
,
);
);
stdoutHandler
.
compilerOutput
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
stdoutHandler
.
compilerOutput
?
.
complete
(
const
CompilerOutput
(
''
,
0
,
<
Uri
>[]));
completer
.
complete
();
completer
.
complete
();
await
output
;
await
output
;
});
});
...
...
packages/flutter_tools/test/general.shard/compile_expression_test.dart
View file @
4bcf8fb4
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
...
@@ -24,12 +22,12 @@ import '../src/fake_process_manager.dart';
...
@@ -24,12 +22,12 @@ import '../src/fake_process_manager.dart';
import
'../src/fakes.dart'
;
import
'../src/fakes.dart'
;
void
main
(
)
{
void
main
(
)
{
FakeProcessManager
processManager
;
late
FakeProcessManager
processManager
;
ResidentCompiler
generator
;
late
ResidentCompiler
generator
;
MemoryIOSink
frontendServerStdIn
;
late
MemoryIOSink
frontendServerStdIn
;
StreamController
<
String
>
stdErrStreamController
;
late
StreamController
<
String
>
stdErrStreamController
;
BufferLogger
testLogger
;
late
BufferLogger
testLogger
;
MemoryFileSystem
fileSystem
;
late
MemoryFileSystem
fileSystem
;
setUp
(()
{
setUp
(()
{
testLogger
=
BufferLogger
.
test
();
testLogger
=
BufferLogger
.
test
();
...
@@ -52,7 +50,7 @@ void main() {
...
@@ -52,7 +50,7 @@ void main() {
});
});
testWithoutContext
(
'compile expression fails if not previously compiled'
,
()
async
{
testWithoutContext
(
'compile expression fails if not previously compiled'
,
()
async
{
final
CompilerOutput
result
=
await
generator
.
compileExpression
(
final
CompilerOutput
?
result
=
await
generator
.
compileExpression
(
'2+2'
,
null
,
null
,
null
,
null
,
false
);
'2+2'
,
null
,
null
,
null
,
null
,
false
);
expect
(
result
,
isNull
);
expect
(
result
,
isNull
);
...
@@ -82,12 +80,12 @@ void main() {
...
@@ -82,12 +80,12 @@ void main() {
packageConfig:
PackageConfig
.
empty
,
packageConfig:
PackageConfig
.
empty
,
projectRootPath:
''
,
projectRootPath:
''
,
fs:
fileSystem
,
fs:
fileSystem
,
).
then
((
CompilerOutput
output
)
{
).
then
((
CompilerOutput
?
output
)
{
expect
(
frontendServerStdIn
.
getAndClear
(),
expect
(
frontendServerStdIn
.
getAndClear
(),
'compile file:///path/to/main.dart
\n
'
);
'compile file:///path/to/main.dart
\n
'
);
expect
(
testLogger
.
errorText
,
expect
(
testLogger
.
errorText
,
equals
(
'line1
\n
line2
\n
'
));
equals
(
'line1
\n
line2
\n
'
));
expect
(
output
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
expect
(
output
!
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
compileExpressionResponseCompleter
.
complete
(
compileExpressionResponseCompleter
.
complete
(
Future
<
List
<
int
>>.
value
(
utf8
.
encode
(
Future
<
List
<
int
>>.
value
(
utf8
.
encode
(
...
@@ -95,9 +93,9 @@ void main() {
...
@@ -95,9 +93,9 @@ void main() {
)));
)));
generator
.
compileExpression
(
generator
.
compileExpression
(
'2+2'
,
null
,
null
,
null
,
null
,
false
).
then
(
'2+2'
,
null
,
null
,
null
,
null
,
false
).
then
(
(
CompilerOutput
outputExpression
)
{
(
CompilerOutput
?
outputExpression
)
{
expect
(
outputExpression
,
isNotNull
);
expect
(
outputExpression
,
isNotNull
);
expect
(
outputExpression
.
expressionData
,
<
int
>[
1
,
2
,
3
,
4
]);
expect
(
outputExpression
!
.
expressionData
,
<
int
>[
1
,
2
,
3
,
4
]);
}
}
);
);
});
});
...
@@ -126,10 +124,10 @@ void main() {
...
@@ -126,10 +124,10 @@ void main() {
packageConfig:
PackageConfig
.
empty
,
packageConfig:
PackageConfig
.
empty
,
projectRootPath:
''
,
projectRootPath:
''
,
fs:
MemoryFileSystem
(),
fs:
MemoryFileSystem
(),
).
then
((
CompilerOutput
outputCompile
)
{
).
then
((
CompilerOutput
?
outputCompile
)
{
expect
(
testLogger
.
errorText
,
expect
(
testLogger
.
errorText
,
equals
(
'line1
\n
line2
\n
'
));
equals
(
'line1
\n
line2
\n
'
));
expect
(
outputCompile
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
expect
(
outputCompile
!
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
fileSystem
.
file
(
'/path/to/main.dart.dill.incremental'
)
fileSystem
.
file
(
'/path/to/main.dart.dill.incremental'
)
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
...
@@ -144,9 +142,9 @@ void main() {
...
@@ -144,9 +142,9 @@ void main() {
final
Completer
<
bool
>
lastExpressionCompleted
=
Completer
<
bool
>();
final
Completer
<
bool
>
lastExpressionCompleted
=
Completer
<
bool
>();
unawaited
(
unawaited
(
generator
.
compileExpression
(
'0+1'
,
null
,
null
,
null
,
null
,
false
).
then
(
generator
.
compileExpression
(
'0+1'
,
null
,
null
,
null
,
null
,
false
).
then
(
(
CompilerOutput
outputExpression
)
{
(
CompilerOutput
?
outputExpression
)
{
expect
(
outputExpression
,
isNotNull
);
expect
(
outputExpression
,
isNotNull
);
expect
(
outputExpression
.
expressionData
,
<
int
>[
0
,
1
,
2
,
3
]);
expect
(
outputExpression
!
.
expressionData
,
<
int
>[
0
,
1
,
2
,
3
]);
fileSystem
.
file
(
'/path/to/main.dart.dill.incremental'
)
fileSystem
.
file
(
'/path/to/main.dart.dill.incremental'
)
..
createSync
(
recursive:
true
)
..
createSync
(
recursive:
true
)
...
@@ -161,9 +159,9 @@ void main() {
...
@@ -161,9 +159,9 @@ void main() {
// The test manages timing via completers.
// The test manages timing via completers.
unawaited
(
unawaited
(
generator
.
compileExpression
(
'1+1'
,
null
,
null
,
null
,
null
,
false
).
then
(
generator
.
compileExpression
(
'1+1'
,
null
,
null
,
null
,
null
,
false
).
then
(
(
CompilerOutput
outputExpression
)
{
(
CompilerOutput
?
outputExpression
)
{
expect
(
outputExpression
,
isNotNull
);
expect
(
outputExpression
,
isNotNull
);
expect
(
outputExpression
.
expressionData
,
<
int
>[
4
,
5
,
6
,
7
]);
expect
(
outputExpression
!
.
expressionData
,
<
int
>[
4
,
5
,
6
,
7
]);
lastExpressionCompleted
.
complete
(
true
);
lastExpressionCompleted
.
complete
(
true
);
},
},
),
),
...
@@ -179,13 +177,13 @@ void main() {
...
@@ -179,13 +177,13 @@ void main() {
class
FakeProcess
extends
Fake
implements
Process
{
class
FakeProcess
extends
Fake
implements
Process
{
@override
@override
Stream
<
List
<
int
>>
stdout
;
Stream
<
List
<
int
>>
stdout
=
const
Stream
<
List
<
int
>>.
empty
()
;
@override
@override
Stream
<
List
<
int
>>
stderr
;
Stream
<
List
<
int
>>
stderr
=
const
Stream
<
List
<
int
>>.
empty
()
;
@override
@override
IOSink
stdin
;
IOSink
stdin
=
IOSink
(
StreamController
<
List
<
int
>>().
sink
)
;
@override
@override
Future
<
int
>
get
exitCode
=>
Completer
<
int
>().
future
;
Future
<
int
>
get
exitCode
=>
Completer
<
int
>().
future
;
...
@@ -195,12 +193,12 @@ class FakeProcessManager extends Fake implements ProcessManager {
...
@@ -195,12 +193,12 @@ class FakeProcessManager extends Fake implements ProcessManager {
final
FakeProcess
process
=
FakeProcess
();
final
FakeProcess
process
=
FakeProcess
();
@override
@override
bool
canRun
(
dynamic
executable
,
{
String
workingDirectory
})
{
bool
canRun
(
dynamic
executable
,
{
String
?
workingDirectory
})
{
return
true
;
return
true
;
}
}
@override
@override
Future
<
Process
>
start
(
List
<
Object
>
command
,
{
String
workingDirectory
,
Map
<
String
,
String
>
environment
,
bool
includeParentEnvironment
=
true
,
bool
runInShell
=
false
,
ProcessStartMode
mode
=
ProcessStartMode
.
normal
})
async
{
Future
<
Process
>
start
(
List
<
Object
>
command
,
{
String
?
workingDirectory
,
Map
<
String
,
String
>?
environment
,
bool
includeParentEnvironment
=
true
,
bool
runInShell
=
false
,
ProcessStartMode
mode
=
ProcessStartMode
.
normal
})
async
{
return
process
;
return
process
;
}
}
}
}
packages/flutter_tools/test/general.shard/compile_incremental_test.dart
View file @
4bcf8fb4
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
...
@@ -21,13 +19,13 @@ import '../src/fake_process_manager.dart';
...
@@ -21,13 +19,13 @@ import '../src/fake_process_manager.dart';
import
'../src/fakes.dart'
;
import
'../src/fakes.dart'
;
void
main
(
)
{
void
main
(
)
{
ResidentCompiler
generator
;
late
ResidentCompiler
generator
;
ResidentCompiler
generatorWithScheme
;
late
ResidentCompiler
generatorWithScheme
;
MemoryIOSink
frontendServerStdIn
;
late
MemoryIOSink
frontendServerStdIn
;
BufferLogger
testLogger
;
late
BufferLogger
testLogger
;
StdoutHandler
generatorStdoutHandler
;
late
StdoutHandler
generatorStdoutHandler
;
StdoutHandler
generatorWithSchemeStdoutHandler
;
late
StdoutHandler
generatorWithSchemeStdoutHandler
;
FakeProcessManager
fakeProcessManager
;
late
FakeProcessManager
fakeProcessManager
;
const
List
<
String
>
frontendServerCommand
=
<
String
>[
const
List
<
String
>
frontendServerCommand
=
<
String
>[
'HostArtifact.engineDartBinary'
,
'HostArtifact.engineDartBinary'
,
...
@@ -87,7 +85,7 @@ void main() {
...
@@ -87,7 +85,7 @@ void main() {
stdin:
frontendServerStdIn
,
stdin:
frontendServerStdIn
,
));
));
final
CompilerOutput
output
=
await
generator
.
recompile
(
final
CompilerOutput
?
output
=
await
generator
.
recompile
(
Uri
.
parse
(
'/path/to/main.dart'
),
Uri
.
parse
(
'/path/to/main.dart'
),
null
/* invalidatedFiles */
,
null
/* invalidatedFiles */
,
outputPath:
'/build/'
,
outputPath:
'/build/'
,
...
@@ -97,7 +95,7 @@ void main() {
...
@@ -97,7 +95,7 @@ void main() {
);
);
expect
(
frontendServerStdIn
.
getAndClear
(),
'compile /path/to/main.dart
\n
'
);
expect
(
frontendServerStdIn
.
getAndClear
(),
'compile /path/to/main.dart
\n
'
);
expect
(
testLogger
.
errorText
,
equals
(
'line1
\n
line2
\n
'
));
expect
(
testLogger
.
errorText
,
equals
(
'line1
\n
line2
\n
'
));
expect
(
output
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
expect
(
output
?
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
});
});
...
@@ -114,7 +112,7 @@ void main() {
...
@@ -114,7 +112,7 @@ void main() {
stdin:
frontendServerStdIn
,
stdin:
frontendServerStdIn
,
));
));
final
CompilerOutput
output
=
await
generatorWithScheme
.
recompile
(
final
CompilerOutput
?
output
=
await
generatorWithScheme
.
recompile
(
Uri
.
parse
(
'file:///foo/bar/fizz/main.dart'
),
Uri
.
parse
(
'file:///foo/bar/fizz/main.dart'
),
null
/* invalidatedFiles */
,
null
/* invalidatedFiles */
,
outputPath:
'/build/'
,
outputPath:
'/build/'
,
...
@@ -124,7 +122,7 @@ void main() {
...
@@ -124,7 +122,7 @@ void main() {
);
);
expect
(
frontendServerStdIn
.
getAndClear
(),
'compile scheme:///main.dart
\n
'
);
expect
(
frontendServerStdIn
.
getAndClear
(),
'compile scheme:///main.dart
\n
'
);
expect
(
testLogger
.
errorText
,
equals
(
'line1
\n
line2
\n
'
));
expect
(
testLogger
.
errorText
,
equals
(
'line1
\n
line2
\n
'
));
expect
(
output
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
expect
(
output
?
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
});
});
...
@@ -401,16 +399,16 @@ Future<void> _recompile(
...
@@ -401,16 +399,16 @@ Future<void> _recompile(
MemoryIOSink
frontendServerStdIn
,
MemoryIOSink
frontendServerStdIn
,
String
mockCompilerOutput
,
{
String
mockCompilerOutput
,
{
bool
suppressErrors
=
false
,
bool
suppressErrors
=
false
,
Uri
mainUri
,
Uri
?
mainUri
,
String
expectedMainUri
=
'/path/to/main.dart'
,
String
expectedMainUri
=
'/path/to/main.dart'
,
List
<
Uri
>
updatedUris
,
List
<
Uri
>
?
updatedUris
,
List
<
String
>
expectedUpdatedUris
,
List
<
String
>
?
expectedUpdatedUris
,
})
async
{
})
async
{
mainUri
??=
Uri
.
parse
(
'/path/to/main.dart'
);
mainUri
??=
Uri
.
parse
(
'/path/to/main.dart'
);
updatedUris
??=
<
Uri
>[
mainUri
];
updatedUris
??=
<
Uri
>[
mainUri
];
expectedUpdatedUris
??=
<
String
>[
expectedMainUri
];
expectedUpdatedUris
??=
<
String
>[
expectedMainUri
];
final
Future
<
CompilerOutput
>
recompileFuture
=
generator
.
recompile
(
final
Future
<
CompilerOutput
?
>
recompileFuture
=
generator
.
recompile
(
mainUri
,
mainUri
,
updatedUris
,
updatedUris
,
outputPath:
'/build/'
,
outputPath:
'/build/'
,
...
@@ -425,8 +423,8 @@ Future<void> _recompile(
...
@@ -425,8 +423,8 @@ Future<void> _recompile(
scheduleMicrotask
(()
{
scheduleMicrotask
(()
{
LineSplitter
.
split
(
mockCompilerOutput
).
forEach
(
stdoutHandler
.
handler
);
LineSplitter
.
split
(
mockCompilerOutput
).
forEach
(
stdoutHandler
.
handler
);
});
});
final
CompilerOutput
output
=
await
recompileFuture
;
final
CompilerOutput
?
output
=
await
recompileFuture
;
expect
(
output
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
expect
(
output
?
.
outputFilename
,
equals
(
'/path/to/main.dart.dill'
));
final
String
commands
=
frontendServerStdIn
.
getAndClear
();
final
String
commands
=
frontendServerStdIn
.
getAndClear
();
final
RegExp
whitespace
=
RegExp
(
r'\s+'
);
final
RegExp
whitespace
=
RegExp
(
r'\s+'
);
final
List
<
String
>
parts
=
commands
.
split
(
whitespace
);
final
List
<
String
>
parts
=
commands
.
split
(
whitespace
);
...
@@ -459,11 +457,11 @@ Future<void> _reject(
...
@@ -459,11 +457,11 @@ Future<void> _reject(
)
async
{
)
async
{
// Put content into the output stream after generator.recompile gets
// Put content into the output stream after generator.recompile gets
// going few lines below, resets completer.
// going few lines below, resets completer.
final
Future
<
CompilerOutput
>
rejectFuture
=
generator
.
reject
();
final
Future
<
CompilerOutput
?
>
rejectFuture
=
generator
.
reject
();
scheduleMicrotask
(()
{
scheduleMicrotask
(()
{
LineSplitter
.
split
(
mockCompilerOutput
).
forEach
(
stdoutHandler
.
handler
);
LineSplitter
.
split
(
mockCompilerOutput
).
forEach
(
stdoutHandler
.
handler
);
});
});
final
CompilerOutput
output
=
await
rejectFuture
;
final
CompilerOutput
?
output
=
await
rejectFuture
;
expect
(
output
,
isNull
);
expect
(
output
,
isNull
);
final
String
commands
=
frontendServerStdIn
.
getAndClear
();
final
String
commands
=
frontendServerStdIn
.
getAndClear
();
...
...
packages/flutter_tools/test/general.shard/compile_test.dart
View file @
4bcf8fb4
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:file/file.dart'
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
...
@@ -19,10 +17,10 @@ void main() {
...
@@ -19,10 +17,10 @@ void main() {
expect
(
stdoutHandler
.
boundaryKey
,
'12345'
);
expect
(
stdoutHandler
.
boundaryKey
,
'12345'
);
stdoutHandler
.
handler
(
'12345'
);
stdoutHandler
.
handler
(
'12345'
);
stdoutHandler
.
handler
(
'12345 message 0'
);
stdoutHandler
.
handler
(
'12345 message 0'
);
final
CompilerOutput
output
=
await
stdoutHandler
.
compilerOutput
.
future
;
final
CompilerOutput
?
output
=
await
stdoutHandler
.
compilerOutput
?
.
future
;
expect
(
output
.
errorCount
,
0
);
expect
(
output
?
.
errorCount
,
0
);
expect
(
output
.
outputFilename
,
'message'
);
expect
(
output
?
.
outputFilename
,
'message'
);
expect
(
output
.
expressionData
,
null
);
expect
(
output
?
.
expressionData
,
null
);
});
});
testWithoutContext
(
'StdoutHandler can read output bytes'
,
()
async
{
testWithoutContext
(
'StdoutHandler can read output bytes'
,
()
async
{
...
@@ -35,11 +33,11 @@ void main() {
...
@@ -35,11 +33,11 @@ void main() {
expect
(
stdoutHandler
.
boundaryKey
,
'12345'
);
expect
(
stdoutHandler
.
boundaryKey
,
'12345'
);
stdoutHandler
.
handler
(
'12345'
);
stdoutHandler
.
handler
(
'12345'
);
stdoutHandler
.
handler
(
'12345 message 0'
);
stdoutHandler
.
handler
(
'12345 message 0'
);
final
CompilerOutput
output
=
await
stdoutHandler
.
compilerOutput
.
future
;
final
CompilerOutput
?
output
=
await
stdoutHandler
.
compilerOutput
?
.
future
;
expect
(
output
.
errorCount
,
0
);
expect
(
output
?
.
errorCount
,
0
);
expect
(
output
.
outputFilename
,
'message'
);
expect
(
output
?
.
outputFilename
,
'message'
);
expect
(
output
.
expressionData
,
<
int
>[
1
,
2
,
3
,
4
]);
expect
(
output
?
.
expressionData
,
<
int
>[
1
,
2
,
3
,
4
]);
});
});
testWithoutContext
(
'StdoutHandler reads output bytes if errorCount > 0'
,
()
async
{
testWithoutContext
(
'StdoutHandler reads output bytes if errorCount > 0'
,
()
async
{
...
@@ -52,11 +50,11 @@ void main() {
...
@@ -52,11 +50,11 @@ void main() {
expect
(
stdoutHandler
.
boundaryKey
,
'12345'
);
expect
(
stdoutHandler
.
boundaryKey
,
'12345'
);
stdoutHandler
.
handler
(
'12345'
);
stdoutHandler
.
handler
(
'12345'
);
stdoutHandler
.
handler
(
'12345 message 1'
);
stdoutHandler
.
handler
(
'12345 message 1'
);
final
CompilerOutput
output
=
await
stdoutHandler
.
compilerOutput
.
future
;
final
CompilerOutput
?
output
=
await
stdoutHandler
.
compilerOutput
?
.
future
;
expect
(
output
.
errorCount
,
1
);
expect
(
output
?
.
errorCount
,
1
);
expect
(
output
.
outputFilename
,
'message'
);
expect
(
output
?
.
outputFilename
,
'message'
);
expect
(
output
.
expressionData
,
<
int
>[
1
,
2
,
3
,
4
]);
expect
(
output
?
.
expressionData
,
<
int
>[
1
,
2
,
3
,
4
]);
});
});
testWithoutContext
(
'TargetModel values'
,
()
{
testWithoutContext
(
'TargetModel values'
,
()
{
...
@@ -72,7 +70,7 @@ void main() {
...
@@ -72,7 +70,7 @@ void main() {
expect
(
TargetModel
(
'dartdevc'
),
TargetModel
.
dartdevc
);
expect
(
TargetModel
(
'dartdevc'
),
TargetModel
.
dartdevc
);
expect
(
TargetModel
.
dartdevc
.
toString
(),
'dartdevc'
);
expect
(
TargetModel
.
dartdevc
.
toString
(),
'dartdevc'
);
expect
(()
=>
TargetModel
(
'foobar'
),
throws
AssertionError
);
expect
(()
=>
TargetModel
(
'foobar'
),
throws
Exception
);
});
});
testWithoutContext
(
'toMultiRootPath maps different URIs'
,
()
async
{
testWithoutContext
(
'toMultiRootPath maps different URIs'
,
()
async
{
...
...
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