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
99e7b0a0
Unverified
Commit
99e7b0a0
authored
May 06, 2019
by
Jonah Williams
Committed by
GitHub
May 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dont NPE with empty pubspec (#32072)
parent
526113db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
project.dart
packages/flutter_tools/lib/src/project.dart
+4
-0
project_test.dart
packages/flutter_tools/test/project_test.dart
+32
-0
No files found.
packages/flutter_tools/lib/src/project.dart
View file @
99e7b0a0
...
...
@@ -181,6 +181,10 @@ class FlutterProject {
return
null
;
}
final
YamlMap
pubspec
=
loadYaml
(
pubspecFile
.
readAsStringSync
());
// If the pubspec file is empty, this will be null.
if
(
pubspec
==
null
)
{
return
null
;
}
return
pubspec
[
'builders'
];
}
...
...
packages/flutter_tools/test/project_test.dart
View file @
99e7b0a0
...
...
@@ -20,6 +20,7 @@ import 'package:mockito/mockito.dart';
import
'src/common.dart'
;
import
'src/context.dart'
;
import
'src/testbed.dart'
;
void
main
(
)
{
group
(
'Project'
,
()
{
...
...
@@ -342,6 +343,37 @@ void main() {
});
});
});
group
(
'Regression test for invalid pubspec'
,
()
{
Testbed
testbed
;
setUp
(()
{
testbed
=
Testbed
();
});
test
(
'Handles asking for builders from an invalid pubspec'
,
()
=>
testbed
.
run
(()
{
fs
.
file
(
'pubspec.yaml'
)
..
createSync
()
..
writeAsStringSync
(
r''
'
# Hello, World
'''
);
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
expect
(
flutterProject
.
builders
,
null
);
}));
test
(
'Handles asking for builders from a trivial pubspec'
,
()
=>
testbed
.
run
(()
{
fs
.
file
(
'pubspec.yaml'
)
..
createSync
()
..
writeAsStringSync
(
r''
'
# Hello, World
name: foo_bar
'''
);
final
FlutterProject
flutterProject
=
FlutterProject
.
current
();
expect
(
flutterProject
.
builders
,
null
);
}));
});
}
Future
<
FlutterProject
>
someProject
()
async
{
...
...
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