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
c130aa95
Unverified
Commit
c130aa95
authored
Jun 04, 2020
by
Jenn Magder
Committed by
GitHub
Jun 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add FakeAsync to delay tests (#58644)
parent
e48e2e6a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
40 deletions
+62
-40
process_test.dart
...s/flutter_tools/test/general.shard/base/process_test.dart
+31
-16
devfs_test.dart
packages/flutter_tools/test/general.shard/devfs_test.dart
+19
-15
ios_device_start_nonprebuilt_test.dart
.../general.shard/ios/ios_device_start_nonprebuilt_test.dart
+12
-9
No files found.
packages/flutter_tools/test/general.shard/base/process_test.dart
View file @
c130aa95
...
...
@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/base/process.dart';
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'package:quiver/testing/async.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
...
...
@@ -193,11 +194,16 @@ void main() {
flakes:
1
,
delay:
delay
,
);
final
RunResult
result
=
await
flakyProcessUtils
.
run
(
<
String
>[
'dummy'
],
timeout:
delay
+
const
Duration
(
seconds:
1
),
);
expect
(
result
.
exitCode
,
-
9
);
FakeAsync
().
run
((
FakeAsync
time
)
async
{
final
Duration
timeout
=
delay
+
const
Duration
(
seconds:
1
);
final
RunResult
result
=
await
flakyProcessUtils
.
run
(
<
String
>[
'dummy'
],
timeout:
timeout
,
);
time
.
elapse
(
timeout
);
expect
(
result
.
exitCode
,
-
9
);
});
});
testWithoutContext
(
' flaky process succeeds with retry'
,
()
async
{
...
...
@@ -205,12 +211,16 @@ void main() {
flakes:
1
,
delay:
delay
,
);
final
RunResult
result
=
await
flakyProcessUtils
.
run
(
<
String
>[
'dummy'
],
timeout:
delay
-
const
Duration
(
milliseconds:
500
),
timeoutRetries:
1
,
);
expect
(
result
.
exitCode
,
0
);
FakeAsync
().
run
((
FakeAsync
time
)
async
{
final
Duration
timeout
=
delay
-
const
Duration
(
milliseconds:
500
);
final
RunResult
result
=
await
flakyProcessUtils
.
run
(
<
String
>[
'dummy'
],
timeout:
timeout
,
timeoutRetries:
1
,
);
time
.
elapse
(
timeout
);
expect
(
result
.
exitCode
,
0
);
});
});
testWithoutContext
(
' flaky process generates ProcessException on timeout'
,
()
async
{
...
...
@@ -230,11 +240,16 @@ void main() {
flakyStdout
.
complete
(<
int
>[]);
return
true
;
});
expect
(()
=>
flakyProcessUtils
.
run
(
<
String
>[
'dummy'
],
timeout:
delay
-
const
Duration
(
milliseconds:
500
),
timeoutRetries:
0
,
),
throwsA
(
isA
<
ProcessException
>()));
FakeAsync
().
run
((
FakeAsync
time
)
async
{
final
Duration
timeout
=
delay
-
const
Duration
(
milliseconds:
500
);
expect
(()
=>
flakyProcessUtils
.
run
(
<
String
>[
'dummy'
],
timeout:
timeout
,
timeoutRetries:
0
,
),
throwsA
(
isA
<
ProcessException
>()));
time
.
elapse
(
timeout
);
});
});
});
...
...
packages/flutter_tools/test/general.shard/devfs_test.dart
View file @
c130aa95
...
...
@@ -16,6 +16,7 @@ import 'package:flutter_tools/src/devfs.dart';
import
'package:flutter_tools/src/vmservice.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:package_config/package_config.dart'
;
import
'package:quiver/testing/async.dart'
;
import
'../src/common.dart'
;
import
'../src/context.dart'
;
...
...
@@ -140,21 +141,24 @@ void main() {
);
await
devFS
.
create
();
final
UpdateFSReport
report
=
await
devFS
.
update
(
mainUri:
Uri
.
parse
(
'lib/foo.txt'
),
dillOutputPath:
'lib/foo.dill'
,
generator:
residentCompiler
,
pathToReload:
'lib/foo.txt.dill'
,
trackWidgetCreation:
false
,
invalidatedFiles:
<
Uri
>[],
packageConfig:
PackageConfig
.
empty
,
);
expect
(
report
.
syncedBytes
,
5
);
expect
(
report
.
success
,
isTrue
);
verify
(
httpClient
.
putUrl
(
any
)).
called
(
kFailedAttempts
+
1
);
verify
(
httpRequest
.
close
()).
called
(
kFailedAttempts
+
1
);
verify
(
osUtils
.
gzipLevel1Stream
(
any
)).
called
(
kFailedAttempts
+
1
);
FakeAsync
().
run
((
FakeAsync
time
)
async
{
final
UpdateFSReport
report
=
await
devFS
.
update
(
mainUri:
Uri
.
parse
(
'lib/foo.txt'
),
dillOutputPath:
'lib/foo.dill'
,
generator:
residentCompiler
,
pathToReload:
'lib/foo.txt.dill'
,
trackWidgetCreation:
false
,
invalidatedFiles:
<
Uri
>[],
packageConfig:
PackageConfig
.
empty
,
);
time
.
elapse
(
const
Duration
(
seconds:
2
));
expect
(
report
.
syncedBytes
,
5
);
expect
(
report
.
success
,
isTrue
);
verify
(
httpClient
.
putUrl
(
any
)).
called
(
kFailedAttempts
+
1
);
verify
(
httpRequest
.
close
()).
called
(
kFailedAttempts
+
1
);
verify
(
osUtils
.
gzipLevel1Stream
(
any
)).
called
(
kFailedAttempts
+
1
);
});
});
testWithoutContext
(
'DevFS reports unsuccessful compile when errors are returned'
,
()
async
{
...
...
packages/flutter_tools/test/general.shard/ios/ios_device_start_nonprebuilt_test.dart
View file @
c130aa95
...
...
@@ -261,16 +261,19 @@ void main() {
])
);
final
LaunchResult
launchResult
=
await
iosDevice
.
startApp
(
buildableIOSApp
,
debuggingOptions:
DebuggingOptions
.
disabled
(
BuildInfo
.
release
),
platformArgs:
<
String
,
Object
>{},
);
FakeAsync
().
run
((
FakeAsync
time
)
async
{
final
LaunchResult
launchResult
=
await
iosDevice
.
startApp
(
buildableIOSApp
,
debuggingOptions:
DebuggingOptions
.
disabled
(
BuildInfo
.
release
),
platformArgs:
<
String
,
Object
>{},
);
time
.
elapse
(
const
Duration
(
seconds:
2
));
expect
(
logger
.
statusText
,
contains
(
'Xcode build failed due to concurrent builds, will retry in 2 seconds'
));
expect
(
launchResult
.
started
,
true
);
expect
(
processManager
.
hasRemainingExpectations
,
false
);
expect
(
logger
.
statusText
,
contains
(
'Xcode build failed due to concurrent builds, will retry in 2 seconds'
));
expect
(
launchResult
.
started
,
true
);
expect
(
processManager
.
hasRemainingExpectations
,
false
);
});
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
FileSystem:
()
=>
fileSystem
,
...
...
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