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
9cc69d47
Unverified
Commit
9cc69d47
authored
Apr 14, 2020
by
Jonah Williams
Committed by
GitHub
Apr 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] support machine and coverage together but for real (#54692)
parent
8ed40ddd
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
109 additions
and
3 deletions
+109
-3
coverage_collector.dart
packages/flutter_tools/lib/src/test/coverage_collector.dart
+6
-0
event_printer.dart
packages/flutter_tools/lib/src/test/event_printer.dart
+15
-0
watcher.dart
packages/flutter_tools/lib/src/test/watcher.dart
+3
-3
coverage_collection_test.dart
...ools/test/integration.shard/coverage_collection_test.dart
+35
-0
project.dart
...utter_tools/test/integration.shard/test_data/project.dart
+4
-0
test_project.dart
..._tools/test/integration.shard/test_data/test_project.dart
+41
-0
test_driver.dart
...ges/flutter_tools/test/integration.shard/test_driver.dart
+5
-0
No files found.
packages/flutter_tools/lib/src/test/coverage_collector.dart
View file @
9cc69d47
...
...
@@ -177,6 +177,12 @@ class CoverageCollector extends TestWatcher {
}
return
true
;
}
@override
Future
<
void
>
handleTestCrashed
(
ProcessEvent
event
)
async
{
}
@override
Future
<
void
>
handleTestTimedOut
(
ProcessEvent
event
)
async
{
}
}
Future
<
VMService
>
_defaultConnect
(
Uri
serviceUri
)
{
...
...
packages/flutter_tools/lib/src/test/event_printer.dart
View file @
9cc69d47
...
...
@@ -22,6 +22,21 @@ class EventPrinter extends TestWatcher {
_parent
?.
handleStartedProcess
(
event
);
}
@override
Future
<
void
>
handleTestCrashed
(
ProcessEvent
event
)
async
{
return
_parent
.
handleTestCrashed
(
event
);
}
@override
Future
<
void
>
handleTestTimedOut
(
ProcessEvent
event
)
async
{
return
_parent
.
handleTestTimedOut
(
event
);
}
@override
Future
<
void
>
handleFinishedTest
(
ProcessEvent
event
)
async
{
return
_parent
.
handleFinishedTest
(
event
);
}
void
_sendEvent
(
String
name
,
[
dynamic
params
])
{
final
Map
<
String
,
dynamic
>
map
=
<
String
,
dynamic
>{
'event'
:
name
};
if
(
params
!=
null
)
{
...
...
packages/flutter_tools/lib/src/test/watcher.dart
View file @
9cc69d47
...
...
@@ -17,14 +17,14 @@ abstract class TestWatcher {
///
/// The child process won't exit until this method completes.
/// Not called if the process died.
Future
<
void
>
handleFinishedTest
(
ProcessEvent
event
)
async
{
}
Future
<
void
>
handleFinishedTest
(
ProcessEvent
event
)
;
/// Called when the test process crashed before connecting to test harness.
Future
<
void
>
handleTestCrashed
(
ProcessEvent
event
)
async
{
}
Future
<
void
>
handleTestCrashed
(
ProcessEvent
event
)
;
/// Called if we timed out waiting for the test process to connect to test
/// harness.
Future
<
void
>
handleTestTimedOut
(
ProcessEvent
event
)
async
{
}
Future
<
void
>
handleTestTimedOut
(
ProcessEvent
event
)
;
}
/// Describes a child process started during testing.
...
...
packages/flutter_tools/test/integration.shard/coverage_collection_test.dart
0 → 100644
View file @
9cc69d47
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:file/file.dart'
;
import
'package:file_testing/file_testing.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'../src/common.dart'
;
import
'test_data/test_project.dart'
;
import
'test_driver.dart'
;
import
'test_utils.dart'
;
void
main
(
)
{
Directory
tempDir
;
setUp
(()
async
{
tempDir
=
createResolvedTempDirectorySync
(
'flutter_coverage_collection_test.'
);
});
tearDown
(()
async
{
tryToDelete
(
tempDir
);
});
test
(
'Can collect coverage in machine mode'
,
()
async
{
final
TestProject
project
=
TestProject
();
await
project
.
setUpIn
(
tempDir
);
final
FlutterTestTestDriver
flutter
=
FlutterTestTestDriver
(
tempDir
);
await
flutter
.
test
(
coverage:
true
);
await
flutter
.
done
;
expect
(
tempDir
.
childDirectory
(
'coverage'
).
childFile
(
'lcov.info'
),
exists
);
});
}
packages/flutter_tools/test/integration.shard/test_data/project.dart
View file @
9cc69d47
...
...
@@ -26,6 +26,7 @@ abstract class Project {
String
get
pubspec
;
String
get
main
;
String
get
test
=>
null
;
Uri
get
mainDart
=>
Uri
.
parse
(
'package:test/main.dart'
);
...
...
@@ -35,6 +36,9 @@ abstract class Project {
if
(
main
!=
null
)
{
writeFile
(
globals
.
fs
.
path
.
join
(
dir
.
path
,
'lib'
,
'main.dart'
),
main
);
}
if
(
test
!=
null
)
{
writeFile
(
globals
.
fs
.
path
.
join
(
dir
.
path
,
'test'
,
'test.dart'
),
test
);
}
writeFile
(
globals
.
fs
.
path
.
join
(
dir
.
path
,
'web'
,
'index.html'
),
_kDefaultHtml
);
await
getPackages
(
dir
.
path
);
}
...
...
packages/flutter_tools/test/integration.shard/test_data/test_project.dart
0 → 100644
View file @
9cc69d47
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'project.dart'
;
class
TestProject
extends
Project
{
@override
final
String
pubspec
=
'''
name: test
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
'''
;
@override
final
String
main
=
r''
'
int foo(int bar) {
return bar + 2;
}
'''
;
@override
final
String
test
=
r''
'
import '
package:
flutter_test
/
flutter_test
.
dart
';
import '
package:
test
/
main
.
dart
';
void main() {
testWidgets('
it
can
test
', (WidgetTester tester) async {
expect(foo(2), 4);
});
}
'''
;
}
packages/flutter_tools/test/integration.shard/test_driver.dart
View file @
9cc69d47
...
...
@@ -126,6 +126,8 @@ abstract class FlutterTestDriver {
_stderr
.
stream
.
listen
((
String
message
)
=>
_debugPrint
(
message
,
topic:
'<=stderr='
));
}
Future
<
void
>
get
done
=>
_process
.
exitCode
;
Future
<
void
>
connectToVmService
({
bool
pauseOnExceptions
=
false
})
async
{
_vmService
=
await
vmServiceConnectUri
(
'
$_vmServiceWsUri
'
);
_vmService
.
onSend
.
listen
((
String
s
)
=>
_debugPrint
(
s
,
topic:
'=vm=>'
));
...
...
@@ -680,6 +682,7 @@ class FlutterTestTestDriver extends FlutterTestDriver {
String
testFile
=
'test/test.dart'
,
bool
withDebugger
=
false
,
bool
pauseOnExceptions
=
false
,
bool
coverage
=
false
,
File
pidFile
,
Future
<
void
>
Function
()
beforeStart
,
})
async
{
...
...
@@ -687,6 +690,8 @@ class FlutterTestTestDriver extends FlutterTestDriver {
'test'
,
'--disable-service-auth-codes'
,
'--machine'
,
if
(
coverage
)
'--coverage'
,
],
script:
testFile
,
withDebugger:
withDebugger
,
pauseOnExceptions:
pauseOnExceptions
,
pidFile:
pidFile
,
beforeStart:
beforeStart
);
}
...
...
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