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
24f8f799
Unverified
Commit
24f8f799
authored
Feb 12, 2020
by
Dan Field
Committed by
GitHub
Feb 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add an --enable-vmservice flag (#50663)
parent
58a4122b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
269 additions
and
129 deletions
+269
-129
fuchsia_tester.dart
packages/flutter_tools/bin/fuchsia_tester.dart
+2
-1
test.dart
packages/flutter_tools/lib/src/commands/test.dart
+15
-2
runner.dart
packages/flutter_tools/lib/src/test/runner.dart
+162
-126
test_test.dart
...flutter_tools/test/commands.shard/hermetic/test_test.dart
+90
-0
No files found.
packages/flutter_tools/bin/fuchsia_tester.dart
View file @
24f8f799
...
...
@@ -142,7 +142,8 @@ Future<void> run(List<String> args) async {
tests
[
source
]
=
dill
;
}
exitCode
=
await
runTests
(
// TODO(dnfield): This should be injected.
exitCode
=
await
const
FlutterTestRunner
().
runTests
(
const
TestWrapper
(),
tests
.
keys
.
toList
(),
workDir:
testDirectory
,
...
...
packages/flutter_tools/lib/src/commands/test.dart
View file @
24f8f799
...
...
@@ -27,6 +27,7 @@ class TestCommand extends FastFlutterCommand {
TestCommand
({
bool
verboseHelp
=
false
,
this
.
testWrapper
=
const
TestWrapper
(),
this
.
testRunner
=
const
FlutterTestRunner
(),
})
:
assert
(
testWrapper
!=
null
)
{
requiresPubspecYaml
();
usesPubOption
();
...
...
@@ -110,6 +111,15 @@ class TestCommand extends FastFlutterCommand {
'test cases (must be a 32bit unsigned integer).
\n
'
'If "random", pick a random seed to use.
\n
'
'If 0 or not set, do not randomize test case execution order.'
,
)
..
addFlag
(
'enable-vmservice'
,
defaultsTo:
false
,
hide:
!
verboseHelp
,
help:
'Enables the vmservice without --start-paused. This flag is '
'intended for use with tests that will use dart:developer to '
'interact with the vmservice at runtime.
\n
'
'This flag is ignored if --start-paused or coverage are requested. '
'The vmservice will be enabled no matter what in those cases.'
);
usesTrackWidgetCreation
(
verboseHelp:
verboseHelp
);
}
...
...
@@ -117,6 +127,9 @@ class TestCommand extends FastFlutterCommand {
/// The interface for starting and configuring the tester.
final
TestWrapper
testWrapper
;
/// Interface for running the tester process.
final
FlutterTestRunner
testRunner
;
@override
Future
<
Set
<
DevelopmentArtifact
>>
get
requiredArtifacts
async
{
final
Set
<
DevelopmentArtifact
>
results
=
<
DevelopmentArtifact
>{};
...
...
@@ -235,14 +248,14 @@ class TestCommand extends FastFlutterCommand {
final
bool
disableServiceAuthCodes
=
boolArg
(
'disable-service-auth-codes'
);
final
int
result
=
await
runTests
(
final
int
result
=
await
testRunner
.
runTests
(
testWrapper
,
files
,
workDir:
workDir
,
names:
names
,
plainNames:
plainNames
,
watcher:
watcher
,
enableObservatory:
collector
!=
null
||
startPaused
,
enableObservatory:
collector
!=
null
||
startPaused
||
boolArg
(
'enable-vmservice'
)
,
startPaused:
startPaused
,
disableServiceAuthCodes:
disableServiceAuthCodes
,
ipv6:
boolArg
(
'ipv6'
),
...
...
packages/flutter_tools/lib/src/test/runner.dart
View file @
24f8f799
...
...
@@ -20,8 +20,43 @@ import 'flutter_web_platform.dart';
import
'test_wrapper.dart'
;
import
'watcher.dart'
;
/// Runs tests using package:test and the Flutter engine.
Future
<
int
>
runTests
(
/// A class that abstracts launching the test process from the test runner.
abstract
class
FlutterTestRunner
{
const
factory
FlutterTestRunner
()
=
_FlutterTestRunnerImpl
;
/// Runs tests using package:test and the Flutter engine.
Future
<
int
>
runTests
(
TestWrapper
testWrapper
,
List
<
String
>
testFiles
,
{
Directory
workDir
,
List
<
String
>
names
=
const
<
String
>[],
List
<
String
>
plainNames
=
const
<
String
>[],
bool
enableObservatory
=
false
,
bool
startPaused
=
false
,
bool
disableServiceAuthCodes
=
false
,
bool
ipv6
=
false
,
bool
machine
=
false
,
String
precompiledDillPath
,
Map
<
String
,
String
>
precompiledDillFiles
,
@required
BuildMode
buildMode
,
bool
trackWidgetCreation
=
false
,
bool
updateGoldens
=
false
,
TestWatcher
watcher
,
@required
int
concurrency
,
bool
buildTestAssets
=
false
,
FlutterProject
flutterProject
,
String
icudtlPath
,
Directory
coverageDirectory
,
bool
web
=
false
,
String
randomSeed
=
'0'
,
});
}
class
_FlutterTestRunnerImpl
implements
FlutterTestRunner
{
const
_FlutterTestRunnerImpl
();
@override
Future
<
int
>
runTests
(
TestWrapper
testWrapper
,
List
<
String
>
testFiles
,
{
Directory
workDir
,
...
...
@@ -45,7 +80,7 @@ Future<int> runTests(
Directory
coverageDirectory
,
bool
web
=
false
,
String
randomSeed
=
'0'
,
})
async
{
})
async
{
// Configure package:test to use the Flutter engine for child processes.
final
String
shellPath
=
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
flutterTester
);
if
(!
globals
.
processManager
.
canRun
(
shellPath
))
{
...
...
@@ -157,4 +192,5 @@ Future<int> runTests(
globals
.
fs
.
currentDirectory
=
saved
;
await
platform
.
close
();
}
}
}
packages/flutter_tools/test/commands.shard/hermetic/test_test.dart
View file @
24f8f799
...
...
@@ -7,9 +7,13 @@ import 'dart:async';
import
'package:args/command_runner.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/test.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/test/runner.dart'
;
import
'package:flutter_tools/src/test/test_wrapper.dart'
;
import
'package:flutter_tools/src/test/watcher.dart'
;
import
'package:process/process.dart'
;
import
'../../src/common.dart'
;
...
...
@@ -73,6 +77,92 @@ void main() {
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Cache:
()
=>
FakeCache
(),
});
testUsingContext
(
'Pipes enable-observatory'
,
()
async
{
final
FakeFlutterTestRunner
testRunner
=
FakeFlutterTestRunner
(
0
);
final
TestCommand
testCommand
=
TestCommand
(
testRunner:
testRunner
);
final
CommandRunner
<
void
>
commandRunner
=
createTestCommandRunner
(
testCommand
);
await
commandRunner
.
run
(
const
<
String
>[
'test'
,
'--no-pub'
,
'--enable-vmservice'
,
'--'
,
'test/fake_test.dart'
,
]);
expect
(
testRunner
.
lastEnableObservatoryValue
,
true
,
);
await
commandRunner
.
run
(
const
<
String
>[
'test'
,
'--no-pub'
,
'--start-paused'
,
'--no-enable-vmservice'
,
'--'
,
'test/fake_test.dart'
,
]);
expect
(
testRunner
.
lastEnableObservatoryValue
,
true
,
);
await
commandRunner
.
run
(
const
<
String
>[
'test'
,
'--no-pub'
,
'--'
,
'test/fake_test.dart'
,
]);
expect
(
testRunner
.
lastEnableObservatoryValue
,
false
,
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Cache:
()
=>
FakeCache
(),
});
}
class
FakeFlutterTestRunner
implements
FlutterTestRunner
{
FakeFlutterTestRunner
(
this
.
exitCode
);
int
exitCode
;
bool
lastEnableObservatoryValue
;
@override
Future
<
int
>
runTests
(
TestWrapper
testWrapper
,
List
<
String
>
testFiles
,
{
Directory
workDir
,
List
<
String
>
names
=
const
<
String
>[],
List
<
String
>
plainNames
=
const
<
String
>[],
bool
enableObservatory
=
false
,
bool
startPaused
=
false
,
bool
disableServiceAuthCodes
=
false
,
bool
ipv6
=
false
,
bool
machine
=
false
,
String
precompiledDillPath
,
Map
<
String
,
String
>
precompiledDillFiles
,
BuildMode
buildMode
,
bool
trackWidgetCreation
=
false
,
bool
updateGoldens
=
false
,
TestWatcher
watcher
,
int
concurrency
,
bool
buildTestAssets
=
false
,
FlutterProject
flutterProject
,
String
icudtlPath
,
Directory
coverageDirectory
,
bool
web
=
false
,
String
randomSeed
=
'0'
,
})
async
{
lastEnableObservatoryValue
=
enableObservatory
;
return
exitCode
;
}
}
class
FakePackageTest
implements
TestWrapper
{
...
...
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