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

[Core] Refactor Runtime #1367

Merged
merged 53 commits into from
Jun 5, 2018
Merged

[Core] Refactor Runtime #1367

merged 53 commits into from
Jun 5, 2018

Conversation

mpkorstanje
Copy link
Contributor

@mpkorstanje mpkorstanje commented May 22, 2018

Summary

Extracting:

  • Backend creation,
  • Glue creation,
  • Runner creation
  • Feature compilation

from the runtime allows

@mpkorstanje mpkorstanje mentioned this pull request May 22, 2018
@mpkorstanje mpkorstanje changed the title [Core] Refactor Runtime [WIP][Core] Refactor Runtime May 22, 2018
@boaty82
Copy link
Contributor

boaty82 commented May 29, 2018

Pulled the branch to work on some changes for PR 1357 and before I've made any changes I'm running the tests (whilst perusing the changes already made for me) and I get the following issue

[ERROR] Failed to execute goal org.revapi:revapi-maven-plugin:0.10.2:check (check) on project cucumber-java: The following API problems caused the build to fail:
[ERROR] java.annotation.noLongerPresent: @interface cucumber.api.java.ht.SipozeKe: Old API referenced the annotation type but the new API version no longer does. (breaks semantic versioning)
[ERROR] java.annotation.noLongerPresent: @interface cucumber.api.java.ht.SipozeKe: Old API referenced the annotation type but the new API version no longer does. (breaks semantic versioning)
[ERROR]
[ERROR] If you're using the semver-ignore extension, update your module's version to one compatible with the current changes (e.g. mvn package revapi:update-versions). If you want to explicitly ignore this change and provide a justification for it, add the following JSON snippet to your Revapi configuration under "revapi.ignore" path:
[ERROR] {
[ERROR] "code": "java.annotation.noLongerPresent",
[ERROR] "old": "@interface cucumber.api.java.ht.SipozeKe",
[ERROR] "package": "cucumber.api.java.ht",
[ERROR] "classQualifiedName": "cucumber.api.java.ht.SipozeKe",
[ERROR] "classSimpleName": "SipozeKe",
[ERROR] "elementKind": "@interface",
[ERROR] "justification": <<<<< ADD YOUR EXPLANATION FOR THE NECESSITY OF THIS CHANGE >>>>>
[ERROR] },
...

Just want to start with a clean running state, thanks in advance

@mpkorstanje
Copy link
Contributor Author

mpkorstanje commented May 29, 2018 via email

@mlvandijk
Copy link
Member

@boaty82 You'll also have to comment out the enforcer (fyi ;))

@boaty82
Copy link
Contributor

boaty82 commented May 29, 2018

I’ve done that. Just thought there might be a more “proper” fix

@mpkorstanje
Copy link
Contributor Author

mpkorstanje commented May 29, 2018

No. Don't have a solution yet. There is something going wrong when you run the build. Maybe something executed in the wrong order that causes the languages not to be generated when revapi comes by.

@mpkorstanje mpkorstanje added this to the 4.0.0 milestone May 30, 2018
@mpkorstanje
Copy link
Contributor Author

mpkorstanje commented Jun 2, 2018

I've moved the semantic version check to a different profile. Unless you turn it own it only runs on the CI.

This slows down the feedback loop a bit, but this is okay because we'll figure out which version it has to go in when merging. Not when building the feature.

@mpkorstanje
Copy link
Contributor Author

Also feel free to ignore any problems with pax-exam.

@mpkorstanje mpkorstanje force-pushed the refactor-runtime-constructors branch from 199f9aa to 3ba1ee7 Compare June 5, 2018 14:27
@mpkorstanje mpkorstanje changed the title [WIP][Core] Refactor Runtime [Core] Refactor Runtime Jun 5, 2018
@mpkorstanje mpkorstanje merged commit 56c3477 into master Jun 5, 2018
@boaty82
Copy link
Contributor

boaty82 commented Jun 9, 2018

OK there are problems in the tests with queueing events, which I've been tracking down for a few hours across the last few days

Basically
Main
uses
RunnerSupplier runnerSupplier = new ThreadLocalRunnerSupplier(runtimeOptions, bus, backendSupplier, glueSupplier);

and ThreadLocalRunnerSupplier
return new Runner(glueSupplier.get(), eventBus.createBatchedEventBus(), backendSupplier.get(), runtimeOptions);
which creates the wrapping EventBus

However, TestHelper does

        RunnerSupplier runnerSupplier = new RunnerSupplier () {
            @Override
            public Runner get() {
                return new Runner(glue, bus, backendSupplier.get(), runtimeOptions);
            }
        };

