Skip to content

[Core] Use Gherkin 6+ and Cucumber messages #1841

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

Merged
merged 132 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
d5b2135
WIP Prepwork Gherkin 8
mpkorstanje Oct 14, 2019
dc80b0d
Extract gherkin 5 module
mpkorstanje Oct 15, 2019
78d917e
Add Gherkin8
mpkorstanje Oct 15, 2019
b5ce5f0
Use in example
mpkorstanje Oct 15, 2019
6f13177
Remove internal use of Gherkin 5
mpkorstanje Oct 15, 2019
231fa78
Use gherkin8 for code generation
aslakhellesoy Oct 16, 2019
302b369
Fix the build
aslakhellesoy Oct 16, 2019
c0fcf80
Add protobuf formatter
aslakhellesoy Oct 17, 2019
9192033
Update Gherkin. Add duration. json-formatter go exe can now process t…
aslakhellesoy Oct 18, 2019
ab6d9f9
Merge with master
aslakhellesoy Oct 28, 2019
c7169dc
Upgrade to latest Gherkin. Add CucumberQuery.
aslakhellesoy Nov 21, 2019
db8821b
Emit TestCase event
aslakhellesoy Nov 21, 2019
9f8bfab
Merge branch 'master' into prep-work-gherkin-8
mpkorstanje Nov 21, 2019
5f88808
Clean up imports
mpkorstanje Nov 21, 2019
d4ba12d
Add rule node
mpkorstanje Nov 21, 2019
5452fe7
Make implementation package private
mpkorstanje Nov 21, 2019
ac61dd4
Add abstract tree implementation
mpkorstanje Nov 21, 2019
ced9a44
Support rules in JUnit 5
mpkorstanje Nov 21, 2019
795aa71
Touch ups
mpkorstanje Nov 21, 2019
a9c0651
Improve diagnostics.
mpkorstanje Nov 21, 2019
22d8ad9
More lenient typing
mpkorstanje Nov 21, 2019
d9ae62e
Properly look up locations of examples rows
aslakhellesoy Nov 22, 2019
8f0e2e9
Gherkin 5/8 hybrid
mpkorstanje Nov 23, 2019
636c548
Make TestNG Formatter Gherkin8 compatible
mpkorstanje Nov 24, 2019
eab22dc
Make timeline formatter Gherkin8 compatible
mpkorstanje Nov 24, 2019
34f5f88
Make JUnitFormatter Gherkin8 compatible
mpkorstanje Nov 24, 2019
f82d1a1
Merge remote-tracking branch 'origin/master' into prep-work-gherkin-8
mpkorstanje Nov 27, 2019
483fe5a
Merge branch 'master' into prep-work-gherkin-8
mpkorstanje Nov 28, 2019
5d41fe9
[Core] Only print pickles in pretty formatter
mpkorstanje Nov 28, 2019
5088418
Clean up unused methods
mpkorstanje Nov 28, 2019
92d922d
Deprecate HTML and JSON Formatters
mpkorstanje Nov 28, 2019
2db8929
Upgrade gherkin
aslakhellesoy Nov 22, 2019
8ad2dcd
Output messages that can be consumed by cucumber-html-formatter
aslakhellesoy Nov 28, 2019
89e15b2
WIP - emit messages from core
aslakhellesoy Nov 28, 2019
bce6ff2
Dont now swallow exceptions
mpkorstanje Nov 28, 2019
7578bfd
Fixup
mpkorstanje Nov 28, 2019
f682060
Update CucumberQuery
aslakhellesoy Nov 28, 2019
28327e8
Add maven profile to exclude gherkin5 in idea
mpkorstanje Nov 28, 2019
972e816
Send messages on the bus
aslakhellesoy Nov 29, 2019
aec3aef
Emit messages from core
aslakhellesoy Nov 29, 2019
c23ab14
Merge remote-tracking branch 'origin/master' into prep-work-gherkin-8
aslakhellesoy Nov 29, 2019
f58b419
Set the group start
aslakhellesoy Nov 29, 2019
f415996
Merge remote-tracking branch 'origin/master' into prep-work-gherkin-8
aslakhellesoy Dec 2, 2019
2969f93
Clean up one
mpkorstanje Dec 5, 2019
949544a
Use event bus to generate ids
mpkorstanje Dec 5, 2019
e7d0b2d
Move protobuf formatter into core and rename
mpkorstanje Dec 5, 2019
bbc8f1f
Move util class closer to usage
mpkorstanje Dec 5, 2019
fca400a
Pass through plugin system for cucumber-expression groups
mpkorstanje Dec 5, 2019
70ea234
Clean up done todos
mpkorstanje Dec 5, 2019
b85828e
Extract IdGeneration
mpkorstanje Dec 5, 2019
8a6edee
Merge branch 'master' into prep-work-gherkin-8
mpkorstanje Dec 5, 2019
80b91f6
WIP Test gherkin 8 and message plugin
mpkorstanje Dec 5, 2019
16760ac
Test Gherkin8 and message plugin
mpkorstanje Dec 6, 2019
dc5f4a5
Html and Json formatters aren't deprecated yet
mpkorstanje Dec 6, 2019
af37328
Remove dead code
mpkorstanje Dec 6, 2019
37c6bd8
Clean up
mpkorstanje Dec 6, 2019
92913ef
Clean up
mpkorstanje Dec 6, 2019
25be110
Remove redundant `Cucumber` prefix from gherkin wrappers
mpkorstanje Dec 6, 2019
f5828e7
Clean up
mpkorstanje Dec 6, 2019
b189db5
Merge branch 'prep-work-gherkin-8' of github.com:cucumber/cucumber-jv…
aslakhellesoy Dec 10, 2019
100cc9e
Merge with master. Use latest cucumber-messages/gherkin releases
aslakhellesoy Dec 10, 2019
a5753b9
Rename modules to free ourselves from evolving versions
aslakhellesoy Dec 11, 2019
b66452c
Simplify revapi check
aslakhellesoy Dec 11, 2019
d2ad310
Be more explicit about revapi.ignore items
aslakhellesoy Dec 11, 2019
7a46fdb
Rename package
aslakhellesoy Dec 12, 2019
8c6a9f0
POC TCK
mpkorstanje Dec 12, 2019
fb94745
Split gherkinglegacy and gherkingmessages into better package names
mpkorstanje Dec 12, 2019
6d9fda3
Rename legacy to vintage
mpkorstanje Dec 12, 2019
bf5ed43
Remove unused UUID
mpkorstanje Dec 12, 2019
03bbb64
Remove unused constructor arg
mpkorstanje Dec 12, 2019
11fce15
[Core] Extract Gherkin compatibility layer
mpkorstanje Dec 12, 2019
2a0a6d2
Merge branch 'prep-work-gherkin-8' into gherkin8
mpkorstanje Dec 12, 2019
cb4964e
Merge remote-tracking branch 'origin/master' into gherkin8
mpkorstanje Dec 13, 2019
04e5910
File order iteration is not guaranteed
mpkorstanje Dec 13, 2019
5e3752c
Remove messages dependency from gherkin
mpkorstanje Dec 18, 2019
66e5fdc
Merge remote-tracking branch 'origin/master' into gherkin8
mpkorstanje Dec 19, 2019
224a237
Merge remote-tracking branch 'origin/master' into gherkin8
mpkorstanje Dec 19, 2019
16ca5e9
Use parameterized tests for cck tests
mpkorstanje Dec 19, 2019
160825f
Merge branch 'master' into gherkin8
mpkorstanje Dec 19, 2019
92f16c5
Reduce the differences between actual and expected
mpkorstanje Dec 20, 2019
e426f62
Merge branch 'master' into gherkin8
mpkorstanje Dec 20, 2019
7227a11
Add step ids
mpkorstanje Dec 20, 2019
9f213b3
more stuff
mpkorstanje Dec 20, 2019
9de6cdf
Merge with master
aslakhellesoy Jan 10, 2020
67d5413
Update cck files
aslakhellesoy Jan 10, 2020
40efa06
Merge remote-tracking branch 'origin/master' into gherkin8
mpkorstanje Jan 11, 2020
1838742
Update CHANGELOG
mpkorstanje Jan 12, 2020
878c3e2
Merge remote-tracking branch 'origin/master' into gherkin8
mpkorstanje Jan 15, 2020
a206102
Merge remote-tracking branch 'origin/master' into gherkin8
mpkorstanje Jan 16, 2020
fa4a307
Fix version
mpkorstanje Jan 16, 2020
ffaa983
[Build] Add release goals to make file
mpkorstanje Jan 16, 2020
febff98
Merge remote-tracking branch 'origin/master' into gherkin8
mpkorstanje Jan 17, 2020
2133e91
Add latest cck examples
mpkorstanje Jan 17, 2020
c8a8791
Sort events and remove some known differences.
mpkorstanje Jan 17, 2020
bb486cb
Write output to target
aslakhellesoy Jan 17, 2020
5475edc
Add step definition ids
mpkorstanje Jan 17, 2020
3b8fa74
Add parameter types case
mpkorstanje Jan 17, 2020
39dc17d
Merge remote-tracking branch 'origin/master' into gherkin8
mpkorstanje Feb 8, 2020
dd19e88
Merge remote-tracking branch 'origin/master' into gherkin8
mpkorstanje Feb 14, 2020
c04261b
Bump version
mpkorstanje Feb 14, 2020
7c66df6
Bump messages version
mpkorstanje Feb 14, 2020
ffbd25f
Update CCK and use directory structure to generate test cases
mpkorstanje Feb 14, 2020
dc7b631
Clean up
mpkorstanje Feb 14, 2020
7d0455c
Clean up
mpkorstanje Feb 14, 2020
affafba
Clean up
mpkorstanje Feb 14, 2020
f1eb78a
Sort
mpkorstanje Feb 14, 2020
9beab8e
Fixed attachment
mpkorstanje Feb 14, 2020
b594555
Add glue for new scenarios
mpkorstanje Feb 14, 2020
40b0b22
Clean up
mpkorstanje Feb 14, 2020
bb57f3b
Fix a few more diffs
mpkorstanje Feb 15, 2020
a96638b
Merge remote-tracking branch 'origin/master' into gherkin8
mpkorstanje Feb 20, 2020
3c0c438
Bump version
mpkorstanje Feb 20, 2020
12aa1f4
Only support ndjson
mpkorstanje Feb 20, 2020
80ae1de
Merge remote-tracking branch 'origin/master' into gherkin8
aslakhellesoy Feb 27, 2020
881ba4b
Update dependencies. Emit hook messages.
aslakhellesoy Feb 27, 2020
57f3861
Disable Compatibility kit assertions - need to find a better strategy
aslakhellesoy Feb 28, 2020
14912f7
Merge remote-tracking branch 'origin/master' into gherkin8
aslakhellesoy Feb 28, 2020
7786065
Update compatibility version
aslakhellesoy Feb 28, 2020
174007a
Merge remote-tracking branch 'origin/master' into gherkin8
aslakhellesoy Mar 4, 2020
c50393c
Allow messages to be written to a URL as well as a file
aslakhellesoy Mar 4, 2020
7529736
Merge remote-tracking branch 'origin/master' into gherkin8
mpkorstanje Mar 6, 2020
63c9aac
Bump version
mpkorstanje Mar 6, 2020
db2ec11
[Core] Add Html message formatter (#1918)
aslakhellesoy Mar 12, 2020
e558857
Merge remote-tracking branch 'origin/master' into gherkin8
mpkorstanje Mar 12, 2020
796d3ff
Merge branch 'v6.x.x' into gherkin8
mpkorstanje Mar 14, 2020
5f64507
Fix dependency convergence
mpkorstanje Mar 14, 2020
22e73a3
Remove compatibility kit
mpkorstanje Mar 14, 2020
790e761
Clean up more cck stuff
mpkorstanje Mar 14, 2020
ed39a96
Remove unfished work
mpkorstanje Mar 14, 2020
240dc5b
Clean up message formatter
mpkorstanje Mar 14, 2020
510a0cb
Rename HTMLFormatter to HtmlFormatter
mpkorstanje Mar 14, 2020
4cc49f0
Use gherkin-messages by default
mpkorstanje Mar 14, 2020
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
15 changes: 6 additions & 9 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,11 @@
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-gherkin-vintage</artifactId>
</dependency>

<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>${gherkin-vintage.version}</version>
<artifactId>cucumber-gherkin-messages</artifactId>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin-jvm-deps</artifactId>
<version>${gherkin-vintage-jvm-deps.version}</version>
<artifactId>messages</artifactId>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
Expand All @@ -61,6 +54,10 @@
<groupId>io.cucumber</groupId>
<artifactId>docstring</artifactId>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>html-formatter</artifactId>
</dependency>
<dependency>
<groupId>org.apiguardian</groupId>
<artifactId>apiguardian-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package io.cucumber.core.eventbus;

import io.cucumber.plugin.event.Event;

public abstract class AbstractEventBus extends AbstractEventPublisher implements EventBus {

@Override
public void send(Event event) {
public <T> void send(T event) {
super.send(event);
}

@Override
public void sendAll(Iterable<Event> queue) {
public <T> void sendAll(Iterable<T> queue) {
super.sendAll(queue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import java.util.Map;

public abstract class AbstractEventPublisher implements EventPublisher {
protected final Map<Class<? extends Event>, List<EventHandler>> handlers = new HashMap<>();
protected final Map<Class<?>, List<EventHandler>> handlers = new HashMap<>();

@Override
public final <T extends Event> void registerHandlerFor(Class<T> eventType, EventHandler<T> handler) {
public final <T> void registerHandlerFor(Class<T> eventType, EventHandler<T> handler) {
if (handlers.containsKey(eventType)) {
handlers.get(eventType).add(handler);
} else {
Expand All @@ -24,15 +24,15 @@ public final <T extends Event> void registerHandlerFor(Class<T> eventType, Event
}

@Override
public final <T extends Event> void removeHandlerFor(Class<T> eventType, EventHandler<T> handler) {
public final <T> void removeHandlerFor(Class<T> eventType, EventHandler<T> handler) {
if (handlers.containsKey(eventType)) {
handlers.get(eventType).remove(handler);
}
}


protected void send(Event event) {
if (handlers.containsKey(Event.class)) {
protected <T> void send(T event) {
if (handlers.containsKey(Event.class) && event instanceof Event) {
for (EventHandler handler : handlers.get(Event.class)) {
//noinspection unchecked: protected by registerHandlerFor
handler.receive(event);
Expand All @@ -47,8 +47,8 @@ protected void send(Event event) {
}
}

protected void sendAll(Iterable<Event> events) {
for (Event event : events) {
protected <T> void sendAll(Iterable<T> events) {
for (T event : events) {
send(event);
}
}
Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/io/cucumber/core/eventbus/EventBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.time.Instant;
import java.util.UUID;

import io.cucumber.plugin.event.Event;
import io.cucumber.plugin.event.EventPublisher;

public interface EventBus extends EventPublisher {
Expand All @@ -12,8 +11,8 @@ public interface EventBus extends EventPublisher {

UUID generateId();

void send(Event event);
<T> void send(T event);

void sendAll(Iterable<Event> queue);
<T> void sendAll(Iterable<T> queue);

}
95 changes: 54 additions & 41 deletions core/src/main/java/io/cucumber/core/options/PluginOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import io.cucumber.core.logging.Logger;
import io.cucumber.core.logging.LoggerFactory;
import io.cucumber.core.plugin.DefaultSummaryPrinter;
import io.cucumber.core.plugin.HTMLFormatter;
import io.cucumber.core.plugin.JSONFormatter;
import io.cucumber.core.plugin.HtmlFormatter;
import io.cucumber.core.plugin.JUnitFormatter;
import io.cucumber.core.plugin.MessageFormatter;
import io.cucumber.core.plugin.NullSummaryPrinter;
import io.cucumber.core.plugin.Options;
import io.cucumber.core.plugin.PrettyFormatter;
Expand All @@ -25,6 +25,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Supplier;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -33,23 +34,35 @@ public class PluginOption implements Options.Plugin {
private static final Logger log = LoggerFactory.getLogger(PluginOption.class);

private static final Pattern PLUGIN_WITH_ARGUMENT_PATTERN = Pattern.compile("([^:]+):(.*)");
private static final HashMap<String, Class<? extends Plugin>> PLUGIN_CLASSES = new HashMap<String, Class<? extends Plugin>>() {{
put("default_summary", DefaultSummaryPrinter.class);
put("html", HTMLFormatter.class);
put("json", JSONFormatter.class);
put("junit", JUnitFormatter.class);
put("null_summary", NullSummaryPrinter.class);
put("pretty", PrettyFormatter.class);
put("progress", ProgressFormatter.class);
put("rerun", RerunFormatter.class);
put("summary", DefaultSummaryPrinter.class);
put("testng", TestNGFormatter.class);
put("timeline", TimelineFormatter.class);
put("unused", UnusedStepsSummaryPrinter.class);
put("usage", UsageFormatter.class);
put("teamcity", TeamCityPlugin.class);
private static final HashMap<String, Supplier<Class<? extends Plugin>>> PLUGIN_CLASSES = new HashMap<String, Supplier<Class<? extends Plugin>>>() {{
put("default_summary", () -> DefaultSummaryPrinter.class);
put("html", () -> HtmlFormatter.class);
put("json", () -> loadClassFromGherkinVintage("io.cucumber.core.gherkin.vintage.JsonFormatter"));
put("junit", () -> JUnitFormatter.class);
put("null_summary", () -> NullSummaryPrinter.class);
put("pretty", () -> PrettyFormatter.class);
put("progress", () -> ProgressFormatter.class);
put("message", () -> MessageFormatter.class);
put("rerun", () -> RerunFormatter.class);
put("summary", () -> DefaultSummaryPrinter.class);
put("testng", () -> TestNGFormatter.class);
put("timeline", () -> TimelineFormatter.class);
put("unused", () -> UnusedStepsSummaryPrinter.class);
put("usage", () -> UsageFormatter.class);
put("teamcity", () -> TeamCityPlugin.class);
}};

private static Class<? extends Plugin> loadClassFromGherkinVintage(String className) {
try {
Class<?> aClass = Thread.currentThread().getContextClassLoader().loadClass(className);
return (Class<? extends Plugin>) aClass;
} catch (ClassNotFoundException | NoClassDefFoundError e) {
throw new CucumberException("" +
"Couldn't load plugin class: " + className + "\n" +
"Make sure `cucumber-gherkin-vintage` is available on the classpath", e);
}
}

// Replace IDEA plugin with TeamCity
private static final Set<String> INCOMPATIBLE_INTELLIJ_IDEA_PLUGIN_CLASSES = new HashSet<String>() {{
add("org.jetbrains.plugins.cucumber.java.run.CucumberJvmSMFormatter");
Expand Down Expand Up @@ -77,6 +90,29 @@ private PluginOption(String pluginString, Class<? extends Plugin> pluginClass, S
this.argument = argument;
}

@Override
public Class<? extends Plugin> pluginClass() {
return pluginClass;
}

@Override
public String argument() {
return argument;
}

@Override
public String pluginString() {
return pluginString;
}

boolean isFormatter() {
return EventListener.class.isAssignableFrom(pluginClass) || ConcurrentEventListener.class.isAssignableFrom(pluginClass);
}

boolean isSummaryPrinter() {
return SummaryPrinter.class.isAssignableFrom(pluginClass);
}

public static PluginOption parse(String pluginArgumentPattern) {
Matcher pluginWithFile = PLUGIN_WITH_ARGUMENT_PATTERN.matcher(pluginArgumentPattern);
if (!pluginWithFile.matches()) {
Expand All @@ -97,7 +133,7 @@ private static Class<? extends Plugin> parsePluginName(String pluginName) {
return TeamCityPlugin.class;
}

Class<? extends Plugin> pluginClass = PLUGIN_CLASSES.get(pluginName);
Class<? extends Plugin> pluginClass = PLUGIN_CLASSES.get(pluginName).get();
if (pluginClass == null) {
pluginClass = loadClass(pluginName);
}
Expand All @@ -118,28 +154,5 @@ private static Class<? extends Plugin> loadClass(String className) {
}
}

@Override
public Class<? extends Plugin> pluginClass() {
return pluginClass;
}

@Override
public String argument() {
return argument;
}

@Override
public String pluginString() {
return pluginString;
}

boolean isFormatter() {
return EventListener.class.isAssignableFrom(pluginClass) || ConcurrentEventListener.class.isAssignableFrom(pluginClass);
}

boolean isSummaryPrinter() {
return SummaryPrinter.class.isAssignableFrom(pluginClass);
}


}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.cucumber.core.options;

import gherkin.GherkinDialect;
import gherkin.GherkinDialectProvider;
import gherkin.IGherkinDialectProvider;
import io.cucumber.core.exception.CucumberException;
import io.cucumber.core.feature.FeatureWithLines;
import io.cucumber.core.feature.GluePath;
import io.cucumber.datatable.DataTable;
import io.cucumber.gherkin.GherkinDialect;
import io.cucumber.gherkin.GherkinDialectProvider;
import io.cucumber.gherkin.IGherkinDialectProvider;

import java.io.BufferedReader;
import java.io.InputStream;
Expand Down
Loading