-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add new option '-exclude' in provider to exclude device with regexp pattern #647
base: master
Are you sure you want to change the base?
Conversation
@@ -154,6 +159,9 @@ module.exports.handler = function(argv) { | |||
, filter: function(device) { | |||
return argv.serial.length === 0 || argv.serial.indexOf(device.id) !== -1 | |||
} | |||
, exclude: function(device) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see this combined with the filter function. So instead of only doing the current check, it would check what it already does, and then this one. Then we can remove the exclusion code in lib/units/provider/index.js
and just rely on the existing filter to do its job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read the code related to provider filter, the semantic of filter is that the provider can only join the device whose serial name is contained in the argument of argv.serial, while the -exclude argument is added to exclude the devices match the Regexp.
So, for explicit semantic and back-level compatibility, I suggest to add a new option '-exclude' like what we see in the manual of 'grep':
man grep:
--include
If specified, only files matching the given filename pattern are searched. Note that
--exclude patterns take priority over --include patterns. Patterns are matched to the
full path specified, not only to the filename component.
--exclude
If specified, it excludes files matching the given filename pattern from the search.
Note that --exclude patterns take priority over --include patterns, and if no --include
pattern is specified, all files are searched that are not excluded. Patterns are
matched to the full path specified, not only to the filename component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I have no problem with adding the new option, however I would like the filter
function to handle both cases.
Also I'm not 100% sure if I like that it's a pattern by default - consider, for example, a case where you have two devices with serials 012345678 and 01234567. Now the user tries to exclude only 01234567, but since it's a regex by default, both devices are excluded. Maybe I would like having both --exclude
and --exclude-pattern
(and possibly --include
and --include-pattern
as well).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, we can handle both inclusion and exclusion in filter function.
For second problem. I just did an experiment and found a workaround. I have a device with serial name KNSCMJJFZ9RCNFHE, the device can be excluded with pattern "^KNSCMJJFZ9RCNFHE$", but not with the pattern "^KNSCMJJFZ9RCNFHEX$" , so I think the options of "exclude/include-pattern" might be redundant thought they are more explicit to users who may not know Regexp.
Btw would you like to join our Slack at https://openstf.slack.com? We could certainly use some help if you'd be interested in joining the team as a contributor. |
Thanks. I would be very happy to join the Slack and become a |
Great! Can you email me at simo @ the name of this github org .io? |
Email sent. Thanks. |
Is this feature implemented? How can we filter emulators out? Thanks! |
When I connected mobile devices into STF from Windows system, some emulator devices were joined unintentionally, so I added a new option "-exclude regex" in provider to exclude devices whose serials match the specified regex pattern like "^emulator.*".
Another benefit for the feature is that we can prevent multiple local devices from joining STF provider.