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
acd68cf4
Unverified
Commit
acd68cf4
authored
Jun 14, 2021
by
Lau Ching Jun
Committed by
GitHub
Jun 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compile expression in tests when precompiled dill files are used. (#84470)
parent
7773d0b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
18 deletions
+58
-18
flutter_platform.dart
packages/flutter_tools/lib/src/test/flutter_platform.dart
+9
-0
test_compiler.dart
packages/flutter_tools/lib/src/test/test_compiler.dart
+28
-16
test_compiler_test.dart
...ter_tools/test/general.shard/test/test_compiler_test.dart
+21
-2
No files found.
packages/flutter_tools/lib/src/test/flutter_platform.dart
View file @
acd68cf4
...
@@ -451,6 +451,15 @@ class FlutterPlatform extends PlatformPlugin {
...
@@ -451,6 +451,15 @@ class FlutterPlatform extends PlatformPlugin {
String
mainDart
;
String
mainDart
;
if
(
precompiledDillPath
!=
null
)
{
if
(
precompiledDillPath
!=
null
)
{
mainDart
=
precompiledDillPath
;
mainDart
=
precompiledDillPath
;
// When start paused is specified, it means that the user is likely
// running this with a debugger attached. Initialize the resident
// compiler in this case.
if
(
debuggingOptions
.
startPaused
)
{
compiler
??=
TestCompiler
(
debuggingOptions
.
buildInfo
,
flutterProject
,
precompiledDillPath:
precompiledDillPath
);
final
Uri
testUri
=
globals
.
fs
.
file
(
testPath
).
uri
;
// Trigger a compilation to initialize the resident compiler.
unawaited
(
compiler
.
compile
(
testUri
));
}
}
else
if
(
precompiledDillFiles
!=
null
)
{
}
else
if
(
precompiledDillFiles
!=
null
)
{
mainDart
=
precompiledDillFiles
[
testPath
];
mainDart
=
precompiledDillFiles
[
testPath
];
}
else
{
}
else
{
...
...
packages/flutter_tools/lib/src/test/test_compiler.dart
View file @
acd68cf4
...
@@ -36,10 +36,14 @@ class TestCompiler {
...
@@ -36,10 +36,14 @@ class TestCompiler {
/// extension.
/// extension.
///
///
/// [flutterProject] is the project for which we are running tests.
/// [flutterProject] is the project for which we are running tests.
///
/// If [precompiledDillPath] is passed, it will be used to initialize the
/// compiler.
TestCompiler
(
TestCompiler
(
this
.
buildInfo
,
this
.
buildInfo
,
this
.
flutterProject
,
this
.
flutterProject
,
)
:
testFilePath
=
globals
.
fs
.
path
.
join
(
{
String
precompiledDillPath
}
)
:
testFilePath
=
precompiledDillPath
??
globals
.
fs
.
path
.
join
(
flutterProject
.
directory
.
path
,
flutterProject
.
directory
.
path
,
getBuildDirectory
(),
getBuildDirectory
(),
'test_cache'
,
'test_cache'
,
...
@@ -47,7 +51,8 @@ class TestCompiler {
...
@@ -47,7 +51,8 @@ class TestCompiler {
trackWidgetCreation:
buildInfo
.
trackWidgetCreation
,
trackWidgetCreation:
buildInfo
.
trackWidgetCreation
,
dartDefines:
buildInfo
.
dartDefines
,
dartDefines:
buildInfo
.
dartDefines
,
extraFrontEndOptions:
buildInfo
.
extraFrontEndOptions
,
extraFrontEndOptions:
buildInfo
.
extraFrontEndOptions
,
))
{
)),
shouldCopyDillFile
=
precompiledDillPath
==
null
{
// Compiler maintains and updates single incremental dill file.
// Compiler maintains and updates single incremental dill file.
// Incremental compilation requests done for each test copy that file away
// Incremental compilation requests done for each test copy that file away
// for independent execution.
// for independent execution.
...
@@ -66,6 +71,7 @@ class TestCompiler {
...
@@ -66,6 +71,7 @@ class TestCompiler {
final
FlutterProject
flutterProject
;
final
FlutterProject
flutterProject
;
final
BuildInfo
buildInfo
;
final
BuildInfo
buildInfo
;
final
String
testFilePath
;
final
String
testFilePath
;
final
bool
shouldCopyDillFile
;
ResidentCompiler
compiler
;
ResidentCompiler
compiler
;
...
@@ -112,6 +118,8 @@ class TestCompiler {
...
@@ -112,6 +118,8 @@ class TestCompiler {
platform:
globals
.
platform
,
platform:
globals
.
platform
,
testCompilation:
true
,
testCompilation:
true
,
fileSystem:
globals
.
fs
,
fileSystem:
globals
.
fs
,
fileSystemRoots:
buildInfo
.
fileSystemRoots
,
fileSystemScheme:
buildInfo
.
fileSystemScheme
,
);
);
return
residentCompiler
;
return
residentCompiler
;
}
}
...
@@ -140,7 +148,7 @@ class TestCompiler {
...
@@ -140,7 +148,7 @@ class TestCompiler {
<
Uri
>[
request
.
mainUri
],
<
Uri
>[
request
.
mainUri
],
outputPath:
outputDill
.
path
,
outputPath:
outputDill
.
path
,
packageConfig:
buildInfo
.
packageConfig
,
packageConfig:
buildInfo
.
packageConfig
,
projectRootPath:
flutterProject
.
directory
.
absolute
.
path
,
projectRootPath:
flutterProject
?.
directory
?.
absolute
?
.
path
,
fs:
globals
.
fs
,
fs:
globals
.
fs
,
);
);
final
String
outputPath
=
compilerOutput
?.
outputFilename
;
final
String
outputPath
=
compilerOutput
?.
outputFilename
;
...
@@ -149,28 +157,32 @@ class TestCompiler {
...
@@ -149,28 +157,32 @@ class TestCompiler {
// errors, pass [null] upwards to the consumer and shutdown the
// errors, pass [null] upwards to the consumer and shutdown the
// compiler to avoid reusing compiler that might have gotten into
// compiler to avoid reusing compiler that might have gotten into
// a weird state.
// a weird state.
final
String
path
=
request
.
mainUri
.
toFilePath
(
windows:
globals
.
platform
.
isWindows
);
if
(
outputPath
==
null
||
compilerOutput
.
errorCount
>
0
)
{
if
(
outputPath
==
null
||
compilerOutput
.
errorCount
>
0
)
{
request
.
result
.
complete
(
null
);
request
.
result
.
complete
(
null
);
await
_shutdown
();
await
_shutdown
();
}
else
{
}
else
{
final
File
outputFile
=
globals
.
fs
.
file
(
outputPath
);
if
(
shouldCopyDillFile
)
{
final
File
kernelReadyToRun
=
await
outputFile
.
copy
(
'
$path
.dill'
);
final
String
path
=
request
.
mainUri
.
toFilePath
(
windows:
globals
.
platform
.
isWindows
);
final
File
testCache
=
globals
.
fs
.
file
(
testFilePath
);
final
File
outputFile
=
globals
.
fs
.
file
(
outputPath
);
if
(
firstCompile
||
!
testCache
.
existsSync
()
||
(
testCache
.
lengthSync
()
<
outputFile
.
lengthSync
()))
{
final
File
kernelReadyToRun
=
await
outputFile
.
copy
(
'
$path
.dill'
);
// The idea is to keep the cache file up-to-date and include as
final
File
testCache
=
globals
.
fs
.
file
(
testFilePath
);
// much as possible in an effort to re-use as many packages as
if
(
firstCompile
||
!
testCache
.
existsSync
()
||
(
testCache
.
lengthSync
()
<
outputFile
.
lengthSync
()))
{
// possible.
// The idea is to keep the cache file up-to-date and include as
if
(!
testCache
.
parent
.
existsSync
())
{
// much as possible in an effort to re-use as many packages as
testCache
.
parent
.
createSync
(
recursive:
true
);
// possible.
if
(!
testCache
.
parent
.
existsSync
())
{
testCache
.
parent
.
createSync
(
recursive:
true
);
}
await
outputFile
.
copy
(
testFilePath
);
}
}
await
outputFile
.
copy
(
testFilePath
);
request
.
result
.
complete
(
kernelReadyToRun
.
path
);
}
else
{
request
.
result
.
complete
(
outputPath
);
}
}
request
.
result
.
complete
(
kernelReadyToRun
.
path
);
compiler
.
accept
();
compiler
.
accept
();
compiler
.
reset
();
compiler
.
reset
();
}
}
globals
.
printTrace
(
'Compiling
$
path
took
${compilerTime.elapsedMilliseconds}
ms'
);
globals
.
printTrace
(
'Compiling
$
{request.mainUri}
took
${compilerTime.elapsedMilliseconds}
ms'
);
// Only remove now when we finished processing the element
// Only remove now when we finished processing the element
compilationQueue
.
removeAt
(
0
);
compilationQueue
.
removeAt
(
0
);
}
}
...
...
packages/flutter_tools/test/general.shard/test/test_compiler_test.dart
View file @
acd68cf4
...
@@ -59,6 +59,23 @@ void main() {
...
@@ -59,6 +59,23 @@ void main() {
Logger:
()
=>
BufferLogger
.
test
(),
Logger:
()
=>
BufferLogger
.
test
(),
});
});
testUsingContext
(
'TestCompiler does not try to cache the dill file when precompiled dill is passed'
,
()
async
{
residentCompiler
.
compilerOutput
=
const
CompilerOutput
(
'abc.dill'
,
0
,
<
Uri
>[]);
final
FakeTestCompiler
testCompiler
=
FakeTestCompiler
(
debugBuild
,
FlutterProject
.
fromDirectoryTest
(
fileSystem
.
currentDirectory
),
residentCompiler
,
precompiledDillPath:
'precompiled.dill'
,
);
expect
(
await
testCompiler
.
compile
(
Uri
.
parse
(
'test/foo.dart'
)),
'abc.dill'
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
Platform:
()
=>
linuxPlatform
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Logger:
()
=>
BufferLogger
.
test
(),
});
testUsingContext
(
'TestCompiler reports null when a compile fails'
,
()
async
{
testUsingContext
(
'TestCompiler reports null when a compile fails'
,
()
async
{
residentCompiler
.
compilerOutput
=
const
CompilerOutput
(
'abc.dill'
,
1
,
<
Uri
>[]);
residentCompiler
.
compilerOutput
=
const
CompilerOutput
(
'abc.dill'
,
1
,
<
Uri
>[]);
final
FakeTestCompiler
testCompiler
=
FakeTestCompiler
(
final
FakeTestCompiler
testCompiler
=
FakeTestCompiler
(
...
@@ -103,8 +120,10 @@ class FakeTestCompiler extends TestCompiler {
...
@@ -103,8 +120,10 @@ class FakeTestCompiler extends TestCompiler {
FakeTestCompiler
(
FakeTestCompiler
(
BuildInfo
buildInfo
,
BuildInfo
buildInfo
,
FlutterProject
flutterProject
,
FlutterProject
flutterProject
,
this
.
residentCompiler
,
this
.
residentCompiler
,
{
)
:
super
(
buildInfo
,
flutterProject
);
String
precompiledDillPath
,
}
)
:
super
(
buildInfo
,
flutterProject
,
precompiledDillPath:
precompiledDillPath
);
final
FakeResidentCompiler
residentCompiler
;
final
FakeResidentCompiler
residentCompiler
;
...
...
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