Skip to content

Commit

Permalink
[Core] Fix test teardown on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mpkorstanje committed Mar 9, 2023
1 parent 7d90abd commit 8ea1d66
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/test-java.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ on:
- renovate/**

jobs:
build:
name: 'Build'
build-ubuntu:
name: 'Build Ubuntu'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -32,6 +32,23 @@ jobs:
env:
CUCUMBER_PUBLISH_TOKEN: ${{ secrets.CUCUMBER_PUBLISH_TOKEN }}

build-windows:
name: 'Build Windows'
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '17'
cache: 'maven'
- name: Install dependencies
run: mvn install -Pinclude-extra-modules -DskipTests=true -DskipITs=true -Darchetype.test.skip=true -Dmaven.javadoc.skip=true --batch-mode -Dstyle.color=always --show-version
- name: Test
run: mvn verify -Pinclude-extra-modules -Dstyle.color=always
env:
CUCUMBER_PUBLISH_TOKEN: ${{ secrets.CUCUMBER_PUBLISH_TOKEN }}

javadoc:
name: 'Javadoc'
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.cucumber.core.options.PluginOption;
import io.cucumber.core.runner.ClockStub;
import io.cucumber.core.runtime.TimeServiceEventBus;
import io.cucumber.messages.types.Envelope;
import io.cucumber.plugin.ConcurrentEventListener;
import io.cucumber.plugin.EventListener;
import io.cucumber.plugin.event.EventHandler;
Expand All @@ -30,13 +31,14 @@
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Instant;
import java.util.Objects;
import java.util.UUID;

import static io.cucumber.core.options.TestPluginOption.parse;
import static io.cucumber.messages.Convertor.toMessage;
import static java.nio.file.Files.readAllLines;
import static java.time.Duration.ZERO;
import static java.time.Instant.now;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
Expand Down Expand Up @@ -383,6 +385,7 @@ public WantsTooMuch(String too, String much) {
private static class FakeTestRunEventsPublisher implements EventPublisher {
private EventHandler<TestRunStarted> startHandler;
private EventHandler<TestRunFinished> finishedHandler;
private EventHandler<Envelope> envelopeHandler;

@Override
public <T> void registerHandlerFor(Class<T> eventType, EventHandler<T> handler) {
Expand All @@ -392,6 +395,9 @@ public <T> void registerHandlerFor(Class<T> eventType, EventHandler<T> handler)
if (eventType == TestRunFinished.class) {
finishedHandler = ((EventHandler<TestRunFinished>) handler);
}
if (eventType == Envelope.class) {
envelopeHandler = ((EventHandler<Envelope>) handler);
}
}

@Override
Expand All @@ -400,10 +406,14 @@ public <T> void removeHandlerFor(Class<T> eventType, EventHandler<T> handler) {

public void fakeTestRunEvents() {
if (startHandler != null) {
startHandler.receive(new TestRunStarted(Instant.now()));
startHandler.receive(new TestRunStarted(now()));
}
if (finishedHandler != null) {
finishedHandler.receive(new TestRunFinished(Instant.now(), new Result(Status.PASSED, ZERO, null)));
finishedHandler.receive(new TestRunFinished(now(), new Result(Status.PASSED, ZERO, null)));
}
if (envelopeHandler != null) {
envelopeHandler.receive(
Envelope.of(new io.cucumber.messages.types.TestRunFinished("done", false, toMessage(now()), null)));
}
}

Expand Down

0 comments on commit 8ea1d66

Please sign in to comment.