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
fde26751
Unverified
Commit
fde26751
authored
Oct 08, 2019
by
Jonah Williams
Committed by
GitHub
Oct 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Pub an interface in the flutter tool (#42257)
parent
fc626661
Changes
28
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
424 additions
and
214 deletions
+424
-214
build_runner.dart
...ages/flutter_tools/lib/src/build_runner/build_runner.dart
+1
-1
web_fs.dart
packages/flutter_tools/lib/src/build_runner/web_fs.dart
+1
-1
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+4
-4
packages.dart
packages/flutter_tools/lib/src/commands/packages.dart
+5
-5
test.dart
packages/flutter_tools/lib/src/commands/test.dart
+1
-1
update_packages.dart
packages/flutter_tools/lib/src/commands/update_packages.dart
+3
-3
upgrade.dart
packages/flutter_tools/lib/src/commands/upgrade.dart
+1
-1
version.dart
packages/flutter_tools/lib/src/commands/version.dart
+1
-1
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+2
-0
pub.dart
packages/flutter_tools/lib/src/dart/pub.dart
+199
-149
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+1
-1
analyze_continuously_test.dart
...st/commands.shard/hermetic/analyze_continuously_test.dart
+5
-2
build_web_test.dart
...er_tools/test/commands.shard/hermetic/build_web_test.dart
+3
-1
drive_test.dart
...lutter_tools/test/commands.shard/hermetic/drive_test.dart
+9
-0
run_test.dart
.../flutter_tools/test/commands.shard/hermetic/run_test.dart
+2
-1
version_test.dart
...tter_tools/test/commands.shard/hermetic/version_test.dart
+6
-0
analyze_once_test.dart
...ools/test/commands.shard/permeable/analyze_once_test.dart
+29
-8
build_bundle_test.dart
...ools/test/commands.shard/permeable/build_bundle_test.dart
+1
-0
create_test.dart
...tter_tools/test/commands.shard/permeable/create_test.dart
+51
-15
packages_test.dart
...er_tools/test/commands.shard/permeable/packages_test.dart
+36
-8
build_aar_test.dart
...ter_tools/test/general.shard/commands/build_aar_test.dart
+1
-0
build_apk_test.dart
...ter_tools/test/general.shard/commands/build_apk_test.dart
+1
-0
build_appbundle_test.dart
...ols/test/general.shard/commands/build_appbundle_test.dart
+1
-0
pub_get_test.dart
...s/flutter_tools/test/general.shard/dart/pub_get_test.dart
+12
-6
sdk_validation_test.dart
...er_tools/test/general.shard/dart/sdk_validation_test.dart
+1
-1
web_fs_test.dart
...ges/flutter_tools/test/general.shard/web/web_fs_test.dart
+10
-5
context.dart
packages/flutter_tools/test/src/context.dart
+3
-0
testbed.dart
packages/flutter_tools/test/src/testbed.dart
+34
-0
No files found.
packages/flutter_tools/lib/src/build_runner/build_runner.dart
View file @
fde26751
...
...
@@ -102,7 +102,7 @@ class BuildRunner extends CodeGenerator {
stringBuffer
.
writeln
(
' build_daemon:
$kSupportedBuildDaemonVersion
'
);
syntheticPubspec
.
writeAsStringSync
(
stringBuffer
.
toString
());
await
pub
G
et
(
await
pub
.
g
et
(
context:
PubContext
.
pubGet
,
directory:
generatedDirectory
.
path
,
upgrade:
false
,
...
...
packages/flutter_tools/lib/src/build_runner/web_fs.dart
View file @
fde26751
...
...
@@ -179,7 +179,7 @@ class WebFs {
// Workaround for https://github.com/flutter/flutter/issues/41681.
final
String
toolPath
=
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'packages'
,
'flutter_tools'
);
if
(!
fs
.
isFileSync
(
fs
.
path
.
join
(
toolPath
,
'.packages'
)))
{
await
pub
G
et
(
await
pub
.
g
et
(
context:
PubContext
.
pubGet
,
directory:
toolPath
,
offline:
true
,
...
...
packages/flutter_tools/lib/src/commands/create.dart
View file @
fde26751
...
...
@@ -498,7 +498,7 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
templateContext
[
'description'
]
=
description
;
generatedCount
+=
_renderTemplate
(
fs
.
path
.
join
(
'module'
,
'common'
),
directory
,
templateContext
,
overwrite:
overwrite
);
if
(
argResults
[
'pub'
])
{
await
pub
G
et
(
await
pub
.
g
et
(
context:
PubContext
.
create
,
directory:
directory
.
path
,
offline:
argResults
[
'offline'
],
...
...
@@ -517,7 +517,7 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
templateContext
[
'description'
]
=
description
;
generatedCount
+=
_renderTemplate
(
'package'
,
directory
,
templateContext
,
overwrite:
overwrite
);
if
(
argResults
[
'pub'
])
{
await
pub
G
et
(
await
pub
.
g
et
(
context:
PubContext
.
createPackage
,
directory:
directory
.
path
,
offline:
argResults
[
'offline'
],
...
...
@@ -534,7 +534,7 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
templateContext
[
'description'
]
=
description
;
generatedCount
+=
_renderTemplate
(
'plugin'
,
directory
,
templateContext
,
overwrite:
overwrite
);
if
(
argResults
[
'pub'
])
{
await
pub
G
et
(
await
pub
.
g
et
(
context:
PubContext
.
createPlugin
,
directory:
directory
.
path
,
offline:
argResults
[
'offline'
],
...
...
@@ -570,7 +570,7 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
}
if
(
argResults
[
'pub'
])
{
await
pub
G
et
(
context:
PubContext
.
create
,
directory:
directory
.
path
,
offline:
argResults
[
'offline'
]);
await
pub
.
g
et
(
context:
PubContext
.
create
,
directory:
directory
.
path
,
offline:
argResults
[
'offline'
]);
await
project
.
ensureReadyForPlatformSpecificTooling
(
checkProjects:
false
);
}
...
...
packages/flutter_tools/lib/src/commands/packages.dart
View file @
fde26751
...
...
@@ -93,7 +93,7 @@ class PackagesGetCommand extends FlutterCommand {
Future
<
void
>
_runPubGet
(
String
directory
)
async
{
final
Stopwatch
pubGetTimer
=
Stopwatch
()..
start
();
try
{
await
pub
G
et
(
context:
PubContext
.
pubGet
,
await
pub
.
g
et
(
context:
PubContext
.
pubGet
,
directory:
directory
,
upgrade:
upgrade
,
offline:
argResults
[
'offline'
],
...
...
@@ -164,7 +164,7 @@ class PackagesTestCommand extends FlutterCommand {
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
await
pub
(<
String
>[
'run'
,
'test'
,
...
argResults
.
rest
],
context:
PubContext
.
runTest
,
retry:
false
);
await
pub
.
batch
(<
String
>[
'run'
,
'test'
,
...
argResults
.
rest
],
context:
PubContext
.
runTest
,
retry:
false
);
return
null
;
}
}
...
...
@@ -205,7 +205,7 @@ class PackagesPublishCommand extends FlutterCommand {
if
(
argResults
[
'force'
])
'--force'
,
];
Cache
.
releaseLockEarly
();
await
pub
I
nteractively
(<
String
>[
'publish'
,
...
args
]);
await
pub
.
i
nteractively
(<
String
>[
'publish'
,
...
args
]);
return
null
;
}
}
...
...
@@ -236,7 +236,7 @@ class PackagesForwardCommand extends FlutterCommand {
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
await
pub
I
nteractively
(<
String
>[
_commandName
,
...
argResults
.
rest
]);
await
pub
.
i
nteractively
(<
String
>[
_commandName
,
...
argResults
.
rest
]);
return
null
;
}
...
...
@@ -264,7 +264,7 @@ class PackagesPassthroughCommand extends FlutterCommand {
@override
Future
<
FlutterCommandResult
>
runCommand
()
async
{
Cache
.
releaseLockEarly
();
await
pub
I
nteractively
(
argResults
.
rest
);
await
pub
.
i
nteractively
(
argResults
.
rest
);
return
null
;
}
}
packages/flutter_tools/lib/src/commands/test.dart
View file @
fde26751
...
...
@@ -131,7 +131,7 @@ class TestCommand extends FastFlutterCommand {
'directory (or one of its subdirectories).'
);
}
if
(
shouldRunPub
)
{
await
pub
G
et
(
context:
PubContext
.
getVerifyContext
(
name
),
skipPubspecYamlCheck:
true
);
await
pub
.
g
et
(
context:
PubContext
.
getVerifyContext
(
name
),
skipPubspecYamlCheck:
true
);
}
final
bool
buildTestAssets
=
argResults
[
'test-assets'
];
final
List
<
String
>
names
=
argResults
[
'name'
];
...
...
packages/flutter_tools/lib/src/commands/update_packages.dart
View file @
fde26751
...
...
@@ -253,7 +253,7 @@ class UpdatePackagesCommand extends FlutterCommand {
fakePackage
.
createSync
();
fakePackage
.
writeAsStringSync
(
_generateFakePubspec
(
dependencies
.
values
));
// First we run "pub upgrade" on this generated package:
await
pub
G
et
(
await
pub
.
g
et
(
context:
PubContext
.
updatePackages
,
directory:
tempDir
.
path
,
upgrade:
true
,
...
...
@@ -264,7 +264,7 @@ class UpdatePackagesCommand extends FlutterCommand {
// of all the dependencies so that we can figure out the transitive
// dependencies later. It also remembers which version was selected for
// each package.
await
pub
(
await
pub
.
batch
(
<
String
>[
'deps'
,
'--style=compact'
],
context:
PubContext
.
updatePackages
,
directory:
tempDir
.
path
,
...
...
@@ -324,7 +324,7 @@ class UpdatePackagesCommand extends FlutterCommand {
int
count
=
0
;
for
(
Directory
dir
in
packages
)
{
await
pub
G
et
(
context:
PubContext
.
updatePackages
,
directory:
dir
.
path
,
checkLastModified:
false
);
await
pub
.
g
et
(
context:
PubContext
.
updatePackages
,
directory:
dir
.
path
,
checkLastModified:
false
);
count
+=
1
;
}
...
...
packages/flutter_tools/lib/src/commands/upgrade.dart
View file @
fde26751
...
...
@@ -264,7 +264,7 @@ class UpgradeCommandRunner {
final
String
projectRoot
=
findProjectRoot
();
if
(
projectRoot
!=
null
)
{
printStatus
(
''
);
await
pub
G
et
(
context:
PubContext
.
pubUpgrade
,
directory:
projectRoot
,
upgrade:
true
,
checkLastModified:
false
);
await
pub
.
g
et
(
context:
PubContext
.
pubUpgrade
,
directory:
projectRoot
,
upgrade:
true
,
checkLastModified:
false
);
}
}
...
...
packages/flutter_tools/lib/src/commands/version.dart
View file @
fde26751
...
...
@@ -119,7 +119,7 @@ class VersionCommand extends FlutterCommand {
final
String
projectRoot
=
findProjectRoot
();
if
(
projectRoot
!=
null
)
{
printStatus
(
''
);
await
pub
G
et
(
await
pub
.
g
et
(
context:
PubContext
.
pubUpgrade
,
directory:
projectRoot
,
upgrade:
true
,
...
...
packages/flutter_tools/lib/src/context_runner.dart
View file @
fde26751
...
...
@@ -27,6 +27,7 @@ import 'base/utils.dart';
import
'build_system/build_system.dart'
;
import
'cache.dart'
;
import
'compile.dart'
;
import
'dart/pub.dart'
;
import
'devfs.dart'
;
import
'device.dart'
;
import
'doctor.dart'
;
...
...
@@ -105,6 +106,7 @@ Future<T> runInContext<T>(
MacOSWorkflow:
()
=>
const
MacOSWorkflow
(),
MDnsObservatoryDiscovery:
()
=>
MDnsObservatoryDiscovery
(),
OperatingSystemUtils:
()
=>
OperatingSystemUtils
(),
Pub:
()
=>
const
Pub
(),
ProcessInfo:
()
=>
ProcessInfo
(),
ProcessUtils:
()
=>
ProcessUtils
(),
Signals:
()
=>
Signals
(),
...
...
packages/flutter_tools/lib/src/dart/pub.dart
View file @
fde26751
...
...
@@ -7,6 +7,7 @@ import 'dart:async';
import
'package:meta/meta.dart'
;
import
'../base/common.dart'
;
import
'../base/context.dart'
;
import
'../base/file_system.dart'
;
import
'../base/io.dart'
as
io
;
import
'../base/logger.dart'
;
...
...
@@ -19,6 +20,9 @@ import '../reporting/reporting.dart';
import
'../runner/flutter_command.dart'
;
import
'sdk.dart'
;
/// The [Pub] instance.
Pub
get
pub
=>
context
.
get
<
Pub
>();
/// Represents Flutter-specific data that is added to the `PUB_ENVIRONMENT`
/// environment variable and allows understanding the type of requests made to
/// the package site on Flutter's behalf.
...
...
@@ -77,9 +81,16 @@ bool _shouldRunPubGet({ File pubSpecYaml, File dotPackages }) {
return
false
;
}
/// [context] provides extra information to package server requests to
/// understand usage.
Future
<
void
>
pubGet
({
/// A handle for interacting with the pub tool.
abstract
class
Pub
{
/// Create a default [Pub] instance.
const
factory
Pub
()
=
_DefaultPub
;
/// Runs `pub get`.
///
/// [context] provides extra information to package server requests to
/// understand usage.
Future
<
void
>
get
({
@required
PubContext
context
,
String
directory
,
bool
skipIfAbsent
=
false
,
...
...
@@ -87,7 +98,54 @@ Future<void> pubGet({
bool
offline
=
false
,
bool
checkLastModified
=
true
,
bool
skipPubspecYamlCheck
=
false
,
})
async
{
});
/// Runs pub in 'batch' mode.
///
/// forwarding complete lines written by pub to its stdout/stderr streams to
/// the corresponding stream of this process, optionally applying filtering.
/// The pub process will not receive anything on its stdin stream.
///
/// The `--trace` argument is passed to `pub` (by mutating the provided
/// `arguments` list) when `showTraceForErrors` is true, and when `showTraceForErrors`
/// is null/unset, and `isRunningOnBot` is true.
///
/// [context] provides extra information to package server requests to
/// understand usage.
Future
<
void
>
batch
(
List
<
String
>
arguments
,
{
@required
PubContext
context
,
String
directory
,
MessageFilter
filter
,
String
failureMessage
=
'pub failed'
,
@required
bool
retry
,
bool
showTraceForErrors
,
});
/// Runs pub in 'interactive' mode.
///
/// directly piping the stdin stream of this process to that of pub, and the
/// stdout/stderr stream of pub to the corresponding streams of this process.
Future
<
void
>
interactively
(
List
<
String
>
arguments
,
{
String
directory
,
});
}
class
_DefaultPub
implements
Pub
{
const
_DefaultPub
();
@override
Future
<
void
>
get
({
@required
PubContext
context
,
String
directory
,
bool
skipIfAbsent
=
false
,
bool
upgrade
=
false
,
bool
offline
=
false
,
bool
checkLastModified
=
true
,
bool
skipPubspecYamlCheck
=
false
,
})
async
{
directory
??=
fs
.
currentDirectory
.
path
;
final
File
pubSpecYaml
=
fs
.
file
(
fs
.
path
.
join
(
directory
,
'pubspec.yaml'
));
...
...
@@ -113,7 +171,7 @@ Future<void> pubGet({
if
(
offline
)
'--offline'
,
];
try
{
await
pub
(
await
batch
(
args
,
context:
context
,
directory:
directory
,
...
...
@@ -137,21 +195,11 @@ Future<void> pubGet({
'(pubspec.yaml timestamp:
${pubSpecYaml.lastModifiedSync()}
; '
'.packages timestamp:
${dotPackages.lastModifiedSync()}
).'
);
}
}
}
typedef
MessageFilter
=
String
Function
(
String
message
);
/// Runs pub in 'batch' mode, forwarding complete lines written by pub to its
/// stdout/stderr streams to the corresponding stream of this process, optionally
/// applying filtering. The pub process will not receive anything on its stdin stream.
///
/// The `--trace` argument is passed to `pub` (by mutating the provided
/// `arguments` list) when `showTraceForErrors` is true, and when `showTraceForErrors`
/// is null/unset, and `isRunningOnBot` is true.
///
/// [context] provides extra information to package server requests to
/// understand usage.
Future
<
void
>
pub
(
@override
Future
<
void
>
batch
(
List
<
String
>
arguments
,
{
@required
PubContext
context
,
String
directory
,
...
...
@@ -159,7 +207,7 @@ Future<void> pub(
String
failureMessage
=
'pub failed'
,
@required
bool
retry
,
bool
showTraceForErrors
,
})
async
{
})
async
{
showTraceForErrors
??=
isRunningOnBot
;
bool
versionSolvingFailed
=
false
;
...
...
@@ -213,15 +261,13 @@ Future<void> pub(
if
(
code
!=
0
)
{
throwToolExit
(
'
$failureMessage
(
$code
)'
,
exitCode:
code
);
}
}
}
/// Runs pub in 'interactive' mode, directly piping the stdin stream of this
/// process to that of pub, and the stdout/stderr stream of pub to the corresponding
/// streams of this process.
Future
<
void
>
pubInteractively
(
@override
Future
<
void
>
interactively
(
List
<
String
>
arguments
,
{
String
directory
,
})
async
{
})
async
{
Cache
.
releaseLockEarly
();
final
io
.
Process
process
=
await
processUtils
.
start
(
_pubCommand
(
arguments
),
...
...
@@ -243,13 +289,17 @@ Future<void> pubInteractively(
if
(
code
!=
0
)
{
throwToolExit
(
'pub finished with exit code
$code
'
,
exitCode:
code
);
}
}
}
/// The command used for running pub.
List
<
String
>
_pubCommand
(
List
<
String
>
arguments
)
{
/// The command used for running pub.
List
<
String
>
_pubCommand
(
List
<
String
>
arguments
)
{
return
<
String
>[
sdkBinaryName
(
'pub'
),
...
arguments
];
}
}
typedef
MessageFilter
=
String
Function
(
String
message
);
/// The full environment used when running pub.
///
/// [context] provides extra information to package server requests to
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
fde26751
...
...
@@ -538,7 +538,7 @@ abstract class FlutterCommand extends Command<void> {
}
if
(
shouldRunPub
)
{
await
pub
G
et
(
context:
PubContext
.
getVerifyContext
(
name
));
await
pub
.
g
et
(
context:
PubContext
.
getVerifyContext
(
name
));
final
FlutterProject
project
=
FlutterProject
.
current
();
await
project
.
ensureReadyForPlatformSpecificTooling
(
checkProjects:
true
);
}
...
...
packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart
View file @
fde26751
...
...
@@ -32,7 +32,7 @@ void main() {
testUsingContext
(
'AnalysisServer success'
,
()
async
{
_createSampleProject
(
tempDir
);
await
pub
G
et
(
context:
PubContext
.
flutterTests
,
directory:
tempDir
.
path
);
await
pub
.
g
et
(
context:
PubContext
.
flutterTests
,
directory:
tempDir
.
path
);
server
=
AnalysisServer
(
dartSdkPath
,
<
String
>[
tempDir
.
path
]);
...
...
@@ -46,13 +46,14 @@ void main() {
expect
(
errorCount
,
0
);
},
overrides:
<
Type
,
Generator
>{
OperatingSystemUtils:
()
=>
os
,
Pub:
()
=>
const
Pub
(),
});
});
testUsingContext
(
'AnalysisServer errors'
,
()
async
{
_createSampleProject
(
tempDir
,
brokenCode:
true
);
await
pub
G
et
(
context:
PubContext
.
flutterTests
,
directory:
tempDir
.
path
);
await
pub
.
g
et
(
context:
PubContext
.
flutterTests
,
directory:
tempDir
.
path
);
server
=
AnalysisServer
(
dartSdkPath
,
<
String
>[
tempDir
.
path
]);
...
...
@@ -68,6 +69,7 @@ void main() {
expect
(
errorCount
,
greaterThan
(
0
));
},
overrides:
<
Type
,
Generator
>{
OperatingSystemUtils:
()
=>
os
,
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'Returns no errors when source is error-free'
,
()
async
{
...
...
@@ -85,6 +87,7 @@ void main() {
expect
(
errorCount
,
0
);
},
overrides:
<
Type
,
Generator
>{
OperatingSystemUtils:
()
=>
os
,
Pub:
()
=>
const
Pub
(),
});
}
...
...
packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart
View file @
fde26751
...
...
@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/build_system/build_system.dart';
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/build.dart'
;
import
'package:flutter_tools/src/commands/build_web.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/project.dart'
;
...
...
@@ -44,6 +45,7 @@ void main() {
Platform:
()
=>
mockPlatform
,
FlutterVersion:
()
=>
MockFlutterVersion
(),
FeatureFlags:
()
=>
TestFeatureFlags
(
isWebEnabled:
true
),
Pub:
()
=>
MockPub
(),
});
});
...
...
@@ -145,7 +147,6 @@ class UrlLauncherPlugin {}
when
(
buildSystem
.
build
(
any
,
any
)).
thenAnswer
((
Invocation
invocation
)
async
{
return
BuildResult
(
success:
true
);
});
await
runner
.
run
(<
String
>[
'build'
,
'web'
]);
expect
(
fs
.
file
(
fs
.
path
.
join
(
'lib'
,
'generated_plugin_registrant.dart'
)).
existsSync
(),
true
);
...
...
@@ -179,3 +180,4 @@ class MockFlutterVersion extends Mock implements FlutterVersion {
@override
bool
get
isMaster
=>
true
;
}
class
MockPub
extends
Mock
implements
Pub
{}
packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart
View file @
fde26751
...
...
@@ -73,6 +73,7 @@ void main() {
final
List
<
String
>
args
=
<
String
>[
'drive'
,
'--target=
$testApp
'
,
'--no-pub'
,
];
try
{
await
createTestCommandRunner
(
command
).
run
(
args
);
...
...
@@ -99,6 +100,7 @@ void main() {
final
List
<
String
>
args
=
<
String
>[
'drive'
,
'--target=
$testApp
'
,
'--no-pub'
,
];
try
{
await
createTestCommandRunner
(
command
).
run
(
args
);
...
...
@@ -118,6 +120,7 @@ void main() {
'--no-wrap'
,
'drive'
,
'--target=
$appFile
'
,
'--no-pub'
,
];
try
{
await
createTestCommandRunner
(
command
).
run
(
args
);
...
...
@@ -139,6 +142,7 @@ void main() {
'--no-wrap'
,
'drive'
,
'--target=
$appFile
'
,
'--no-pub'
,
];
try
{
await
createTestCommandRunner
(
command
).
run
(
args
);
...
...
@@ -178,6 +182,7 @@ void main() {
final
List
<
String
>
args
=
<
String
>[
'drive'
,
'--target=
$testApp
'
,
'--no-pub'
,
];
await
createTestCommandRunner
(
command
).
run
(
args
);
expect
(
testLogger
.
errorText
,
isEmpty
);
...
...
@@ -208,6 +213,7 @@ void main() {
final
List
<
String
>
args
=
<
String
>[
'drive'
,
'--target=
$testApp
'
,
'--no-pub'
,
];
try
{
await
createTestCommandRunner
(
command
).
run
(
args
);
...
...
@@ -365,6 +371,7 @@ void main() {
final
List
<
String
>
args
=
<
String
>[
'drive'
,
'--target=
$testApp
'
,
'--no-pub'
,
];
try
{
await
createTestCommandRunner
(
command
).
run
(
args
);
...
...
@@ -391,6 +398,7 @@ void main() {
'drive'
,
'--build'
,
'--target=
$testApp
'
,
'--no-pub'
,
];
try
{
await
createTestCommandRunner
(
command
).
run
(
args
);
...
...
@@ -417,6 +425,7 @@ void main() {
'drive'
,
'--no-build'
,
'--target=
$testApp
'
,
'--no-pub'
,
];
try
{
await
createTestCommandRunner
(
command
).
run
(
args
);
...
...
packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
View file @
fde26751
...
...
@@ -36,7 +36,7 @@ void main() {
final
RunCommand
command
=
RunCommand
();
applyMocksToCommand
(
command
);
try
{
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'run'
,
'-t'
,
'abc123'
]);
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'run'
,
'-t'
,
'abc123'
,
'--no-pub'
]);
fail
(
'Expect exception'
);
}
on
ToolExit
catch
(
e
)
{
expect
(
e
.
exitCode
??
1
,
1
);
...
...
@@ -61,6 +61,7 @@ void main() {
'run'
,
'--dart-flags'
,
'"--observe"'
,
'--no-hot'
,
'--no-pub'
,
];
});
...
...
packages/flutter_tools/test/commands.shard/hermetic/version_test.dart
View file @
fde26751
...
...
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/common.dart';
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/version.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
...
...
@@ -30,6 +31,7 @@ void main() {
expect
(
testLogger
.
statusText
,
equals
(
'v10.0.0
\r\n
v20.0.0
\n
'
''
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
MockProcessManager
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'version switch'
,
()
async
{
...
...
@@ -40,6 +42,7 @@ void main() {
expect
(
testLogger
.
statusText
,
contains
(
'Switching Flutter to version
$version
'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
MockProcessManager
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'switch to not supported version without force'
,
()
async
{
...
...
@@ -50,6 +53,7 @@ void main() {
expect
(
testLogger
.
errorText
,
contains
(
'Version command is not supported in'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
MockProcessManager
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'switch to not supported version with force'
,
()
async
{
...
...
@@ -60,6 +64,7 @@ void main() {
expect
(
testLogger
.
statusText
,
contains
(
'Switching Flutter to version
$version
with force'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
MockProcessManager
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'tool exit on confusing version'
,
()
async
{
...
...
@@ -70,6 +75,7 @@ void main() {
throwsA
(
isInstanceOf
<
ToolExit
>()));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
MockProcessManager
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'exit tool if can
\'
t get the tags'
,
()
async
{
...
...
packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart
View file @
fde26751
...
...
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/platform.dart';
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/analyze.dart'
;
import
'package:flutter_tools/src/commands/create.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'../../src/common.dart'
;
...
...
@@ -53,7 +54,9 @@ void main() {
],
);
expect
(
libMain
.
existsSync
(),
isTrue
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
// Analyze in the current directory - no arguments
testUsingContext
(
'working directory'
,
()
async
{
...
...
@@ -62,7 +65,9 @@ void main() {
arguments:
<
String
>[
'analyze'
],
statusTextContains:
<
String
>[
'No issues found!'
],
);
},
timeout:
allowForSlowAnalyzeTests
);
},
timeout:
allowForSlowAnalyzeTests
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
// Analyze a specific file outside the current directory
testUsingContext
(
'passing one file throws'
,
()
async
{
...
...
@@ -72,8 +77,9 @@ void main() {
toolExit:
true
,
exitMessageContains:
'is not a directory'
,
);
},
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
// Analyze in the current directory - no arguments
testUsingContext
(
'working directory with errors'
,
()
async
{
// Break the code to produce the "The parameter 'onPressed' is required" hint
...
...
@@ -104,7 +110,10 @@ void main() {
exitMessageContains:
'2 issues found.'
,
toolExit:
true
,
);
},
timeout:
allowForSlowAnalyzeTests
,
overrides:
noColorTerminalOverride
);
},
timeout:
allowForSlowAnalyzeTests
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
...
noColorTerminalOverride
,
});
// Analyze in the current directory - no arguments
testUsingContext
(
'working directory with local options'
,
()
async
{
...
...
@@ -131,7 +140,10 @@ void main() {
exitMessageContains:
'3 issues found.'
,
toolExit:
true
,
);
},
timeout:
allowForSlowAnalyzeTests
,
overrides:
noColorTerminalOverride
);
},
timeout:
allowForSlowAnalyzeTests
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
...
noColorTerminalOverride
});
testUsingContext
(
'no duplicate issues'
,
()
async
{
final
Directory
tempDir
=
fs
.
systemTempDirectory
.
createTempSync
(
'flutter_analyze_once_test_2.'
).
absolute
;
...
...
@@ -165,7 +177,10 @@ void bar() {
}
finally
{
tryToDelete
(
tempDir
);
}
},
overrides:
noColorTerminalOverride
);
},
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
...
noColorTerminalOverride
});
testUsingContext
(
'returns no issues when source is error-free'
,
()
async
{
const
String
contents
=
'''
...
...
@@ -182,7 +197,10 @@ StringBuffer bar = StringBuffer('baz');
}
finally
{
tryToDelete
(
tempDir
);
}
},
overrides:
noColorTerminalOverride
);
},
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
...
noColorTerminalOverride
});
testUsingContext
(
'returns no issues for todo comments'
,
()
async
{
const
String
contents
=
'''
...
...
@@ -200,7 +218,10 @@ StringBuffer bar = StringBuffer('baz');
}
finally
{
tryToDelete
(
tempDir
);
}
},
overrides:
noColorTerminalOverride
);
},
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
...
noColorTerminalOverride
});
});
}
...
...
packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart
View file @
fde26751
...
...
@@ -59,6 +59,7 @@ void main() {
'bundle'
,
...?
arguments
,
'--target=
$projectPath
/lib/main.dart'
,
'--no-pub'
]);
return
command
;
}
...
...
packages/flutter_tools/test/commands.shard/permeable/create_test.dart
View file @
fde26751
...
...
@@ -13,6 +13,7 @@ import 'package:flutter_tools/src/base/net.dart';
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/create.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/dart/sdk.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/version.dart'
;
...
...
@@ -77,7 +78,9 @@ void main() {
],
);
return
_runFlutterTest
(
projectDir
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'can create a default project if empty directory exists'
,
()
async
{
await
projectDir
.
create
(
recursive:
true
);
...
...
@@ -93,7 +96,9 @@ void main() {
'ios/Runner/GeneratedPluginRegistrant.h'
,
],
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'creates a module project correctly'
,
()
async
{
await
_createAndAnalyzeProject
(
projectDir
,
<
String
>[
...
...
@@ -114,7 +119,9 @@ void main() {
]);
return
_runFlutterTest
(
projectDir
);
},
timeout:
allowForRemotePubInvocation
,
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
},
);
testUsingContext
(
'cannot create a project if non-empty non-project directory exists with .metadata'
,
()
async
{
...
...
@@ -131,7 +138,10 @@ void main() {
'.ios/'
,
]),
throwsToolExit
(
message:
'Sorry, unable to detect the type of project to recreate'
));
},
timeout:
allowForRemotePubInvocation
,
overrides:
noColorTerminalOverride
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
...
noColorTerminalOverride
,
});
testUsingContext
(
'Will create an app project if non-empty non-project directory exists without .metadata'
,
()
async
{
await
projectDir
.
absolute
.
childDirectory
(
'blag'
).
create
(
recursive:
true
);
...
...
@@ -154,7 +164,9 @@ void main() {
'.ios/'
,
],
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'detects and recreates an app project correctly'
,
()
async
{
await
projectDir
.
absolute
.
childDirectory
(
'lib'
).
create
(
recursive:
true
);
...
...
@@ -177,7 +189,9 @@ void main() {
'.ios/'
,
],
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'detects and recreates a plugin project correctly'
,
()
async
{
await
projectDir
.
create
(
recursive:
true
);
...
...
@@ -200,7 +214,9 @@ void main() {
'lib/flutter_project.dart'
,
],
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'detects and recreates a package project correctly'
,
()
async
{
await
projectDir
.
create
(
recursive:
true
);
...
...
@@ -229,7 +245,9 @@ void main() {
'test/widget_test.dart'
,
],
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'kotlin/swift legacy app project'
,
()
async
{
return
_createProject
(
...
...
@@ -249,7 +267,9 @@ void main() {
'ios/Runner/main.m'
,
],
);
},
timeout:
allowForCreateFlutterProject
);
},
timeout:
allowForCreateFlutterProject
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'can create a package project'
,
()
async
{
await
_createAndAnalyzeProject
(
...
...
@@ -277,7 +297,9 @@ void main() {
],
);
return
_runFlutterTest
(
projectDir
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'can create a plugin project'
,
()
async
{
await
_createAndAnalyzeProject
(
...
...
@@ -297,7 +319,9 @@ void main() {
],
);
return
_runFlutterTest
(
projectDir
.
childDirectory
(
'example'
));
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'kotlin/swift plugin project'
,
()
async
{
return
_createProject
(
...
...
@@ -380,7 +404,9 @@ void main() {
<
String
>[
'--with-driver-test'
,
'--template=app'
],
<
String
>[
'lib/main.dart'
],
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'module project with pub'
,
()
async
{
return
_createProject
(
projectDir
,
<
String
>[
...
...
@@ -413,7 +439,9 @@ void main() {
'android/'
,
'ios/'
,
]);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'androidx is used by default in an app project'
,
()
async
{
...
...
@@ -902,7 +930,9 @@ void main() {
'.android/app/src/main/java/com/bar/foo/flutter_project/host/MainActivity.java'
,
],
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'can re-gen module .ios/ folder, reusing custom org'
,
()
async
{
await
_createProject
(
...
...
@@ -917,7 +947,9 @@ void main() {
await
project
.
ios
.
productBundleIdentifier
,
'com.bar.foo.flutterProject'
,
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'can re-gen app android/ folder, reusing custom org'
,
()
async
{
await
_createProject
(
...
...
@@ -1070,6 +1102,8 @@ void main() {
'ios/Runner/GeneratedPluginRegistrant.h'
,
],
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'fails when invalid package name'
,
()
async
{
...
...
@@ -1097,6 +1131,7 @@ void main() {
timeout:
allowForCreateFlutterProject
,
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
loggingProcessManager
,
Pub:
()
=>
const
Pub
(),
},
);
...
...
@@ -1115,6 +1150,7 @@ void main() {
timeout:
allowForCreateFlutterProject
,
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
loggingProcessManager
,
Pub:
()
=>
const
Pub
(),
},
);
...
...
packages/flutter_tools/test/commands.shard/permeable/packages_test.dart
View file @
fde26751
...
...
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/io.dart';
import
'package:flutter_tools/src/base/utils.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/packages.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:process/process.dart'
;
...
...
@@ -206,7 +207,9 @@ void main() {
expectDependenciesResolved
(
projectPath
);
expectZeroPluginsInjected
(
projectPath
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'get --offline fetches packages'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
...
...
@@ -217,7 +220,9 @@ void main() {
expectDependenciesResolved
(
projectPath
);
expectZeroPluginsInjected
(
projectPath
);
},
timeout:
allowForCreateFlutterProject
);
},
timeout:
allowForCreateFlutterProject
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'set the number of plugins as usage value'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
...
...
@@ -229,7 +234,9 @@ void main() {
expect
(
await
getCommand
.
usageValues
,
containsPair
(
CustomDimensions
.
commandPackagesNumberPlugins
,
'0'
));
},
timeout:
allowForCreateFlutterProject
);
},
timeout:
allowForCreateFlutterProject
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'indicate that the project is not a module in usage value'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
...
...
@@ -241,7 +248,9 @@ void main() {
expect
(
await
getCommand
.
usageValues
,
containsPair
(
CustomDimensions
.
commandPackagesProjectModule
,
'false'
));
},
timeout:
allowForCreateFlutterProject
);
},
timeout:
allowForCreateFlutterProject
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'indicate that the project is a module in usage value'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
...
...
@@ -253,7 +262,9 @@ void main() {
expect
(
await
getCommand
.
usageValues
,
containsPair
(
CustomDimensions
.
commandPackagesProjectModule
,
'true'
));
},
timeout:
allowForCreateFlutterProject
);
},
timeout:
allowForCreateFlutterProject
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'upgrade fetches packages'
,
()
async
{
final
String
projectPath
=
await
createProject
(
tempDir
,
...
...
@@ -264,7 +275,9 @@ void main() {
expectDependenciesResolved
(
projectPath
);
expectZeroPluginsInjected
(
projectPath
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'get fetches packages and injects plugin'
,
()
async
{
final
String
projectPath
=
await
createProjectWithPlugin
(
'path_provider'
,
...
...
@@ -275,7 +288,9 @@ void main() {
expectDependenciesResolved
(
projectPath
);
expectModulePluginInjected
(
projectPath
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'get fetches packages and injects plugin in plugin project'
,
()
async
{
final
String
projectPath
=
await
createProject
(
...
...
@@ -294,7 +309,9 @@ void main() {
expectDependenciesResolved
(
exampleProjectPath
);
expectPluginInjected
(
exampleProjectPath
);
},
timeout:
allowForRemotePubInvocation
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
const
Pub
(),
});
});
group
(
'packages test/pub'
,
()
{
...
...
@@ -317,6 +334,7 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysFalseBotDetector
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'test with bot'
,
()
async
{
...
...
@@ -331,6 +349,7 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'run'
,
()
async
{
...
...
@@ -344,6 +363,7 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'pub publish'
,
()
async
{
...
...
@@ -368,6 +388,7 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'publish'
,
()
async
{
...
...
@@ -380,6 +401,7 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'packages publish'
,
()
async
{
...
...
@@ -392,6 +414,7 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'deps'
,
()
async
{
...
...
@@ -404,6 +427,7 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'cache'
,
()
async
{
...
...
@@ -416,6 +440,7 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'version'
,
()
async
{
...
...
@@ -428,6 +453,7 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'uploader'
,
()
async
{
...
...
@@ -440,6 +466,7 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'global'
,
()
async
{
...
...
@@ -453,6 +480,7 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
AlwaysTrueBotDetector
(),
Pub:
()
=>
const
Pub
(),
});
});
}
packages/flutter_tools/test/general.shard/commands/build_aar_test.dart
View file @
fde26751
...
...
@@ -40,6 +40,7 @@ void main() {
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'aar'
,
'--no-pub'
,
...?
arguments
,
target
,
]);
...
...
packages/flutter_tools/test/general.shard/commands/build_apk_test.dart
View file @
fde26751
...
...
@@ -324,6 +324,7 @@ Future<BuildApkCommand> runBuildApkCommand(
await
runner
.
run
(<
String
>[
'apk'
,
...?
arguments
,
'--no-pub'
,
fs
.
path
.
join
(
target
,
'lib'
,
'main.dart'
),
]);
return
command
;
...
...
packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart
View file @
fde26751
...
...
@@ -315,6 +315,7 @@ Future<BuildAppBundleCommand> runBuildAppBundleCommand(
await
runner
.
run
(<
String
>[
'appbundle'
,
...?
arguments
,
'--no-pub'
,
fs
.
path
.
join
(
target
,
'lib'
,
'main.dart'
),
]);
return
command
;
...
...
packages/flutter_tools/test/general.shard/dart/pub_get_test.dart
View file @
fde26751
...
...
@@ -36,7 +36,7 @@ void main() {
FakeAsync
().
run
((
FakeAsync
time
)
{
expect
(
processMock
.
lastPubEnvironment
,
isNull
);
expect
(
testLogger
.
statusText
,
''
);
pub
G
et
(
context:
PubContext
.
flutterTests
,
checkLastModified:
false
).
then
((
void
value
)
{
pub
.
g
et
(
context:
PubContext
.
flutterTests
,
checkLastModified:
false
).
then
((
void
value
)
{
error
=
'test completed unexpectedly'
;
},
onError:
(
dynamic
thrownError
)
{
error
=
'test failed unexpectedly:
$thrownError
'
;
...
...
@@ -94,6 +94,7 @@ void main() {
Platform:
()
=>
FakePlatform
(
environment:
UnmodifiableMapView
<
String
,
String
>(<
String
,
String
>{}),
),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'pub cache in root is used'
,
()
async
{
...
...
@@ -106,7 +107,7 @@ void main() {
MockDirectory
.
findCache
=
true
;
expect
(
processMock
.
lastPubEnvironment
,
isNull
);
expect
(
processMock
.
lastPubCache
,
isNull
);
pub
G
et
(
context:
PubContext
.
flutterTests
,
checkLastModified:
false
).
then
((
void
value
)
{
pub
.
g
et
(
context:
PubContext
.
flutterTests
,
checkLastModified:
false
).
then
((
void
value
)
{
error
=
'test completed unexpectedly'
;
},
onError:
(
dynamic
thrownError
)
{
error
=
'test failed unexpectedly:
$thrownError
'
;
...
...
@@ -121,6 +122,7 @@ void main() {
Platform:
()
=>
FakePlatform
(
environment:
UnmodifiableMapView
<
String
,
String
>(<
String
,
String
>{}),
),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'pub cache in environment is used'
,
()
async
{
...
...
@@ -132,7 +134,7 @@ void main() {
MockDirectory
.
findCache
=
true
;
expect
(
processMock
.
lastPubEnvironment
,
isNull
);
expect
(
processMock
.
lastPubCache
,
isNull
);
pub
G
et
(
context:
PubContext
.
flutterTests
,
checkLastModified:
false
).
then
((
void
value
)
{
pub
.
g
et
(
context:
PubContext
.
flutterTests
,
checkLastModified:
false
).
then
((
void
value
)
{
error
=
'test completed unexpectedly'
;
},
onError:
(
dynamic
thrownError
)
{
error
=
'test failed unexpectedly:
$thrownError
'
;
...
...
@@ -149,11 +151,12 @@ void main() {
'PUB_CACHE'
:
'custom/pub-cache/path'
,
}),
),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'analytics sent on success'
,
()
async
{
MockDirectory
.
findCache
=
true
;
await
pub
G
et
(
context:
PubContext
.
flutterTests
,
checkLastModified:
false
);
await
pub
.
g
et
(
context:
PubContext
.
flutterTests
,
checkLastModified:
false
);
verify
(
flutterUsage
.
sendEvent
(
'pub-result'
,
'flutter-tests'
,
label:
'success'
)).
called
(
1
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
MockProcessManager
(
0
),
...
...
@@ -164,12 +167,13 @@ void main() {
}),
),
Usage:
()
=>
MockUsage
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'analytics sent on failure'
,
()
async
{
MockDirectory
.
findCache
=
true
;
try
{
await
pub
G
et
(
context:
PubContext
.
flutterTests
,
checkLastModified:
false
);
await
pub
.
g
et
(
context:
PubContext
.
flutterTests
,
checkLastModified:
false
);
}
on
ToolExit
{
// Ignore.
}
...
...
@@ -183,12 +187,13 @@ void main() {
}),
),
Usage:
()
=>
MockUsage
(),
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'analytics sent on failed version solve'
,
()
async
{
MockDirectory
.
findCache
=
true
;
try
{
await
pub
G
et
(
context:
PubContext
.
flutterTests
,
checkLastModified:
false
);
await
pub
.
g
et
(
context:
PubContext
.
flutterTests
,
checkLastModified:
false
);
}
on
ToolExit
{
// Ignore.
}
...
...
@@ -205,6 +210,7 @@ void main() {
}),
),
Usage:
()
=>
MockUsage
(),
Pub:
()
=>
const
Pub
(),
});
}
...
...
packages/flutter_tools/test/general.shard/dart/sdk_validation_test.dart
View file @
fde26751
...
...
@@ -44,7 +44,7 @@ void main() {
}
'''
);
await
pub
G
et
(
context:
PubContext
.
flutterTests
,
directory:
projectDirectory
.
path
);
await
pub
.
g
et
(
context:
PubContext
.
flutterTests
,
directory:
projectDirectory
.
path
);
final
AnalysisServer
server
=
AnalysisServer
(
dartSdkPath
,
<
String
>[
projectDirectory
.
path
]);
try
{
final
int
errorCount
=
await
analyze
(
server
);
...
...
packages/flutter_tools/test/general.shard/web/web_fs_test.dart
View file @
fde26751
...
...
@@ -11,7 +11,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/base/process.dart'
;
import
'package:flutter_tools/src/build_info.dart'
;
import
'package:flutter_tools/src/
cache
.dart'
;
import
'package:flutter_tools/src/
dart/pub
.dart'
;
import
'package:flutter_tools/src/project.dart'
;
import
'package:flutter_tools/src/web/chrome.dart'
;
import
'package:flutter_tools/src/build_runner/web_fs.dart'
;
...
...
@@ -89,6 +89,7 @@ void main() {
fs
.
file
(
'.packages'
).
createSync
();
},
overrides:
<
Type
,
Generator
>{
Pub:
()
=>
MockPub
(),
OperatingSystemUtils:
()
=>
mockOperatingSystemUtils
,
BuildDaemonCreator:
()
=>
mockBuildDaemonCreator
,
ChromeLauncher:
()
=>
mockChromeLauncher
,
...
...
@@ -128,10 +129,13 @@ void main() {
);
// Since the .packages file is missing in the memory filesystem, this should
// be called.
verify
(
processUtils
.
stream
(
any
,
workingDirectory:
fs
.
path
.
join
(
Cache
.
flutterRoot
,
'packages'
,
'flutter_tools'
),
mapFunction:
anyNamed
(
'mapFunction'
),
environment:
anyNamed
(
'environment'
),)).
called
(
1
);
verify
(
pub
.
get
(
context:
PubContext
.
pubGet
,
directory:
anyNamed
(
'directory'
),
offline:
true
,
skipPubspecYamlCheck:
true
,
checkLastModified:
false
,
)).
called
(
1
);
// The build daemon is told to build once.
verify
(
mockBuildDaemonClient
.
startBuild
()).
called
(
1
);
...
...
@@ -213,3 +217,4 @@ class MockHttpMultiServer extends Mock implements HttpMultiServer {}
class
MockChromeLauncher
extends
Mock
implements
ChromeLauncher
{}
class
MockOperatingSystemUtils
extends
Mock
implements
OperatingSystemUtils
{}
class
MockProcessUtils
extends
Mock
implements
ProcessUtils
{}
class
MockPub
extends
Mock
implements
Pub
{}
packages/flutter_tools/test/src/context.dart
View file @
fde26751
...
...
@@ -17,6 +17,7 @@ import 'package:flutter_tools/src/base/terminal.dart';
import
'package:flutter_tools/src/base/time.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/context_runner.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/device.dart'
;
import
'package:flutter_tools/src/doctor.dart'
;
import
'package:flutter_tools/src/ios/plist_parser.dart'
;
...
...
@@ -29,6 +30,7 @@ import 'package:meta/meta.dart';
import
'package:mockito/mockito.dart'
;
import
'common.dart'
;
import
'testbed.dart'
;
export
'package:flutter_tools/src/base/context.dart'
show
Generator
;
...
...
@@ -92,6 +94,7 @@ void testUsingContext(
TimeoutConfiguration:
()
=>
const
TimeoutConfiguration
(),
PlistParser:
()
=>
FakePlistParser
(),
Signals:
()
=>
FakeSignals
(),
Pub:
()
=>
ThrowingPub
()
// prevent accidentally using pub.
},
body:
()
{
final
String
flutterRoot
=
getFlutterRoot
();
...
...
packages/flutter_tools/test/src/testbed.dart
View file @
fde26751
...
...
@@ -18,6 +18,7 @@ import 'package:flutter_tools/src/base/signals.dart';
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/context_runner.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
import
'package:flutter_tools/src/features.dart'
;
import
'package:flutter_tools/src/reporting/reporting.dart'
;
import
'package:flutter_tools/src/version.dart'
;
...
...
@@ -37,6 +38,7 @@ final Map<Type, Generator> _testbedDefaults = <Type, Generator>{
Usage:
()
=>
NoOpUsage
(),
// prevent addition of analytics from burdening test mocks
FlutterVersion:
()
=>
FakeFlutterVersion
(),
// prevent requirement to mock git for test runner.
Signals:
()
=>
FakeSignals
(),
// prevent registering actual signal handlers.
Pub:
()
=>
ThrowingPub
(),
// prevent accidental invocations of pub.
};
/// Manages interaction with the tool injection and runner system.
...
...
@@ -711,3 +713,35 @@ class TestFeatureFlags implements FeatureFlags {
@override
final
bool
isNewAndroidEmbeddingEnabled
;
}
class
ThrowingPub
implements
Pub
{
@override
Future
<
void
>
batch
(
List
<
String
>
arguments
,
{
PubContext
context
,
String
directory
,
MessageFilter
filter
,
String
failureMessage
=
'pub failed'
,
bool
retry
,
bool
showTraceForErrors
,
})
{
throw
UnsupportedError
(
'Attempted to inovke pub during test.'
);
}
@override
Future
<
void
>
get
({
PubContext
context
,
String
directory
,
bool
skipIfAbsent
=
false
,
bool
upgrade
=
false
,
bool
offline
=
false
,
bool
checkLastModified
=
true
,
bool
skipPubspecYamlCheck
=
false
,
})
{
throw
UnsupportedError
(
'Attempted to inovke pub during test.'
);
}
@override
Future
<
void
>
interactively
(
List
<
String
>
arguments
,
{
String
directory
})
{
throw
UnsupportedError
(
'Attempted to inovke pub during test.'
);
}
}
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