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
020bf31c
Unverified
Commit
020bf31c
authored
Mar 04, 2022
by
Mathieu Dubois-Briand
Committed by
GitHub
Mar 04, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix custom-device default forwardPortSuccessRegex (#97719)
parent
163a7ac1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
547 additions
and
8 deletions
+547
-8
custom_devices.dart
packages/flutter_tools/lib/src/commands/custom_devices.dart
+3
-2
custom_device_config.dart
...er_tools/lib/src/custom_devices/custom_device_config.dart
+3
-2
custom_devices_test.dart
...ols/test/commands.shard/hermetic/custom_devices_test.dart
+541
-4
No files found.
packages/flutter_tools/lib/src/commands/custom_devices.dart
View file @
020bf31c
...
...
@@ -736,11 +736,12 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
'-o'
,
'ExitOnForwardFailure=yes'
,
if
(
ipv6
)
'-6'
,
'-L'
,
'
$formattedLoopbackIp
:
\
${hostPort}
:
$formattedLoopbackIp
:
\
${devicePort}
'
,
sshTarget
sshTarget
,
"echo 'Port forwarding success'; read"
]
:
null
,
forwardPortSuccessRegex:
usePortForwarding
?
RegExp
(
'
Linux
'
)
?
RegExp
(
'
Port forwarding success
'
)
:
null
,
screenshotCommand:
screenshotCommand
.
isNotEmpty
...
...
packages/flutter_tools/lib/src/custom_devices/custom_device_config.dart
View file @
020bf31c
...
...
@@ -264,8 +264,9 @@ class CustomDeviceConfig {
'-o'
,
'ExitOnForwardFailure=yes'
,
'-L'
,
r'127.0.0.1:${hostPort}:127.0.0.1:${devicePort}'
,
'pi@raspberrypi'
,
"echo 'Port forwarding success'; read"
,
],
forwardPortSuccessRegex:
RegExp
(
'
Linux
'
),
forwardPortSuccessRegex:
RegExp
(
'
Port forwarding success
'
),
screenshotCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
...
...
@@ -472,7 +473,7 @@ class CustomDeviceConfig {
_kEnabled:
enabled
,
_kPingCommand:
pingCommand
,
_kPingSuccessRegex:
pingSuccessRegex
?.
pattern
,
_kPostBuildCommand:
postBuildCommand
,
_kPostBuildCommand:
(
postBuildCommand
?.
length
??
0
)
>
0
?
postBuildCommand
:
null
,
_kInstallCommand:
installCommand
,
_kUninstallCommand:
uninstallCommand
,
_kRunDebugCommand:
runDebugCommand
,
...
...
packages/flutter_tools/test/commands.shard/hermetic/custom_devices_test.dart
View file @
020bf31c
...
...
@@ -82,9 +82,10 @@ const String defaultConfigLinux1 = r'''
"ExitOnForwardFailure=yes",
"-L",
"127.0.0.1:
${hostPort}
:127.0.0.1:
${devicePort}
",
"pi@raspberrypi"
"pi@raspberrypi",
"echo '
Port
forwarding
success
'; read"
],
"forwardPortSuccessRegex": "
Linux
",
"forwardPortSuccessRegex": "
Port forwarding success
",
"screenshot": [
"ssh",
"-o",
...
...
@@ -145,9 +146,10 @@ const String defaultConfigLinux2 = r'''
"ExitOnForwardFailure=yes",
"-L",
"127.0.0.1:
${hostPort}
:127.0.0.1:
${devicePort}
",
"pi@raspberrypi"
"pi@raspberrypi",
"echo '
Port
forwarding
success
'; read"
],
"forwardPortSuccessRegex": "
Linux
",
"forwardPortSuccessRegex": "
Port forwarding success
",
"screenshot": [
"ssh",
"-o",
...
...
@@ -503,6 +505,444 @@ void main() {
);
// test add command
testUsingContext
(
'custom-devices add command correctly adds ssh device config on linux'
,
()
async
{
final
MemoryFileSystem
fs
=
MemoryFileSystem
.
test
();
final
CommandRunner
<
void
>
runner
=
createCustomDevicesCommandRunner
(
terminal:
(
Platform
platform
)
=>
createFakeTerminalForAddingSshDevice
(
platform:
platform
,
id:
'testid'
,
label:
'testlabel'
,
sdkNameAndVersion:
'testsdknameandversion'
,
enabled:
'y'
,
hostname:
'testhostname'
,
username:
'testuser'
,
runDebug:
'testrundebug'
,
usePortForwarding:
'y'
,
screenshot:
'testscreenshot'
,
apply:
'y'
),
fileSystem:
fs
,
processManager:
FakeProcessManager
.
any
(),
featureEnabled:
true
);
await
expectLater
(
runner
.
run
(
const
<
String
>[
'custom-devices'
,
'add'
,
'--no-check'
]),
completes
);
final
CustomDevicesConfig
config
=
CustomDevicesConfig
.
test
(
fileSystem:
fs
,
directory:
fs
.
directory
(
'/'
),
logger:
BufferLogger
.
test
()
);
expect
(
config
.
devices
,
contains
(
CustomDeviceConfig
(
id:
'testid'
,
label:
'testlabel'
,
sdkNameAndVersion:
'testsdknameandversion'
,
enabled:
true
,
pingCommand:
const
<
String
>[
'ping'
,
'-c'
,
'1'
,
'-w'
,
'1'
,
'testhostname'
],
postBuildCommand:
null
,
// ignore: avoid_redundant_argument_values
installCommand:
const
<
String
>[
'scp'
,
'-r'
,
'-o'
,
'BatchMode=yes'
,
r'${localPath}'
,
r'testuser@testhostname:/tmp/${appName}'
],
uninstallCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@testhostname'
,
r'rm -rf "/tmp/${appName}"'
],
runDebugCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@testhostname'
,
'testrundebug'
],
forwardPortCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'-o'
,
'ExitOnForwardFailure=yes'
,
'-L'
,
r'127.0.0.1:${hostPort}:127.0.0.1:${devicePort}'
,
'testuser@testhostname'
,
"echo 'Port forwarding success'; read"
],
forwardPortSuccessRegex:
RegExp
(
'Port forwarding success'
),
screenshotCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@testhostname'
,
'testscreenshot'
],
)
)
);
}
);
testUsingContext
(
'custom-devices add command correctly adds ipv4 ssh device config'
,
()
async
{
final
MemoryFileSystem
fs
=
MemoryFileSystem
.
test
();
final
CommandRunner
<
void
>
runner
=
createCustomDevicesCommandRunner
(
terminal:
(
Platform
platform
)
=>
createFakeTerminalForAddingSshDevice
(
platform:
platform
,
id:
'testid'
,
label:
'testlabel'
,
sdkNameAndVersion:
'testsdknameandversion'
,
enabled:
'y'
,
hostname:
'192.168.178.1'
,
username:
'testuser'
,
runDebug:
'testrundebug'
,
usePortForwarding:
'y'
,
screenshot:
'testscreenshot'
,
apply:
'y'
,
),
processManager:
FakeProcessManager
.
any
(),
fileSystem:
fs
,
featureEnabled:
true
);
await
expectLater
(
runner
.
run
(
const
<
String
>[
'custom-devices'
,
'add'
,
'--no-check'
]),
completes
);
final
CustomDevicesConfig
config
=
CustomDevicesConfig
.
test
(
fileSystem:
fs
,
directory:
fs
.
directory
(
'/'
),
logger:
BufferLogger
.
test
()
);
expect
(
config
.
devices
,
contains
(
CustomDeviceConfig
(
id:
'testid'
,
label:
'testlabel'
,
sdkNameAndVersion:
'testsdknameandversion'
,
enabled:
true
,
pingCommand:
const
<
String
>[
'ping'
,
'-c'
,
'1'
,
'-w'
,
'1'
,
'192.168.178.1'
],
postBuildCommand:
null
,
// ignore: avoid_redundant_argument_values
installCommand:
const
<
String
>[
'scp'
,
'-r'
,
'-o'
,
'BatchMode=yes'
,
r'${localPath}'
,
r'testuser@192.168.178.1:/tmp/${appName}'
],
uninstallCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@192.168.178.1'
,
r'rm -rf "/tmp/${appName}"'
],
runDebugCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@192.168.178.1'
,
'testrundebug'
],
forwardPortCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'-o'
,
'ExitOnForwardFailure=yes'
,
'-L'
,
r'127.0.0.1:${hostPort}:127.0.0.1:${devicePort}'
,
'testuser@192.168.178.1'
,
"echo 'Port forwarding success'; read"
],
forwardPortSuccessRegex:
RegExp
(
'Port forwarding success'
),
screenshotCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@192.168.178.1'
,
'testscreenshot'
]
)
)
);
}
);
testUsingContext
(
'custom-devices add command correctly adds ipv6 ssh device config'
,
()
async
{
final
MemoryFileSystem
fs
=
MemoryFileSystem
.
test
();
final
CommandRunner
<
void
>
runner
=
createCustomDevicesCommandRunner
(
terminal:
(
Platform
platform
)
=>
createFakeTerminalForAddingSshDevice
(
platform:
platform
,
id:
'testid'
,
label:
'testlabel'
,
sdkNameAndVersion:
'testsdknameandversion'
,
enabled:
'y'
,
hostname:
'::1'
,
username:
'testuser'
,
runDebug:
'testrundebug'
,
usePortForwarding:
'y'
,
screenshot:
'testscreenshot'
,
apply:
'y'
,
),
fileSystem:
fs
,
featureEnabled:
true
);
await
expectLater
(
runner
.
run
(
const
<
String
>[
'custom-devices'
,
'add'
,
'--no-check'
]),
completes
);
final
CustomDevicesConfig
config
=
CustomDevicesConfig
.
test
(
fileSystem:
fs
,
directory:
fs
.
directory
(
'/'
),
logger:
BufferLogger
.
test
()
);
expect
(
config
.
devices
,
contains
(
CustomDeviceConfig
(
id:
'testid'
,
label:
'testlabel'
,
sdkNameAndVersion:
'testsdknameandversion'
,
enabled:
true
,
pingCommand:
const
<
String
>[
'ping'
,
'-6'
,
'-c'
,
'1'
,
'-w'
,
'1'
,
'::1'
],
postBuildCommand:
null
,
// ignore: avoid_redundant_argument_values
installCommand:
const
<
String
>[
'scp'
,
'-r'
,
'-o'
,
'BatchMode=yes'
,
'-6'
,
r'${localPath}'
,
r'testuser@[::1]:/tmp/${appName}'
],
uninstallCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'-6'
,
'testuser@[::1]'
,
r'rm -rf "/tmp/${appName}"'
],
runDebugCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'-6'
,
'testuser@[::1]'
,
'testrundebug'
],
forwardPortCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'-o'
,
'ExitOnForwardFailure=yes'
,
'-6'
,
'-L'
,
r'[::1]:${hostPort}:[::1]:${devicePort}'
,
'testuser@[::1]'
,
"echo 'Port forwarding success'; read"
],
forwardPortSuccessRegex:
RegExp
(
'Port forwarding success'
),
screenshotCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'-6'
,
'testuser@[::1]'
,
'testscreenshot'
]
)
)
);
}
);
testUsingContext
(
'custom-devices add command correctly adds non-forwarding ssh device config'
,
()
async
{
final
MemoryFileSystem
fs
=
MemoryFileSystem
.
test
();
final
CommandRunner
<
void
>
runner
=
createCustomDevicesCommandRunner
(
terminal:
(
Platform
platform
)
=>
createFakeTerminalForAddingSshDevice
(
platform:
platform
,
id:
'testid'
,
label:
'testlabel'
,
sdkNameAndVersion:
'testsdknameandversion'
,
enabled:
'y'
,
hostname:
'testhostname'
,
username:
'testuser'
,
runDebug:
'testrundebug'
,
usePortForwarding:
'n'
,
screenshot:
'testscreenshot'
,
apply:
'y'
,
),
fileSystem:
fs
,
featureEnabled:
true
);
await
expectLater
(
runner
.
run
(
const
<
String
>[
'custom-devices'
,
'add'
,
'--no-check'
]),
completes
);
final
CustomDevicesConfig
config
=
CustomDevicesConfig
.
test
(
fileSystem:
fs
,
directory:
fs
.
directory
(
'/'
),
logger:
BufferLogger
.
test
()
);
expect
(
config
.
devices
,
contains
(
const
CustomDeviceConfig
(
id:
'testid'
,
label:
'testlabel'
,
sdkNameAndVersion:
'testsdknameandversion'
,
enabled:
true
,
pingCommand:
<
String
>[
'ping'
,
'-c'
,
'1'
,
'-w'
,
'1'
,
'testhostname'
],
postBuildCommand:
null
,
// ignore: avoid_redundant_argument_values
installCommand:
<
String
>[
'scp'
,
'-r'
,
'-o'
,
'BatchMode=yes'
,
r'${localPath}'
,
r'testuser@testhostname:/tmp/${appName}'
],
uninstallCommand:
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@testhostname'
,
r'rm -rf "/tmp/${appName}"'
],
runDebugCommand:
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@testhostname'
,
'testrundebug'
],
screenshotCommand:
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@testhostname'
,
'testscreenshot'
]
)
)
);
}
);
testUsingContext
(
'custom-devices add command correctly adds non-screenshotting ssh device config'
,
()
async
{
final
MemoryFileSystem
fs
=
MemoryFileSystem
.
test
();
final
CommandRunner
<
void
>
runner
=
createCustomDevicesCommandRunner
(
terminal:
(
Platform
platform
)
=>
createFakeTerminalForAddingSshDevice
(
platform:
platform
,
id:
'testid'
,
label:
'testlabel'
,
sdkNameAndVersion:
'testsdknameandversion'
,
enabled:
'y'
,
hostname:
'testhostname'
,
username:
'testuser'
,
runDebug:
'testrundebug'
,
usePortForwarding:
'y'
,
screenshot:
''
,
apply:
'y'
,
),
fileSystem:
fs
,
featureEnabled:
true
);
await
expectLater
(
runner
.
run
(
const
<
String
>[
'custom-devices'
,
'add'
,
'--no-check'
]),
completes
);
final
CustomDevicesConfig
config
=
CustomDevicesConfig
.
test
(
fileSystem:
fs
,
directory:
fs
.
directory
(
'/'
),
logger:
BufferLogger
.
test
()
);
expect
(
config
.
devices
,
contains
(
CustomDeviceConfig
(
id:
'testid'
,
label:
'testlabel'
,
sdkNameAndVersion:
'testsdknameandversion'
,
enabled:
true
,
pingCommand:
const
<
String
>[
'ping'
,
'-c'
,
'1'
,
'-w'
,
'1'
,
'testhostname'
],
postBuildCommand:
null
,
// ignore: avoid_redundant_argument_values
installCommand:
const
<
String
>[
'scp'
,
'-r'
,
'-o'
,
'BatchMode=yes'
,
r'${localPath}'
,
r'testuser@testhostname:/tmp/${appName}'
],
uninstallCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@testhostname'
,
r'rm -rf "/tmp/${appName}"'
],
runDebugCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@testhostname'
,
'testrundebug'
],
forwardPortCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'-o'
,
'ExitOnForwardFailure=yes'
,
'-L'
,
r'127.0.0.1:${hostPort}:127.0.0.1:${devicePort}'
,
'testuser@testhostname'
,
"echo 'Port forwarding success'; read"
],
forwardPortSuccessRegex:
RegExp
(
'Port forwarding success'
),
)
)
);
}
);
testUsingContext
(
'custom-devices delete command deletes device and creates backup'
,
()
async
{
...
...
@@ -737,4 +1177,101 @@ void main() {
}
);
});
group
(
'windows'
,
()
{
setUp
(()
{
Cache
.
flutterRoot
=
windowsFlutterRoot
;
});
testUsingContext
(
'custom-devices add command correctly adds ssh device config on windows'
,
()
async
{
final
MemoryFileSystem
fs
=
MemoryFileSystem
.
test
(
style:
FileSystemStyle
.
windows
);
final
CommandRunner
<
void
>
runner
=
createCustomDevicesCommandRunner
(
terminal:
(
Platform
platform
)
=>
createFakeTerminalForAddingSshDevice
(
platform:
platform
,
id:
'testid'
,
label:
'testlabel'
,
sdkNameAndVersion:
'testsdknameandversion'
,
enabled:
'y'
,
hostname:
'testhostname'
,
username:
'testuser'
,
runDebug:
'testrundebug'
,
usePortForwarding:
'y'
,
screenshot:
'testscreenshot'
,
apply:
'y'
,
),
fileSystem:
fs
,
platform:
windowsPlatform
,
featureEnabled:
true
);
await
expectLater
(
runner
.
run
(
const
<
String
>[
'custom-devices'
,
'add'
,
'--no-check'
]),
completes
);
final
CustomDevicesConfig
config
=
CustomDevicesConfig
.
test
(
fileSystem:
fs
,
directory:
fs
.
directory
(
'/'
),
logger:
BufferLogger
.
test
()
);
expect
(
config
.
devices
,
contains
(
CustomDeviceConfig
(
id:
'testid'
,
label:
'testlabel'
,
sdkNameAndVersion:
'testsdknameandversion'
,
enabled:
true
,
pingCommand:
const
<
String
>[
'ping'
,
'-n'
,
'1'
,
'-w'
,
'500'
,
'testhostname'
],
pingSuccessRegex:
RegExp
(
r'[<=]\d+ms'
),
postBuildCommand:
null
,
// ignore: avoid_redundant_argument_values
installCommand:
const
<
String
>[
'scp'
,
'-r'
,
'-o'
,
'BatchMode=yes'
,
r'${localPath}'
,
r'testuser@testhostname:/tmp/${appName}'
],
uninstallCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@testhostname'
,
r'rm -rf "/tmp/${appName}"'
],
runDebugCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@testhostname'
,
'testrundebug'
],
forwardPortCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'-o'
,
'ExitOnForwardFailure=yes'
,
'-L'
,
r'127.0.0.1:${hostPort}:127.0.0.1:${devicePort}'
,
'testuser@testhostname'
,
"echo 'Port forwarding success'; read"
],
forwardPortSuccessRegex:
RegExp
(
'Port forwarding success'
),
screenshotCommand:
const
<
String
>[
'ssh'
,
'-o'
,
'BatchMode=yes'
,
'testuser@testhostname'
,
'testscreenshot'
]
)
)
);
},
);
});
}
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