which doesn't create the wrapper, which it should as this class should be effectively verifying what Main does

So if I update the TestHelper to do the same and then run cucumber.runtime.formatter.JSONFormatterTest#should_format_feature_with_background, for example, then the test fails. Having looked through the resulting json the step durations are all 0

I've tracked the problem down to StepDurationTimeService in that it registers for TestStepStarted events, and when it receives them it increments the currentTime by the required duration.

Just trying to think of a nice way to resolve this, but thoughts are welcome in the mean time.

Also, BTW the super.send in cucumber.runner.EventBus.BatchEventBus#send is kind of superfluous, in this instance, as the handlers in the BatchEventBus are empty and it isn't until parent.sendAll() when the events are distributed. But that isn't to say that the handlers would be empty in all scenarios

@boaty82
Copy link
Contributor

boaty82 commented Jun 9, 2018

Think I've found a nice solution.

I've created a new event TimerEvent, which StepDurationTimeService now registers for.
Updated TestStepStarted to implement it

I then had to update EventBus to loop through the handler map and check if the incoming event is an instance of the class in the key, rather than getting the key.

Just got to double check the tests

@mpkorstanje
Copy link
Contributor Author

mpkorstanje commented Jun 9, 2018 via email

@boaty82
Copy link
Contributor

boaty82 commented Jun 9, 2018

Hi.

Haven't needed to add a new event interface in the end. Managed to just create a new EventBus implementation now, purely for tests, so TestStepStarted events are sent, all the time, for only certain EventListeners - in my case StepDurationTimeService - as well as being queued up for the Formatters

Have done the changes to support --threads, just adding the thread timeline report now. Do the HTML/JS/etc files need to go in a new jar & repo link the HTML plugin? I won't have permission to do this

@boaty82 boaty82 mentioned this pull request Jun 9, 2018
6 tasks
mpkorstanje added a commit that referenced this pull request Mar 8, 2019
JUnit is running Cucumber so the expectation is that JUnit's
`@BeforeClass` and `@AfterClass` methods are invoked respectively before
and after all events emitted by Cucumber. However because the
`TestRunStarted` event was emitted in the constructor of `Cucumber` it
would precede the the invocation of `@BeforeClass`.

In older versions of Cucumber sending the `TestSourceRead` events was
coupled to reading the test sources. This made it impossible to read the
features ahead of time -required to to create the test description
tree and fail on lexer errors- and send `TestRunStarted` after
`@BeforeClass`.

This is no longer case since #1367 and so this problem can be resolved.
mpkorstanje added a commit that referenced this pull request Mar 8, 2019
JUnit is running Cucumber so the expectation is that JUnit's
`@BeforeClass` and `@AfterClass` methods are invoked respectively before
and after all events emitted by Cucumber. However because the
`TestRunStarted` event was emitted in the constructor of `Cucumber` it
would precede the the invocation of `@BeforeClass`.

In older versions of Cucumber sending the `TestSourceRead` events was
coupled to reading the test sources. This made it impossible to read the
features ahead of time -required to to create the test description
tree and fail on lexer errors- and send `TestRunStarted` after
`@BeforeClass`.

This is no longer case since #1367 and so this problem can be resolved.
mpkorstanje added a commit that referenced this pull request Mar 8, 2019
JUnit is running Cucumber so the expectation is that JUnit's
`@BeforeClass` and `@AfterClass` methods are invoked respectively before
and after all events emitted by Cucumber. However because the
`TestRunStarted` event was emitted in the constructor of `Cucumber` it
would precede the the invocation of `@BeforeClass`.

In older versions of Cucumber sending the `TestSourceRead` events was
coupled to reading the test sources. This made it impossible to read the
features ahead of time -required to to create the test description
tree and fail on lexer errors- and send `TestRunStarted` after
`@BeforeClass`.

This is no longer case since #1367 and so this problem can be resolved.
mpkorstanje added a commit that referenced this pull request Mar 8, 2019
JUnit is running Cucumber so the expectation is that JUnit's
`@BeforeClass` and `@AfterClass` methods are invoked respectively before
and after all events emitted by Cucumber. However because the
`TestRunStarted` event was emitted in the constructor of `Cucumber` it
would precede the the invocation of `@BeforeClass`.

In older versions of Cucumber sending the `TestSourceRead` events was
coupled to reading the test sources. This made it impossible to read the
features ahead of time -required to to create the test description
tree and fail on lexer errors- and send `TestRunStarted` after
`@BeforeClass`.

This is no longer case since #1367 and so this problem can be resolved.
@lock
Copy link

lock bot commented Jun 9, 2019

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 Jun 9, 2019
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.

4 participants