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

Discussion for the Focus/Tags feature #81

Closed
angelsanzn opened this issue May 16, 2016 · 4 comments
Closed

Discussion for the Focus/Tags feature #81

angelsanzn opened this issue May 16, 2016 · 4 comments

Comments

@angelsanzn
Copy link
Contributor

angelsanzn commented May 16, 2016

Hi, I'd like to bring up the topic of these two features to attempt an
implementation. I believe there are a few points to discuss:

syntax alternatives

First of all, notice that whenever new identifiers are used, we run the risk of
driving linters crazy (that is already the case with describe, description,
context, it, the 'pending' variants, before, after and self).

dedicated identifiers

fdescribe, fdescription, fcontext, fit à la
Jasmine, or similar.

tags

Here, the inspiration is clearly [rspec](https://relishapp.com/rspec/rspec-
core/v/3-4/docs/metadata/user-defined-metadata). I would not yet go as far as to
create a whole mechanism for user-defined metadata, just one for tags or even
just for the 'focus' feature.

Some ideas:

tags as additional arguments

as strings

with description('spec description', 'a_tag', 'another_tag'):
    pass

as identifiers

with description('spec description', a_tag, another_tag):
    pass

tags as additional context managers

as strings

with description('spec description'), 'a_tag', 'another_tag':
    pass

as identifiers

with description('spec description'), a_tag, another_tag:
    pass

tags as context manager aliases

with description('spec description') as a_tag, another_tag:
    pass

weird (but still valid) syntax mixture

with description('spec description') is a_tag, another_tag:
    pass
with description('spec description') in a_tag, another_tag:
    pass

tags in the previous line

It's probably harder to retrieve these from the AST.

as strings

'a_tag', 'another_tag'
with description('spec description'):
    pass

as identifiers

a_tag, another_tag
with description('spec description'):
    pass

tags in the next line

as strings

with description('spec description'):
    'a_tag', 'another_tag'
    pass

as identifiers

with description('spec description'):
    a_tag, another_tag
    pass

tags as comments

In this case, we would need to move away from an AST towards something like a
concrete syntax tree such as redbaron and
similar
or the tokenize module.

with description('spec description'): #a_tag #another_tag
    pass

I'm sure there are quite a few more candidates. Having tags in the same line is
clumsier to type but more readable; having them in the previous or next line is
more comfortable to type but less intuitive, I think.

behaviour

  • Should we implement just 'focus' or a full 'tags' mechanism?
  • Relationship between focus and skip: which one takes precedence over which?
  • Tags-related:
    • Can tags apply to groups or only to examples?
    • Is the 'focus' tag automatically recognised or would it only run when specifying it as a CLI argument?

foreseeable problems

  • How to keep track of the tags of each example? We need to store them starting
    from the point where the AST is transformed.
  • If implementing the full 'tags' feature, we should probably use it for the
    existing 'skip' behaviour.
  • Currently, mamba runs the test tree depth-first, as it builds it. This
    would need to be changed: the whole tree needs to be built before we can
    decide which examples should run.

ping: @deusz @eferro because their work in #78 suggests they're interested in this, @fatuhoku because he originally wrote #20

@gardenunez
Copy link

@Angelsanz @nestorsalceda I would use 'only' instead of 'focus'. Think is more readable.

@nestorsalceda
Copy link
Owner

Thanks for your valuable work @Angelsanz!

This issue was really useful to me for taking some decisions about tagging feature.

@gardenunez by now, for being consistent with _it, I have decided to use fit. But I think that only would be a nice addition, because we are using that convention on before.* and after.* hooks.

Thanks another time!

@gardenunez
Copy link

Your welcome, happy to contribute!! 👍

@angelsanzn
Copy link
Contributor Author

You're welcome @nestorsalceda, glad to help!

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

No branches or pull requests

3 participants