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
7caef218
Unverified
Commit
7caef218
authored
Nov 12, 2019
by
Jonah Williams
Committed by
GitHub
Nov 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactorings to testbed.run and testbed.test (#44488)
parent
9acf1054
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
23 deletions
+16
-23
assemble_test.dart
...ter_tools/test/commands.shard/hermetic/assemble_test.dart
+16
-23
No files found.
packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart
View file @
7caef218
...
@@ -16,20 +16,14 @@ import '../../src/common.dart';
...
@@ -16,20 +16,14 @@ import '../../src/common.dart';
import
'../../src/testbed.dart'
;
import
'../../src/testbed.dart'
;
void
main
(
)
{
void
main
(
)
{
Testbed
testbed
;
MockBuildSystem
mockBuildSystem
;
Cache
.
disableLocking
();
Cache
.
disableLocking
();
final
Testbed
testbed
=
Testbed
(
overrides:
<
Type
,
Generator
>{
setUp
(()
{
BuildSystem:
()
=>
MockBuildSystem
(),
mockBuildSystem
=
MockBuildSystem
();
testbed
=
Testbed
(
overrides:
<
Type
,
Generator
>{
BuildSystem:
()
=>
mockBuildSystem
,
Cache:
()
=>
FakeCache
(),
Cache:
()
=>
FakeCache
(),
});
});
});
test
(
'Can run a build'
,
()
=>
testbed
.
run
(
()
async
{
test
bed
.
test
(
'Can run a build'
,
()
async
{
when
(
mockB
uildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
when
(
b
uildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
.
thenAnswer
((
Invocation
invocation
)
async
{
.
thenAnswer
((
Invocation
invocation
)
async
{
return
BuildResult
(
success:
true
);
return
BuildResult
(
success:
true
);
});
});
...
@@ -38,30 +32,30 @@ void main() {
...
@@ -38,30 +32,30 @@ void main() {
final
BufferLogger
bufferLogger
=
logger
;
final
BufferLogger
bufferLogger
=
logger
;
expect
(
bufferLogger
.
traceText
,
contains
(
'build succeeded.'
));
expect
(
bufferLogger
.
traceText
,
contains
(
'build succeeded.'
));
})
)
;
});
test
(
'Throws ToolExit if not provided with output'
,
()
=>
testbed
.
run
(
()
async
{
test
bed
.
test
(
'Throws ToolExit if not provided with output'
,
()
async
{
when
(
mockB
uildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
when
(
b
uildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
.
thenAnswer
((
Invocation
invocation
)
async
{
.
thenAnswer
((
Invocation
invocation
)
async
{
return
BuildResult
(
success:
true
);
return
BuildResult
(
success:
true
);
});
});
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
AssembleCommand
());
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
AssembleCommand
());
expect
(
commandRunner
.
run
(<
String
>[
'assemble'
,
'debug_macos_bundle_flutter_assets'
]),
throwsA
(
isInstanceOf
<
ToolExit
>()));
expect
(
commandRunner
.
run
(<
String
>[
'assemble'
,
'debug_macos_bundle_flutter_assets'
]),
throwsA
(
isInstanceOf
<
ToolExit
>()));
})
)
;
});
test
(
'Throws ToolExit if called with non-existent rule'
,
()
=>
testbed
.
run
(
()
async
{
test
bed
.
test
(
'Throws ToolExit if called with non-existent rule'
,
()
async
{
when
(
mockB
uildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
when
(
b
uildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
.
thenAnswer
((
Invocation
invocation
)
async
{
.
thenAnswer
((
Invocation
invocation
)
async
{
return
BuildResult
(
success:
true
);
return
BuildResult
(
success:
true
);
});
});
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
AssembleCommand
());
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
AssembleCommand
());
expect
(
commandRunner
.
run
(<
String
>[
'assemble'
,
'-o Output'
,
'undefined'
]),
throwsA
(
isInstanceOf
<
ToolExit
>()));
expect
(
commandRunner
.
run
(<
String
>[
'assemble'
,
'-o Output'
,
'undefined'
]),
throwsA
(
isInstanceOf
<
ToolExit
>()));
})
)
;
});
test
(
'Only writes input and output files when the values change'
,
()
=>
testbed
.
run
(
()
async
{
test
bed
.
test
(
'Only writes input and output files when the values change'
,
()
async
{
when
(
mockB
uildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
when
(
b
uildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
.
thenAnswer
((
Invocation
invocation
)
async
{
.
thenAnswer
((
Invocation
invocation
)
async
{
return
BuildResult
(
return
BuildResult
(
success:
true
,
success:
true
,
...
@@ -86,8 +80,7 @@ void main() {
...
@@ -86,8 +80,7 @@ void main() {
expect
(
inputs
.
lastModifiedSync
(),
theDistantPast
);
expect
(
inputs
.
lastModifiedSync
(),
theDistantPast
);
expect
(
outputs
.
lastModifiedSync
(),
theDistantPast
);
expect
(
outputs
.
lastModifiedSync
(),
theDistantPast
);
when
(
buildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
when
(
mockBuildSystem
.
build
(
any
,
any
,
buildSystemConfig:
anyNamed
(
'buildSystemConfig'
)))
.
thenAnswer
((
Invocation
invocation
)
async
{
.
thenAnswer
((
Invocation
invocation
)
async
{
return
BuildResult
(
return
BuildResult
(
success:
true
,
success:
true
,
...
@@ -99,7 +92,7 @@ void main() {
...
@@ -99,7 +92,7 @@ void main() {
expect
(
inputs
.
readAsStringSync
(),
contains
(
'foo'
));
expect
(
inputs
.
readAsStringSync
(),
contains
(
'foo'
));
expect
(
inputs
.
readAsStringSync
(),
contains
(
'fizz'
));
expect
(
inputs
.
readAsStringSync
(),
contains
(
'fizz'
));
expect
(
inputs
.
lastModifiedSync
(),
isNot
(
theDistantPast
));
expect
(
inputs
.
lastModifiedSync
(),
isNot
(
theDistantPast
));
})
)
;
});
}
}
class
MockBuildSystem
extends
Mock
implements
BuildSystem
{}
class
MockBuildSystem
extends
Mock
implements
BuildSystem
{}
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