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

Remove the Ruby Gherkin parser. Rely on Go binary/protobuf #427

Merged
merged 11 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gherkin/ruby/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ acceptance/
.built
.compared
pkg/
gherkin-go/
4 changes: 0 additions & 4 deletions gherkin/ruby/.rsync
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@
../../.templates/github/ .github/
../../.templates/ruby/.travis.yml .travis.yml
../testdata/ testdata/
../download-gherkin-go scripts/download-gherkin-go
Copy link
Contributor

Choose a reason for hiding this comment

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

Put this back in, so it gets updated if we make changes to ../download-gherkin-go

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't look done, so I added this back on master.

Copy link
Member Author

Choose a reason for hiding this comment

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

@aslakhellesoy Yeah, I had done it locally but hadn't pushed yet. Held off in favor of letting @enkessler have at it if he wanted, but for some reason my comment indicating that didn't make it? Womp. Thanks though!

../gherkin.berp gherkin.berp
../bin/ berp/
../gherkin-languages.json lib/gherkin/gherkin-languages.json
27 changes: 12 additions & 15 deletions gherkin/ruby/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export CUCUMBER_MESSAGES
GOOD_FEATURE_FILES = $(shell find testdata/good -name "*.feature")
BAD_FEATURE_FILES = $(shell find testdata/bad -name "*.feature")

TOKENS = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.tokens,$(GOOD_FEATURE_FILES))
ASTS = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.ast.ndjson,$(GOOD_FEATURE_FILES))
PICKLES = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.pickles.ndjson,$(GOOD_FEATURE_FILES))
SOURCES = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.source.ndjson,$(GOOD_FEATURE_FILES))
Expand All @@ -13,24 +12,25 @@ ERRORS = $(patsubst testdata/%.feature,acceptance/testdata/%.feature.error

RUBY_FILES = $(shell find . -name "*.rb")

ifdef TRAVIS_TAG
GHERKIN_VERSION=$(TRAVIS_TAG)
else
GHERKIN_VERSION=master
endif

.DELETE_ON_ERROR:

default: .compared
bundle exec rake install
.PHONY: default

.compared: .built $(ERRORS) $(SOURCES) $(PICKLES) $(PROTOBUFS) $(TOKENS) $(ASTS)
.compared: .built $(ERRORS) $(SOURCES) $(PICKLES) $(PROTOBUFS) $(ASTS)
touch $@

.built: lib/gherkin/parser.rb lib/gherkin/gherkin-languages.json $(RUBY_FILES) bin/gherkin Gemfile.lock
.built: $(RUBY_FILES) bin/gherkin Gemfile.lock gherkin-go
bundle exec rspec --color
touch $@

acceptance/testdata/%.feature.tokens: testdata/%.feature testdata/%.feature.tokens .built
mkdir -p `dirname $@`
bundle exec bin/gherkin-generate-tokens $< > $@
diff --unified $<.tokens $@

acceptance/testdata/%.feature.ast.ndjson: testdata/%.feature testdata/%.feature.ast.ndjson .built
mkdir -p `dirname $@`
bundle exec bin/gherkin --no-source --no-pickles $< | jq --sort-keys --compact-output "." > $@
Expand Down Expand Up @@ -61,15 +61,12 @@ clean:
.PHONY: clean

clobber: clean
rm -rf lib/gherkin/parser.rb Gemfile.lock
rm -rf Gemfile.lock
.PHONY: clobber

lib/gherkin/parser.rb: gherkin.berp gherkin-ruby.razor berp/berp.exe
-mono berp/berp.exe -g gherkin.berp -t gherkin-ruby.razor -o $@
# Remove BOM
awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}{print}' < $@ > $@.nobom
mv $@.nobom $@

Gemfile.lock: Gemfile
bundle install
touch $@

gherkin-go:
./scripts/download-gherkin-go $(GHERKIN_VERSION)
5 changes: 1 addition & 4 deletions gherkin/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

Gherkin parser/compiler for Ruby. Please see [Gherkin](https://github.com/cucumber/gherkin) for details.

## Developers

Some files are generated from the `gherkin-ruby.razor` file. Please run the
following command to generate the ruby files.
## To build

~~~bash
cd <project_root>/ruby
Expand Down
Binary file removed gherkin/ruby/berp/CommandLine.dll
Binary file not shown.
Binary file removed gherkin/ruby/berp/RazorEngine.dll
Binary file not shown.
Binary file removed gherkin/ruby/berp/RazorEngine.pdb
Binary file not shown.
Binary file removed gherkin/ruby/berp/System.Web.Razor.dll
Binary file not shown.
Binary file removed gherkin/ruby/berp/berp.exe
Binary file not shown.
Binary file removed gherkin/ruby/berp/berp.pdb
Binary file not shown.
27 changes: 6 additions & 21 deletions gherkin/ruby/bin/gherkin
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__),"../lib"))

require 'optparse'
require 'json'
require 'gherkin/exe_file.rb'
require 'gherkin/messages/subprocess_cucumber_messages'
require 'gherkin/messages/protobuf_cucumber_messages'
require 'gherkin/messages/parser_cucumber_messages'

options = {
print_source: true,
Expand Down Expand Up @@ -56,29 +56,14 @@ def remove_empties(ob)
end
end

# gherkin_executable = '../javascript/bin/gherkin'
gherkin_executable = ENV['GHERKIN_EXECUTABLE']
if ARGV.empty?
messages = ARGV.empty? ?
# Read protobuf from STDIN
messages = Gherkin::Messages::ProtobufCucumberMessages.new(STDIN).messages
print_messages(messages)
elsif gherkin_executable
# Read protobuf from STDIN
STDERR.puts options
messages = Gherkin::Messages::SubprocessCucumberMessages.new(
gherkin_executable,
ARGV,
options[:print_source],
options[:print_ast],
options[:print_pickles]
).messages
print_messages(messages)
else
messages = Gherkin::Messages::ParserCucumberMessages.new(
Gherkin::Messages::ProtobufCucumberMessages.new(STDIN).messages
:
Gherkin::Messages::SubprocessCucumberMessages.new(
ARGV,
options[:print_source],
options[:print_ast],
options[:print_pickles]
).messages
print_messages(messages)
end
print_messages(messages)
13 changes: 0 additions & 13 deletions gherkin/ruby/bin/gherkin-generate-tokens

This file was deleted.

218 changes: 0 additions & 218 deletions gherkin/ruby/gherkin-ruby.razor

This file was deleted.

Loading