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
d3c8a0bd
Unverified
Commit
d3c8a0bd
authored
Feb 18, 2021
by
Jenn Magder
Committed by
GitHub
Feb 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove mocks from visual_studio_test (#76260)
parent
805fffd1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
80 deletions
+63
-80
visual_studio_test.dart
..._tools/test/general.shard/windows/visual_studio_test.dart
+63
-55
mocks.dart
packages/flutter_tools/test/src/mocks.dart
+0
-25
No files found.
packages/flutter_tools/test/general.shard/windows/visual_studio_test.dart
View file @
d3c8a0bd
...
...
@@ -11,11 +11,9 @@ import 'package:flutter_tools/src/base/logger.dart';
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/convert.dart'
;
import
'package:flutter_tools/src/windows/visual_studio.dart'
;
import
'package:mockito/mockito.dart'
;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/mocks.dart'
;
const
String
programFilesPath
=
r'C:\Program Files (x86)'
;
const
String
visualStudioPath
=
programFilesPath
+
r'\Microsoft Visual Studio\2017\Community'
;
...
...
@@ -108,6 +106,8 @@ void setMockVswhereResponse(
List
<
String
>
additionalArguments
,
Map
<
String
,
dynamic
>
response
,
String
responseOverride
,
int
exitCode
,
Exception
exception
,
])
{
fileSystem
.
file
(
vswherePath
).
createSync
(
recursive:
true
);
fileSystem
.
file
(
cmakePath
).
createSync
(
recursive:
true
);
...
...
@@ -130,6 +130,8 @@ void setMockVswhereResponse(
...?
requirementArguments
,
],
stdout:
finalResponse
,
exception:
exception
,
exitCode:
exitCode
??
0
,
));
}
...
...
@@ -138,14 +140,19 @@ void setMockVswhereResponse(
void
setMockCompatibleVisualStudioInstallation
(
Map
<
String
,
dynamic
>
response
,
FileSystem
fileSystem
,
FakeProcessManager
processManager
,
)
{
FakeProcessManager
processManager
,
[
int
exitCode
,
Exception
exception
,
])
{
setMockVswhereResponse
(
fileSystem
,
processManager
,
_requirements
,
<
String
>[
'-version'
,
'16'
],
response
,
null
,
exitCode
,
exception
,
);
}
...
...
@@ -154,14 +161,19 @@ void setMockCompatibleVisualStudioInstallation(
void
setMockPrereleaseVisualStudioInstallation
(
Map
<
String
,
dynamic
>
response
,
FileSystem
fileSystem
,
FakeProcessManager
processManager
,
)
{
FakeProcessManager
processManager
,
[
int
exitCode
,
Exception
exception
,
])
{
setMockVswhereResponse
(
fileSystem
,
processManager
,
_requirements
,
<
String
>[
'-version'
,
'16'
,
'-prerelease'
],
response
,
null
,
exitCode
,
exception
,
);
}
...
...
@@ -170,14 +182,19 @@ void setMockPrereleaseVisualStudioInstallation(
void
setMockCompatibleVisualStudioBuildToolsInstallation
(
Map
<
String
,
dynamic
>
response
,
FileSystem
fileSystem
,
FakeProcessManager
processManager
,
)
{
FakeProcessManager
processManager
,
[
int
exitCode
,
Exception
exception
,
])
{
setMockVswhereResponse
(
fileSystem
,
processManager
,
_requirementsBuildTools
,
<
String
>[
'-version'
,
'16'
],
response
,
null
,
exitCode
,
exception
,
);
}
...
...
@@ -186,14 +203,19 @@ void setMockCompatibleVisualStudioBuildToolsInstallation(
void
setMockPrereleaseVisualStudioBuildToolsInstallation
(
Map
<
String
,
dynamic
>
response
,
FileSystem
fileSystem
,
FakeProcessManager
processManager
,
)
{
FakeProcessManager
processManager
,
[
int
exitCode
,
Exception
exception
,
])
{
setMockVswhereResponse
(
fileSystem
,
processManager
,
_requirementsBuildTools
,
<
String
>[
'-version'
,
'16'
,
'-prerelease'
],
response
,
null
,
exitCode
,
exception
,
);
}
...
...
@@ -202,14 +224,19 @@ void setMockPrereleaseVisualStudioBuildToolsInstallation(
void
setMockAnyVisualStudioInstallation
(
Map
<
String
,
dynamic
>
response
,
FileSystem
fileSystem
,
FakeProcessManager
processManager
,
)
{
FakeProcessManager
processManager
,
[
int
exitCode
,
Exception
exception
,
])
{
setMockVswhereResponse
(
fileSystem
,
processManager
,
null
,
<
String
>[
'-prerelease'
,
'-all'
],
response
,
null
,
exitCode
,
exception
,
);
}
...
...
@@ -315,65 +342,48 @@ void setNoViableToolchainInstallation(
void
main
(
)
{
group
(
'Visual Studio'
,
()
{
testWithoutContext
(
'isInstalled returns false when vswhere is missing'
,
()
{
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
when
(
mockProcessManager
.
runSync
(
any
,
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
stdoutEncoding:
utf8
,
stderrEncoding:
utf8
,
)).
thenThrow
(
const
ProcessException
(
'vswhere'
,
<
String
>[]));
final
VisualStudio
visualStudio
=
VisualStudio
(
logger:
BufferLogger
.
test
(),
fileSystem:
MemoryFileSystem
.
test
(
style:
FileSystemStyle
.
windows
),
platform:
windowsPlatform
,
processManager:
mockProcessManager
,
);
testWithoutContext
(
'isInstalled and cmakePath correct when vswhere is missing'
,
()
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
(
style:
FileSystemStyle
.
windows
);
const
Exception
exception
=
ProcessException
(
'vswhere'
,
<
String
>[]);
final
FakeProcessManager
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]);
expect
(
visualStudio
.
isInstalled
,
false
);
});
setMockCompatibleVisualStudioInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
null
,
exception
);
setMockCompatibleVisualStudioBuildToolsInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
null
,
exception
);
setMockPrereleaseVisualStudioInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
null
,
exception
);
setMockPrereleaseVisualStudioBuildToolsInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
null
,
exception
);
setMockAnyVisualStudioInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
null
,
exception
);
testWithoutContext
(
'cmakePath returns null when vswhere is missing'
,
()
{
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
when
(
mockProcessManager
.
runSync
(
any
,
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
stdoutEncoding:
utf8
,
stderrEncoding:
utf8
,
)).
thenThrow
(
const
ProcessException
(
'vswhere'
,
<
String
>[]));
final
VisualStudio
visualStudio
=
VisualStudio
(
logger:
BufferLogger
.
test
(),
fileSystem:
MemoryFileSystem
.
test
(
style:
FileSystemStyle
.
windows
)
,
fileSystem:
fileSystem
,
platform:
windowsPlatform
,
processManager:
mock
ProcessManager
,
processManager:
fake
ProcessManager
,
);
expect
(
visualStudio
.
isInstalled
,
false
);
expect
(
visualStudio
.
cmakePath
,
isNull
);
});
testWithoutContext
(
'isInstalled returns false when vswhere returns non-zero'
,
()
{
final
MockProcessManager
mockProcessManager
=
MockProcessManager
();
when
(
mockProcessManager
.
runSync
(
any
,
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
stdoutEncoding:
utf8
,
stderrEncoding:
utf8
,
)).
thenAnswer
((
Invocation
invocation
)
{
return
FakeProcessResult
(
exitCode:
1
,
stderr:
''
,
stdout:
''
);
});
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
(
style:
FileSystemStyle
.
windows
);
final
FakeProcessManager
fakeProcessManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]);
setMockCompatibleVisualStudioInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
1
);
setMockCompatibleVisualStudioBuildToolsInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
1
);
setMockPrereleaseVisualStudioInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
1
);
setMockPrereleaseVisualStudioBuildToolsInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
1
);
setMockAnyVisualStudioInstallation
(
null
,
fileSystem
,
fakeProcessManager
,
1
);
final
VisualStudio
visualStudio
=
VisualStudio
(
logger:
BufferLogger
.
test
(),
fileSystem:
MemoryFileSystem
.
test
(
style:
FileSystemStyle
.
windows
)
,
fileSystem:
fileSystem
,
platform:
windowsPlatform
,
processManager:
mock
ProcessManager
,
processManager:
fake
ProcessManager
,
);
expect
(
visualStudio
.
isInstalled
,
false
);
expect
(
visualStudio
.
isInstalled
,
false
);
expect
(
visualStudio
.
cmakePath
,
isNull
);
});
testWithoutContext
(
'VisualStudio getters return the right values if no installation is found'
,
()
{
...
...
@@ -820,5 +830,3 @@ class VisualStudioFixture {
final
FileSystem
fileSystem
;
final
FakeProcessManager
processManager
;
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
packages/flutter_tools/test/src/mocks.dart
View file @
d3c8a0bd
...
...
@@ -323,31 +323,6 @@ class MockResidentCompiler extends _BasicMock implements ResidentCompiler {
void
addFileSystemRoot
(
String
root
)
{
}
}
/// A fake implementation of [ProcessResult].
class
FakeProcessResult
implements
ProcessResult
{
FakeProcessResult
({
this
.
exitCode
=
0
,
this
.
pid
=
1
,
this
.
stderr
,
this
.
stdout
,
});
@override
final
int
exitCode
;
@override
final
int
pid
;
@override
final
dynamic
stderr
;
@override
final
dynamic
stdout
;
@override
String
toString
()
=>
stdout
?.
toString
()
??
stderr
?.
toString
()
??
runtimeType
.
toString
();
}
class
MockStdIn
extends
Mock
implements
IOSink
{
final
StringBuffer
stdInWrites
=
StringBuffer
();
...
...
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