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
b0810bc9
Unverified
Commit
b0810bc9
authored
Oct 30, 2021
by
Christopher Fujino
Committed by
GitHub
Oct 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix analysis throwing string (#91435)
parent
5883a662
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
3 deletions
+114
-3
analyze_once.dart
packages/flutter_tools/lib/src/commands/analyze_once.dart
+6
-1
analysis.dart
packages/flutter_tools/lib/src/dart/analysis.dart
+24
-1
flutter_command_runner.dart
.../flutter_tools/lib/src/runner/flutter_command_runner.dart
+0
-1
analyze_test.dart
...tter_tools/test/commands.shard/hermetic/analyze_test.dart
+84
-0
No files found.
packages/flutter_tools/lib/src/commands/analyze_once.dart
View file @
b0810bc9
...
...
@@ -125,7 +125,12 @@ class AnalyzeOnce extends AnalyzeBase {
// Completing the future in the callback can't fail.
unawaited
(
server
.
onExit
.
then
<
void
>((
int
exitCode
)
{
if
(!
analysisCompleter
.
isCompleted
)
{
analysisCompleter
.
completeError
(
'analysis server exited:
$exitCode
'
);
analysisCompleter
.
completeError
(
// Include the last 20 lines of server output in exception message
Exception
(
'analysis server exited with code
$exitCode
and output:
\n
${server.getLogs(20)}
'
,
),
);
}
}));
...
...
packages/flutter_tools/lib/src/dart/analysis.dart
View file @
b0810bc9
...
...
@@ -79,7 +79,7 @@ class AnalysisServer {
final
Stream
<
String
>
errorStream
=
_process
!.
stderr
.
transform
<
String
>(
utf8
.
decoder
)
.
transform
<
String
>(
const
LineSplitter
());
errorStream
.
listen
(
_
logger
.
print
Error
);
errorStream
.
listen
(
_
handle
Error
);
final
Stream
<
String
>
inStream
=
_process
!.
stdout
.
transform
<
String
>(
utf8
.
decoder
)
...
...
@@ -94,6 +94,28 @@ class AnalysisServer {
<
String
,
dynamic
>{
'included'
:
directories
,
'excluded'
:
<
String
>[]});
}
final
List
<
String
>
_logs
=
<
String
>[];
/// Aggregated STDOUT and STDERR logs from the server.
///
/// This can be surfaced to the user if the server crashes. If [tail] is null,
/// returns all logs, else only the last [tail] lines.
String
getLogs
([
int
?
tail
])
{
if
(
tail
==
null
)
{
return
_logs
.
join
(
'
\n
'
);
}
// Since List doesn't implement a .tail() method, we reverse it then use
// .take()
final
Iterable
<
String
>
reversedLogs
=
_logs
.
reversed
;
final
List
<
String
>
firstTailLogs
=
reversedLogs
.
take
(
tail
).
toList
();
return
firstTailLogs
.
reversed
.
join
(
'
\n
'
);
}
void
_handleError
(
String
message
)
{
_logs
.
add
(
'[stderr]
$message
'
);
_logger
.
printError
(
message
);
}
bool
get
didServerErrorOccur
=>
_didServerErrorOccur
;
Stream
<
bool
>
get
onAnalyzing
=>
_analyzingController
.
stream
;
...
...
@@ -113,6 +135,7 @@ class AnalysisServer {
}
void
_handleServerResponse
(
String
line
)
{
_logs
.
add
(
'[stdout]
$line
'
);
_logger
.
printTrace
(
'<==
$line
'
);
final
dynamic
response
=
json
.
decode
(
line
);
...
...
packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
View file @
b0810bc9
...
...
@@ -312,7 +312,6 @@ class FlutterCommandRunner extends CommandRunner<void> {
return
<
String
>[];
}
final
List
<
String
>
projectPaths
=
globals
.
fs
.
directory
(
rootPath
)
.
listSync
(
followLinks:
false
)
.
expand
((
FileSystemEntity
entity
)
{
...
...
packages/flutter_tools/test/commands.shard/hermetic/analyze_test.dart
View file @
b0810bc9
...
...
@@ -4,15 +4,25 @@
// @dart = 2.8
import
'package:args/command_runner.dart'
;
import
'package:file/file.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/artifacts.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/analyze.dart'
;
import
'package:flutter_tools/src/commands/analyze_base.dart'
;
import
'package:flutter_tools/src/dart/analysis.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/fake_process_manager.dart'
;
import
'../../src/test_flutter_command_runner.dart'
;
const
String
_kFlutterRoot
=
'/data/flutter'
;
const
int
SIGABRT
=
-
6
;
void
main
(
)
{
testWithoutContext
(
'analyze generate correct errors message'
,
()
async
{
...
...
@@ -35,6 +45,80 @@ void main() {
);
});
group
(
'analyze command'
,
()
{
FileSystem
fileSystem
;
Platform
platform
;
BufferLogger
logger
;
FakeProcessManager
processManager
;
Terminal
terminal
;
AnalyzeCommand
command
;
CommandRunner
<
void
>
runner
;
setUpAll
(()
{
Cache
.
disableLocking
();
});
setUp
(()
{
fileSystem
=
MemoryFileSystem
.
test
();
platform
=
FakePlatform
();
logger
=
BufferLogger
.
test
();
processManager
=
FakeProcessManager
.
empty
();
terminal
=
Terminal
.
test
();
command
=
AnalyzeCommand
(
artifacts:
Artifacts
.
test
(),
fileSystem:
fileSystem
,
logger:
logger
,
platform:
platform
,
processManager:
processManager
,
terminal:
terminal
,
);
runner
=
createTestCommandRunner
(
command
);
// Setup repo roots
const
String
homePath
=
'/home/user/flutter'
;
Cache
.
flutterRoot
=
homePath
;
for
(
final
String
dir
in
<
String
>[
'dev'
,
'examples'
,
'packages'
])
{
fileSystem
.
directory
(
homePath
).
childDirectory
(
dir
).
createSync
(
recursive:
true
);
}
});
testUsingContext
(
'SIGABRT throws Exception'
,
()
async
{
const
String
stderr
=
'Something bad happened!'
;
processManager
.
addCommands
(
<
FakeCommand
>[
const
FakeCommand
(
// artifact paths are from Artifacts.test() and stable
command:
<
String
>[
'HostArtifact.engineDartSdkPath/bin/dart'
,
'--disable-dart-dev'
,
'HostArtifact.engineDartSdkPath/bin/snapshots/analysis_server.dart.snapshot'
,
'--disable-server-feature-completion'
,
'--disable-server-feature-search'
,
'--sdk'
,
'HostArtifact.engineDartSdkPath'
,
],
exitCode:
SIGABRT
,
stderr:
stderr
,
),
],
);
await
expectLater
(
runner
.
run
(<
String
>[
'analyze'
]),
throwsA
(
isA
<
Exception
>().
having
(
(
Exception
e
)
=>
e
.
toString
(),
'description'
,
contains
(
'analysis server exited with code
$SIGABRT
and output:
\n
[stderr]
$stderr
'
),
),
),
);
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fileSystem
,
ProcessManager:
()
=>
processManager
,
});
});
testWithoutContext
(
'analyze inRepo'
,
()
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
fileSystem
.
directory
(
_kFlutterRoot
).
createSync
(
recursive:
true
);
...
...
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