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

cli: extract option splitting and use it for --compiler (#746) #958

Merged
merged 1 commit into from
Nov 5, 2017
Merged

cli: extract option splitting and use it for --compiler (#746) #958

merged 1 commit into from
Nov 5, 2017

Conversation

darrinholst
Copy link
Contributor

Thought I'd take a crack at #746 while I was dealing with : splitting for the formatters. The compiler isn't as easy to unit test as the formatters was since the result of the split is used internally to the config builder plus it actually requires the module so you can't just send anything you want to it...like a windows absolute path. So I added an OptionSplitter utility that both the --format and --compiler can use. There are no new tests for --compiler because of the reason above, but the existing feature should ensure there are no regressions.

The splitting itself almost turned out to be simple with negative look aheads and look behinds until I found out that js regex doesn't support look behinds. That's why there's still a little bit of logic to smash those back together.

Copy link
Member

@charlierudolph charlierudolph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I'd like to clean up the test duplication a bit but otherwise this is good to merge.


function split(option) {
return OptionSplitter.split(option)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on converting this to something like

// The following is within the describe block for OptionSplitter

const examples = [
  { 
    description: "doesn't split when nothing to split on",
    input: '../custom/formatter',
    output: ['../custom/formatter']  
  }
  //...
]

examples.forEach(({description, input, output}) => {
  it(description, function() {
    expect(OptionSplitter.split(input)).to.eql(output)
  })
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and changed it. I'm kind of indifferent either way. The individual it blocks were already pretty terse, but this way does remove what boilerplate there was and gets to the point of what you're testing.

@charlierudolph charlierudolph merged commit 8b5fcdd into cucumber:master Nov 5, 2017
@lock
Copy link

lock bot commented Nov 5, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants