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
e00d424d
Unverified
Commit
e00d424d
authored
Feb 27, 2020
by
Jonah Williams
Committed by
GitHub
Feb 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] clean-ups to linux doctor test (#51593)
parent
fef2d6cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
146 deletions
+119
-146
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+3
-1
linux_doctor.dart
packages/flutter_tools/lib/src/linux/linux_doctor.dart
+11
-4
linux_doctor_test.dart
...ter_tools/test/general.shard/linux/linux_doctor_test.dart
+105
-141
No files found.
packages/flutter_tools/lib/src/doctor.dart
View file @
e00d424d
...
...
@@ -81,7 +81,9 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider {
fileSystem:
globals
.
fs
,
),
if
(
linuxWorkflow
.
appliesToHostPlatform
)
LinuxDoctorValidator
(),
LinuxDoctorValidator
(
processManager:
globals
.
processManager
,
),
if
(
windowsWorkflow
.
appliesToHostPlatform
)
visualStudioValidator
,
if
(
ideValidators
.
isNotEmpty
)
...
...
packages/flutter_tools/lib/src/linux/linux_doctor.dart
View file @
e00d424d
...
...
@@ -2,14 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:meta/meta.dart'
;
import
'package:process/process.dart'
;
import
'../base/io.dart'
;
import
'../base/version.dart'
;
import
'../doctor.dart'
;
import
'../globals.dart'
as
globals
;
/// A validator that checks for Clang and Make build dependencies
class
LinuxDoctorValidator
extends
DoctorValidator
{
LinuxDoctorValidator
()
:
super
(
'Linux toolchain - develop for Linux desktop'
);
LinuxDoctorValidator
({
@required
ProcessManager
processManager
,
})
:
_processManager
=
processManager
,
super
(
'Linux toolchain - develop for Linux desktop'
);
final
ProcessManager
_processManager
;
/// The minimum version of clang supported.
final
Version
minimumClangVersion
=
Version
(
3
,
4
,
0
);
...
...
@@ -21,7 +28,7 @@ class LinuxDoctorValidator extends DoctorValidator {
/// Check for a minimum version of Clang.
ProcessResult
clangResult
;
try
{
clangResult
=
await
globals
.
processManager
.
run
(
const
<
String
>[
clangResult
=
await
_
processManager
.
run
(
const
<
String
>[
'clang++'
,
'--version'
,
]);
...
...
@@ -48,7 +55,7 @@ class LinuxDoctorValidator extends DoctorValidator {
// a better idea about what is supported.
ProcessResult
makeResult
;
try
{
makeResult
=
await
globals
.
processManager
.
run
(
const
<
String
>[
makeResult
=
await
_
processManager
.
run
(
const
<
String
>[
'make'
,
'--version'
,
]);
...
...
packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart
View file @
e00d424d
...
...
@@ -3,157 +3,121 @@
// found in the LICENSE file.
import
'package:flutter_tools/src/doctor.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/linux/linux_doctor.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/mocks.dart'
;
void
main
(
)
{
group
(
LinuxDoctorValidator
,
()
{
ProcessManager
processManager
;
LinuxDoctorValidator
linuxDoctorValidator
;
setUp
(()
{
processManager
=
MockProcessManager
();
linuxDoctorValidator
=
LinuxDoctorValidator
();
});
testUsingContext
(
'Returns full validation when clang++ and make are availibe'
,
()
async
{
when
(
globals
.
processManager
.
run
(<
String
>[
'clang++'
,
'--version'
])).
thenAnswer
((
_
)
async
{
return
FakeProcessResult
(
stdout:
'clang version 4.0.1-10 (tags/RELEASE_401/final)
\n
junk'
,
exitCode:
0
,
);
});
when
(
globals
.
processManager
.
run
(<
String
>[
'make'
,
'--version'
,
])).
thenAnswer
((
_
)
async
{
return
FakeProcessResult
(
stdout:
'GNU Make 4.1
\n
junk'
,
exitCode:
0
,
);
});
final
ValidationResult
result
=
await
linuxDoctorValidator
.
validate
();
expect
(
result
.
type
,
ValidationType
.
installed
);
expect
(
result
.
messages
,
<
ValidationMessage
>[
ValidationMessage
(
'clang++ 4.0.1'
),
ValidationMessage
(
'GNU Make 4.1'
),
]);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
});
testUsingContext
(
'Returns partial validation when clang++ version is too old'
,
()
async
{
when
(
globals
.
processManager
.
run
(<
String
>[
'clang++'
,
'--version'
])).
thenAnswer
((
_
)
async
{
return
FakeProcessResult
(
stdout:
'clang version 2.0.1-10 (tags/RELEASE_401/final)
\n
junk'
,
exitCode:
0
,
);
});
when
(
globals
.
processManager
.
run
(<
String
>[
'make'
,
'--version'
,
])).
thenAnswer
((
_
)
async
{
return
FakeProcessResult
(
stdout:
'GNU Make 4.1
\n
junk'
,
exitCode:
0
,
);
});
final
ValidationResult
result
=
await
linuxDoctorValidator
.
validate
();
expect
(
result
.
type
,
ValidationType
.
partial
);
expect
(
result
.
messages
,
<
ValidationMessage
>[
ValidationMessage
.
error
(
'clang++ 2.0.1 is below minimum version of 3.4.0'
),
ValidationMessage
(
'GNU Make 4.1'
),
]);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
});
testUsingContext
(
'Returns mising validation when make is not availible'
,
()
async
{
when
(
globals
.
processManager
.
run
(<
String
>[
'clang++'
,
'--version'
])).
thenAnswer
((
_
)
async
{
return
FakeProcessResult
(
stdout:
'clang version 4.0.1-10 (tags/RELEASE_401/final)
\n
junk'
,
exitCode:
0
,
);
});
when
(
globals
.
processManager
.
run
(<
String
>[
'make'
,
'--version'
,
])).
thenAnswer
((
_
)
async
{
return
FakeProcessResult
(
stdout:
''
,
exitCode:
1
,
);
});
final
ValidationResult
result
=
await
linuxDoctorValidator
.
validate
();
expect
(
result
.
type
,
ValidationType
.
missing
);
expect
(
result
.
messages
,
<
ValidationMessage
>[
ValidationMessage
(
'clang++ 4.0.1'
),
ValidationMessage
.
error
(
'make is not installed'
),
]);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
});
testUsingContext
(
'Returns mising validation when clang++ is not availible'
,
()
async
{
when
(
globals
.
processManager
.
run
(<
String
>[
'clang++'
,
'--version'
])).
thenAnswer
((
_
)
async
{
return
FakeProcessResult
(
stdout:
''
,
exitCode:
1
,
);
});
when
(
globals
.
processManager
.
run
(<
String
>[
'make'
,
'--version'
,
])).
thenAnswer
((
_
)
async
{
return
FakeProcessResult
(
stdout:
'GNU Make 4.1
\n
junk'
,
exitCode:
0
,
);
});
testWithoutContext
(
'Full validation when clang++ and Make are available'
,()
async
{
final
ProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'clang++'
,
'--version'
],
stdout:
'clang version 4.0.1-10 (tags/RELEASE_401/final)
\n
junk'
,
),
const
FakeCommand
(
command:
<
String
>[
'make'
,
'--version'
],
stdout:
'GNU Make 4.1
\n
junk'
,
),
]);
final
DoctorValidator
linuxDoctorValidator
=
LinuxDoctorValidator
(
processManager:
processManager
,
);
final
ValidationResult
result
=
await
linuxDoctorValidator
.
validate
();
expect
(
result
.
type
,
ValidationType
.
installed
);
expect
(
result
.
messages
,
<
ValidationMessage
>[
ValidationMessage
(
'clang++ 4.0.1'
),
ValidationMessage
(
'GNU Make 4.1'
),
]);
});
final
ValidationResult
result
=
await
linuxDoctorValidator
.
validate
();
expect
(
result
.
type
,
ValidationType
.
missing
);
expect
(
result
.
messages
,
<
ValidationMessage
>[
ValidationMessage
.
error
(
'clang++ is not installed'
),
ValidationMessage
(
'GNU Make 4.1'
),
]);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
});
testWithoutContext
(
'Partial validation when clang++ version is too old'
,
()
async
{
final
ProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'clang++'
,
'--version'
],
stdout:
'clang version 2.0.1-10 (tags/RELEASE_401/final)
\n
junk'
,
),
const
FakeCommand
(
command:
<
String
>[
'make'
,
'--version'
],
stdout:
'GNU Make 4.1
\n
junk'
,
),
]);
final
DoctorValidator
linuxDoctorValidator
=
LinuxDoctorValidator
(
processManager:
processManager
,
);
final
ValidationResult
result
=
await
linuxDoctorValidator
.
validate
();
expect
(
result
.
type
,
ValidationType
.
partial
);
expect
(
result
.
messages
,
<
ValidationMessage
>[
ValidationMessage
.
error
(
'clang++ 2.0.1 is below minimum version of 3.4.0'
),
ValidationMessage
(
'GNU Make 4.1'
),
]);
});
testWithoutContext
(
'Missing validation when Make is not available'
,
()
async
{
final
ProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'clang++'
,
'--version'
],
stdout:
'clang version 4.0.1-10 (tags/RELEASE_401/final)
\n
junk'
,
),
const
FakeCommand
(
command:
<
String
>[
'make'
,
'--version'
],
exitCode:
1
,
),
]);
final
DoctorValidator
linuxDoctorValidator
=
LinuxDoctorValidator
(
processManager:
processManager
,
);
final
ValidationResult
result
=
await
linuxDoctorValidator
.
validate
();
expect
(
result
.
type
,
ValidationType
.
missing
);
expect
(
result
.
messages
,
<
ValidationMessage
>[
ValidationMessage
(
'clang++ 4.0.1'
),
ValidationMessage
.
error
(
'make is not installed'
),
]);
});
testUsingContext
(
'Returns missing validation when clang and make are not availible'
,
()
async
{
when
(
globals
.
processManager
.
run
(<
String
>[
'clang++'
,
'--version'
])).
thenAnswer
((
_
)
async
{
return
FakeProcessResult
(
stdout:
''
,
exitCode:
1
,
);
});
when
(
globals
.
processManager
.
run
(<
String
>[
'make'
,
'--version'
,
])).
thenAnswer
((
_
)
async
{
return
FakeProcessResult
(
stdout:
''
,
exitCode:
1
,
);
});
testWithoutContext
(
'Missing validation when clang++ is not available'
,
()
async
{
final
ProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'clang++'
,
'--version'
],
exitCode:
1
),
const
FakeCommand
(
command:
<
String
>[
'make'
,
'--version'
],
stdout:
'GNU Make 4.1
\n
junk'
),
]);
final
DoctorValidator
linuxDoctorValidator
=
LinuxDoctorValidator
(
processManager:
processManager
,
);
final
ValidationResult
result
=
await
linuxDoctorValidator
.
validate
();
expect
(
result
.
type
,
ValidationType
.
missing
);
expect
(
result
.
messages
,
<
ValidationMessage
>[
ValidationMessage
.
error
(
'clang++ is not installed'
),
ValidationMessage
(
'GNU Make 4.1'
),
]);
});
final
ValidationResult
result
=
await
linuxDoctorValidator
.
validate
();
expect
(
result
.
type
,
ValidationType
.
missing
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
});
testWithoutContext
(
'Missing validation when clang++ and Make are not available'
,
()
async
{
final
ProcessManager
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'clang++'
,
'--version'
],
exitCode:
1
,
),
const
FakeCommand
(
command:
<
String
>[
'make'
,
'--version'
],
exitCode:
1
,
),
]);
final
DoctorValidator
linuxDoctorValidator
=
LinuxDoctorValidator
(
processManager:
processManager
,
);
final
ValidationResult
result
=
await
linuxDoctorValidator
.
validate
();
expect
(
result
.
type
,
ValidationType
.
missing
);
});
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
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