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
a49d6773
Unverified
Commit
a49d6773
authored
Feb 26, 2021
by
Jonah Williams
Committed by
GitHub
Feb 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] simplify packages pass-through testing (#76806)
parent
1610a274
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
244 deletions
+39
-244
packages_test.dart
...er_tools/test/commands.shard/permeable/packages_test.dart
+39
-244
No files found.
packages/flutter_tools/test/commands.shard/permeable/packages_test.dart
View file @
a49d6773
...
...
@@ -4,13 +4,16 @@
// @dart = 2.8
import
'dart:async'
;
import
'dart:convert'
;
import
'package:args/command_runner.dart'
;
import
'package:file/memory.dart'
;
import
'package:flutter_tools/src/base/bot_detector.dart'
;
import
'package:flutter_tools/src/base/error_handling_io.dart'
;
import
'package:flutter_tools/src/base/file_system.dart'
hide
IOSink
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/commands/packages.dart'
;
import
'package:flutter_tools/src/dart/pub.dart'
;
...
...
@@ -21,7 +24,6 @@ import 'package:flutter_tools/src/globals.dart' as globals;
import
'../../src/common.dart'
;
import
'../../src/context.dart'
;
import
'../../src/fakes.dart'
;
import
'../../src/mocks.dart'
show
MockProcessManager
;
import
'../../src/testbed.dart'
;
void
main
(
)
{
...
...
@@ -438,23 +440,27 @@ void main() {
});
group
(
'packages test/pub'
,
()
{
MockProcessManager
mockP
rocessManager
;
FakeProcessManager
p
rocessManager
;
FakeStdio
mockStdio
;
setUp
(()
{
mockProcessManager
=
MockProcessManager
(
);
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]
);
mockStdio
=
FakeStdio
()..
stdout
.
terminalColumns
=
80
;
});
testUsingContext
(
'test without bot'
,
()
async
{
Cache
.
flutterRoot
=
''
;
globals
.
fs
.
file
(
'pubspec.yaml'
).
createSync
();
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/bin/cache/dart-sdk/bin/pub'
,
'run'
,
'test'
]),
);
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'test'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
3
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'run'
);
expect
(
commands
[
2
],
'test'
);
expect
(
processManager
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
ProcessManager:
()
=>
processManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
FakeBotDetector
(
false
),
Pub:
()
=>
Pub
(
...
...
@@ -468,136 +474,18 @@ void main() {
});
testUsingContext
(
'test with bot'
,
()
async
{
Cache
.
flutterRoot
=
''
;
globals
.
fs
.
file
(
'pubspec.yaml'
).
createSync
();
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'/bin/cache/dart-sdk/bin/pub'
,
'--trace'
,
'run'
,
'test'
]),
);
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'test'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
4
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'--trace'
);
expect
(
commands
[
2
],
'run'
);
expect
(
commands
[
3
],
'test'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
FakeBotDetector
(
true
),
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
usage:
globals
.
flutterUsage
,
botDetector:
globals
.
botDetector
,
platform:
globals
.
platform
,
),
});
testUsingContext
(
'run'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'--verbose'
,
'pub'
,
'run'
,
'--foo'
,
'bar'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
4
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'run'
);
expect
(
commands
[
2
],
'--foo'
);
expect
(
commands
[
3
],
'bar'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
usage:
globals
.
flutterUsage
,
botDetector:
globals
.
botDetector
,
platform:
globals
.
platform
,
),
});
testUsingContext
(
'pub publish'
,
()
async
{
final
PromptingProcess
process
=
PromptingProcess
();
mockProcessManager
.
processFactory
=
(
List
<
String
>
commands
)
=>
process
;
final
Future
<
void
>
runPackages
=
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'pub'
,
'publish'
]);
final
Future
<
void
>
runPrompt
=
process
.
showPrompt
(
'Proceed (y/n)? '
,
<
String
>[
'hello'
,
'world'
]);
final
Future
<
void
>
simulateUserInput
=
Future
<
void
>(()
{
mockStdio
.
simulateStdin
(
'y'
);
});
await
Future
.
wait
<
void
>(<
Future
<
void
>>[
runPackages
,
runPrompt
,
simulateUserInput
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
2
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'publish'
);
final
List
<
String
>
stdout
=
mockStdio
.
writtenToStdout
;
expect
(
stdout
,
hasLength
(
4
));
expect
(
stdout
.
sublist
(
0
,
2
),
contains
(
'Proceed (y/n)? '
));
expect
(
stdout
.
sublist
(
0
,
2
),
contains
(
'y
\n
'
));
expect
(
stdout
[
2
],
'hello
\n
'
);
expect
(
stdout
[
3
],
'world
\n
'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
usage:
globals
.
flutterUsage
,
botDetector:
globals
.
botDetector
,
platform:
globals
.
platform
,
),
});
testUsingContext
(
'pub publish input fails'
,
()
async
{
final
PromptingProcess
process
=
PromptingProcess
(
stdinError:
true
);
mockProcessManager
.
processFactory
=
(
List
<
String
>
commands
)
=>
process
;
final
Future
<
void
>
runPackages
=
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'pub'
,
'publish'
]);
final
Future
<
void
>
runPrompt
=
process
.
showPrompt
(
'Proceed (y/n)? '
,
<
String
>[
'hello'
,
'world'
]);
final
Future
<
void
>
simulateUserInput
=
Future
<
void
>(()
{
mockStdio
.
simulateStdin
(
'y'
);
});
await
Future
.
wait
<
void
>(<
Future
<
void
>>[
runPackages
,
runPrompt
,
simulateUserInput
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
2
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'publish'
);
// We get a trace message about the write to stdin failing.
expect
(
testLogger
.
traceText
,
contains
(
'Echoing stdin to the pub subprocess failed'
));
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
usage:
globals
.
flutterUsage
,
botDetector:
globals
.
botDetector
,
platform:
globals
.
platform
,
),
});
testUsingContext
(
'publish'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'pub'
,
'publish'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
2
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'publish'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
FakeBotDetector
(
true
),
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
usage:
globals
.
flutterUsage
,
botDetector:
globals
.
botDetector
,
platform:
globals
.
platform
,
),
});
testUsingContext
(
'packages publish'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'pub'
,
'publish'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
2
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'publish'
);
expect
(
processManager
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
ProcessManager:
()
=>
processManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
FakeBotDetector
(
true
),
Pub:
()
=>
Pub
(
...
...
@@ -610,117 +498,24 @@ void main() {
),
});
testUsingContext
(
'deps'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'deps'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
2
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'deps'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
FakeBotDetector
(
true
),
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
usage:
globals
.
flutterUsage
,
botDetector:
globals
.
botDetector
,
platform:
globals
.
platform
,
),
});
testUsingContext
(
'cache'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'cache'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
2
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'cache'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
FakeBotDetector
(
true
),
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
usage:
globals
.
flutterUsage
,
botDetector:
globals
.
botDetector
,
platform:
globals
.
platform
,
),
});
testUsingContext
(
'version'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'version'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
2
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'version'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
FakeBotDetector
(
true
),
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
usage:
globals
.
flutterUsage
,
botDetector:
globals
.
botDetector
,
platform:
globals
.
platform
,
),
});
testUsingContext
(
'uploader'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'uploader'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
2
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'uploader'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
FakeBotDetector
(
true
),
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
usage:
globals
.
flutterUsage
,
botDetector:
globals
.
botDetector
,
platform:
globals
.
platform
,
),
});
testUsingContext
(
'global'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'global'
,
'list'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
3
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'global'
);
expect
(
commands
[
2
],
'list'
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
FakeBotDetector
(
true
),
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
processManager:
globals
.
processManager
,
usage:
globals
.
flutterUsage
,
botDetector:
globals
.
botDetector
,
platform:
globals
.
platform
,
),
});
testUsingContext
(
'run pass arguments through to pub'
,
()
async
{
Cache
.
flutterRoot
=
''
;
globals
.
fs
.
file
(
'pubspec.yaml'
).
createSync
();
final
IOSink
stdin
=
IOSink
(
StreamController
<
List
<
int
>>().
sink
);
processManager
.
addCommand
(
FakeCommand
(
command:
const
<
String
>[
'/bin/cache/dart-sdk/bin/pub'
,
'run'
,
'--foo'
,
'bar'
],
stdin:
stdin
,
),
);
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'--verbose'
,
'pub'
,
'run'
,
'--foo'
,
'bar'
]);
testUsingContext
(
'outdated'
,
()
async
{
await
createTestCommandRunner
(
PackagesCommand
()).
run
(<
String
>[
'packages'
,
'outdated'
]);
final
List
<
String
>
commands
=
mockProcessManager
.
commands
;
expect
(
commands
,
hasLength
(
2
));
expect
(
commands
[
0
],
matches
(
r'dart-sdk[\\/]bin[\\/]pub'
));
expect
(
commands
[
1
],
'outdated'
);
expect
(
processManager
.
hasRemainingExpectations
,
false
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
mockProcessManager
,
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
Platform:
()
=>
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{}),
ProcessManager:
()
=>
processManager
,
Stdio:
()
=>
mockStdio
,
BotDetector:
()
=>
const
FakeBotDetector
(
true
),
Pub:
()
=>
Pub
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
...
...
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