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
cf903d73
Unverified
Commit
cf903d73
authored
Mar 22, 2021
by
Jonah Williams
Committed by
GitHub
Mar 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove globals from process, filesystem (#78357)
parent
e85fe60d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
30 deletions
+24
-30
executable.dart
packages/flutter_tools/lib/executable.dart
+1
-2
runner.dart
packages/flutter_tools/lib/runner.dart
+1
-1
file_system.dart
packages/flutter_tools/lib/src/base/file_system.dart
+5
-17
process.dart
packages/flutter_tools/lib/src/base/process.dart
+0
-5
globals.dart
packages/flutter_tools/lib/src/globals.dart
+13
-1
analyze_continuously_test.dart
...st/commands.shard/hermetic/analyze_continuously_test.dart
+1
-1
analyze_once_test.dart
...ools/test/commands.shard/permeable/analyze_once_test.dart
+1
-1
common.dart
packages/flutter_tools/test/src/common.dart
+2
-2
No files found.
packages/flutter_tools/lib/executable.dart
View file @
cf903d73
...
@@ -9,7 +9,6 @@ import 'package:meta/meta.dart';
...
@@ -9,7 +9,6 @@ import 'package:meta/meta.dart';
import
'runner.dart'
as
runner
;
import
'runner.dart'
as
runner
;
import
'src/artifacts.dart'
;
import
'src/artifacts.dart'
;
import
'src/base/context.dart'
;
import
'src/base/context.dart'
;
import
'src/base/file_system.dart'
;
import
'src/base/io.dart'
;
import
'src/base/io.dart'
;
import
'src/base/logger.dart'
;
import
'src/base/logger.dart'
;
import
'src/base/platform.dart'
;
import
'src/base/platform.dart'
;
...
@@ -85,7 +84,7 @@ Future<void> main(List<String> args) async {
...
@@ -85,7 +84,7 @@ Future<void> main(List<String> args) async {
// instances of the platform or filesystem, so just use those.
// instances of the platform or filesystem, so just use those.
Cache
.
flutterRoot
=
Cache
.
defaultFlutterRoot
(
Cache
.
flutterRoot
=
Cache
.
defaultFlutterRoot
(
platform:
const
LocalPlatform
(),
platform:
const
LocalPlatform
(),
fileSystem:
LocalFileSystem
.
instance
,
fileSystem:
globals
.
localFileSystem
,
userMessages:
UserMessages
(),
userMessages:
UserMessages
(),
);
);
...
...
packages/flutter_tools/lib/runner.dart
View file @
cf903d73
...
@@ -250,7 +250,7 @@ Future<int> _exit(int code) async {
...
@@ -250,7 +250,7 @@ Future<int> _exit(int code) async {
}
}
// Run shutdown hooks before flushing logs
// Run shutdown hooks before flushing logs
await
shutdownHooks
.
runShutdownHooks
();
await
globals
.
shutdownHooks
.
runShutdownHooks
();
final
Completer
<
void
>
completer
=
Completer
<
void
>();
final
Completer
<
void
>
completer
=
Completer
<
void
>();
...
...
packages/flutter_tools/lib/src/base/file_system.dart
View file @
cf903d73
...
@@ -163,31 +163,19 @@ void copyDirectory(
...
@@ -163,31 +163,19 @@ void copyDirectory(
/// directories and files that the tool creates under the system temporary
/// directories and files that the tool creates under the system temporary
/// directory when the tool exits either normally or when killed by a signal.
/// directory when the tool exits either normally or when killed by a signal.
class
LocalFileSystem
extends
local_fs
.
LocalFileSystem
{
class
LocalFileSystem
extends
local_fs
.
LocalFileSystem
{
LocalFileSystem
.
_
(
Signals
signals
,
List
<
ProcessSignal
>
fatalSignals
)
:
LocalFileSystem
(
this
.
_signals
,
this
.
_fatalSignals
,
this
.
_shutdownHooks
);
_signals
=
signals
,
_fatalSignals
=
fatalSignals
;
@visibleForTesting
@visibleForTesting
LocalFileSystem
.
test
({
LocalFileSystem
.
test
({
@required
Signals
signals
,
@required
Signals
signals
,
List
<
ProcessSignal
>
fatalSignals
=
Signals
.
defaultExitSignals
,
List
<
ProcessSignal
>
fatalSignals
=
Signals
.
defaultExitSignals
,
})
:
this
.
_
(
signals
,
fatalSignals
);
})
:
this
(
signals
,
fatalSignals
,
null
);
// Unless we're in a test of this class's signal handling features, we must
// have only one instance created with the singleton LocalSignals instance
// and the catchable signals it considers to be fatal.
static
LocalFileSystem
_instance
;
static
LocalFileSystem
get
instance
=>
_instance
??=
LocalFileSystem
.
_
(
LocalSignals
.
instance
,
Signals
.
defaultExitSignals
,
);
Directory
_systemTemp
;
Directory
_systemTemp
;
final
Map
<
ProcessSignal
,
Object
>
_signalTokens
=
<
ProcessSignal
,
Object
>{};
final
Map
<
ProcessSignal
,
Object
>
_signalTokens
=
<
ProcessSignal
,
Object
>{};
final
ShutdownHooks
_shutdownHooks
;
@visibleForTesting
Future
<
void
>
dispose
()
async
{
static
Future
<
void
>
dispose
()
=>
LocalFileSystem
.
instance
?.
_dispose
();
Future
<
void
>
_dispose
()
async
{
_tryToDeleteTemp
();
_tryToDeleteTemp
();
for
(
final
MapEntry
<
ProcessSignal
,
Object
>
signalToken
in
_signalTokens
.
entries
)
{
for
(
final
MapEntry
<
ProcessSignal
,
Object
>
signalToken
in
_signalTokens
.
entries
)
{
await
_signals
.
removeHandler
(
signalToken
.
key
,
signalToken
.
value
);
await
_signals
.
removeHandler
(
signalToken
.
key
,
signalToken
.
value
);
...
@@ -233,7 +221,7 @@ class LocalFileSystem extends local_fs.LocalFileSystem {
...
@@ -233,7 +221,7 @@ class LocalFileSystem extends local_fs.LocalFileSystem {
}
}
// Make sure that the temporary directory is cleaned up when the tool
// Make sure that the temporary directory is cleaned up when the tool
// exits normally.
// exits normally.
shutdownHooks
?.
addShutdownHook
(
_
shutdownHooks
?.
addShutdownHook
(
_tryToDeleteTemp
,
_tryToDeleteTemp
,
);
);
}
}
...
...
packages/flutter_tools/lib/src/base/process.dart
View file @
cf903d73
...
@@ -11,7 +11,6 @@ import 'package:process/process.dart';
...
@@ -11,7 +11,6 @@ import 'package:process/process.dart';
import
'../convert.dart'
;
import
'../convert.dart'
;
import
'common.dart'
;
import
'common.dart'
;
import
'context.dart'
;
import
'io.dart'
;
import
'io.dart'
;
import
'logger.dart'
;
import
'logger.dart'
;
...
@@ -26,8 +25,6 @@ typedef ShutdownHook = FutureOr<dynamic> Function();
...
@@ -26,8 +25,6 @@ typedef ShutdownHook = FutureOr<dynamic> Function();
// See [here](https://github.com/flutter/flutter/pull/14535#discussion_r167041161)
// See [here](https://github.com/flutter/flutter/pull/14535#discussion_r167041161)
// for more details.
// for more details.
ShutdownHooks
get
shutdownHooks
=>
ShutdownHooks
.
instance
;
abstract
class
ShutdownHooks
{
abstract
class
ShutdownHooks
{
factory
ShutdownHooks
({
factory
ShutdownHooks
({
@required
Logger
logger
,
@required
Logger
logger
,
...
@@ -35,8 +32,6 @@ abstract class ShutdownHooks {
...
@@ -35,8 +32,6 @@ abstract class ShutdownHooks {
logger:
logger
,
logger:
logger
,
);
);
static
ShutdownHooks
get
instance
=>
context
.
get
<
ShutdownHooks
>();
/// Registers a [ShutdownHook] to be executed before the VM exits.
/// Registers a [ShutdownHook] to be executed before the VM exits.
void
addShutdownHook
(
void
addShutdownHook
(
ShutdownHook
shutdownHook
ShutdownHook
shutdownHook
...
...
packages/flutter_tools/lib/src/globals.dart
View file @
cf903d73
...
@@ -74,7 +74,7 @@ LocalEngineLocator get localEngineLocator => context.get<LocalEngineLocator>();
...
@@ -74,7 +74,7 @@ LocalEngineLocator get localEngineLocator => context.get<LocalEngineLocator>();
/// By default it uses local disk-based implementation. Override this in tests
/// By default it uses local disk-based implementation. Override this in tests
/// with [MemoryFileSystem].
/// with [MemoryFileSystem].
FileSystem
get
fs
=>
ErrorHandlingFileSystem
(
FileSystem
get
fs
=>
ErrorHandlingFileSystem
(
delegate:
context
.
get
<
FileSystem
>()
??
LocalFileSystem
.
instance
,
delegate:
context
.
get
<
FileSystem
>()
??
localFileSystem
,
platform:
platform
,
platform:
platform
,
);
);
...
@@ -213,3 +213,15 @@ TemplateRenderer get templateRenderer => context.get<TemplateRenderer>();
...
@@ -213,3 +213,15 @@ TemplateRenderer get templateRenderer => context.get<TemplateRenderer>();
/// Gradle utils in the current [AppContext].
/// Gradle utils in the current [AppContext].
GradleUtils
get
gradleUtils
=>
context
.
get
<
GradleUtils
>();
GradleUtils
get
gradleUtils
=>
context
.
get
<
GradleUtils
>();
ShutdownHooks
get
shutdownHooks
=>
context
.
get
<
ShutdownHooks
>();
// Unless we're in a test of this class's signal handling features, we must
// have only one instance created with the singleton LocalSignals instance
// and the catchable signals it considers to be fatal.
LocalFileSystem
_instance
;
LocalFileSystem
get
localFileSystem
=>
_instance
??=
LocalFileSystem
(
LocalSignals
.
instance
,
Signals
.
defaultExitSignals
,
shutdownHooks
,
);
packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart
View file @
cf903d73
...
@@ -39,7 +39,7 @@ void main() {
...
@@ -39,7 +39,7 @@ void main() {
Logger
logger
;
Logger
logger
;
setUp
(()
{
setUp
(()
{
fileSystem
=
LocalFileSystem
.
instance
;
fileSystem
=
globals
.
localFileSystem
;
platform
=
const
LocalPlatform
();
platform
=
const
LocalPlatform
();
processManager
=
const
LocalProcessManager
();
processManager
=
const
LocalProcessManager
();
terminal
=
AnsiTerminal
(
platform:
platform
,
stdio:
Stdio
());
terminal
=
AnsiTerminal
(
platform:
platform
,
stdio:
Stdio
());
...
...
packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart
View file @
cf903d73
...
@@ -111,7 +111,7 @@ void main() {
...
@@ -111,7 +111,7 @@ void main() {
processManager
=
const
LocalProcessManager
();
processManager
=
const
LocalProcessManager
();
platform
=
const
LocalPlatform
();
platform
=
const
LocalPlatform
();
terminal
=
AnsiTerminal
(
platform:
platform
,
stdio:
Stdio
());
terminal
=
AnsiTerminal
(
platform:
platform
,
stdio:
Stdio
());
fileSystem
=
LocalFileSystem
.
instance
;
fileSystem
=
globals
.
localFileSystem
;
logger
=
BufferLogger
.
test
();
logger
=
BufferLogger
.
test
();
analyzerSeparator
=
platform
.
isWindows
?
'-'
:
'•'
;
analyzerSeparator
=
platform
.
isWindows
?
'-'
:
'•'
;
artifacts
=
CachedArtifacts
(
artifacts
=
CachedArtifacts
(
...
...
packages/flutter_tools/test/src/common.dart
View file @
cf903d73
...
@@ -79,7 +79,7 @@ String getFlutterRoot() {
...
@@ -79,7 +79,7 @@ String getFlutterRoot() {
throw
invalidScript
();
throw
invalidScript
();
}
}
final
List
<
String
>
parts
=
path
.
split
(
LocalFileSystem
.
instance
.
path
.
fromUri
(
scriptUri
));
final
List
<
String
>
parts
=
path
.
split
(
globals
.
localFileSystem
.
path
.
fromUri
(
scriptUri
));
final
int
toolsIndex
=
parts
.
indexOf
(
'flutter_tools'
);
final
int
toolsIndex
=
parts
.
indexOf
(
'flutter_tools'
);
if
(
toolsIndex
==
-
1
)
{
if
(
toolsIndex
==
-
1
)
{
throw
invalidScript
();
throw
invalidScript
();
...
@@ -198,7 +198,7 @@ void test(String description, FutureOr<void> Function() body, {
...
@@ -198,7 +198,7 @@ void test(String description, FutureOr<void> Function() body, {
description
,
description
,
()
async
{
()
async
{
addTearDown
(()
async
{
addTearDown
(()
async
{
await
L
ocalFileSystem
.
dispose
();
await
globals
.
l
ocalFileSystem
.
dispose
();
});
});
return
body
();
return
body
();
},
},
...
...
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