Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thinkhy
Copy link
Member

@thinkhy thinkhy commented Jul 16, 2017

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.

@@ -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) {
Copy link
Member

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.

Copy link
Member Author

@thinkhy thinkhy Jul 18, 2017

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.

Copy link
Member

@sorccu sorccu Jul 18, 2017

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).

Copy link
Member Author

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.

@sorccu
Copy link
Member

sorccu commented Jul 18, 2017

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.

@thinkhy
Copy link
Member Author

thinkhy commented Jul 19, 2017

Thanks. I would be very happy to join the Slack and become a formal contributor.

@sorccu
Copy link
Member

sorccu commented Jul 19, 2017

Great! Can you email me at simo @ the name of this github org .io?

@thinkhy
Copy link
Member Author

thinkhy commented Jul 20, 2017

Email sent. Thanks.

@nicodn
Copy link

nicodn commented Sep 5, 2019

Is this feature implemented? How can we filter emulators out? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants