Skip to content

Commit 7f798f3

Browse files
authored
fix(allure-karate): remove the code that causes the process to hang (fixes #1040, via #1065)
1 parent a85d0e3 commit 7f798f3

File tree

1 file changed

+0
-85
lines changed

1 file changed

+0
-85
lines changed

allure-karate/src/main/java/io/qameta/allure/karate/AllureKarate.java

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import com.intuit.karate.core.StepResult;
2727
import io.qameta.allure.Allure;
2828
import io.qameta.allure.AllureLifecycle;
29-
import io.qameta.allure.model.Attachment;
3029
import io.qameta.allure.model.Label;
3130
import io.qameta.allure.model.Link;
3231
import io.qameta.allure.model.Parameter;
@@ -50,8 +49,6 @@
5049
import java.util.Optional;
5150
import java.util.Set;
5251
import java.util.UUID;
53-
import java.util.concurrent.locks.ReadWriteLock;
54-
import java.util.concurrent.locks.ReentrantReadWriteLock;
5552
import java.util.stream.Collectors;
5653

5754
import static io.qameta.allure.util.ResultsUtils.createLabel;
@@ -71,11 +68,6 @@ public class AllureKarate implements RuntimeHook {
7168

7269
private final AllureLifecycle lifecycle;
7370

74-
private final ReadWriteLock lock = new ReentrantReadWriteLock();
75-
76-
private final Map<String, String> stepsAndTcUuids = new HashMap<>();
77-
private final Map<String, Step> stepAndUuids = new HashMap<>();
78-
7971
private final List<String> tcUuids = new ArrayList<>();
8072

8173
public AllureKarate() {
@@ -221,14 +213,6 @@ public void afterStep(final StepResult result,
221213
});
222214
lifecycle.stopStep(uuid);
223215

224-
if (stepResult.isFailed()
225-
&& sr.engine.getConfig().getDriverOptions() != null
226-
&& (Boolean) sr.engine.getConfig().getDriverOptions().get("screenshotOnFailure")
227-
) {
228-
addToStepsAndTcUuids(uuid, lifecycle.getCurrentTestCase().get());
229-
addToStepAndUuids(uuid, step);
230-
}
231-
232216
if (Objects.nonNull(result.getEmbeds())) {
233217
result.getEmbeds().forEach(embed -> {
234218
try (InputStream is = new BufferedInputStream(Files.newInputStream(embed.getFile().toPath()))) {
@@ -248,30 +232,6 @@ public void afterStep(final StepResult result,
248232

249233
@Override
250234
public void afterFeature(final FeatureRuntime fr) {
251-
252-
if (!stepsAndTcUuids.isEmpty()) {
253-
fr.result.getScenarioResults()
254-
.forEach(sc -> {
255-
if (Objects.nonNull(sc.getFailedStep())) {
256-
getKeySetFromStepAndUuids().forEach(uuid -> {
257-
if (getValueFromStepAndUuids(uuid) == sc.getFailedStep().getStep()) {
258-
final List<Attachment> attachments = new ArrayList<>();
259-
sc.getFailedStep().getEmbeds().forEach(e -> attachments.add(
260-
new Attachment()
261-
.setSource(e.getFile().getPath())
262-
.setType(e.getResourceType().contentType)
263-
.setName(e.getFile().getName())
264-
)
265-
);
266-
lifecycle.updateTestCase(getValueFromStepsAndTcUuids(uuid), result ->
267-
result.setAttachments(attachments)
268-
);
269-
}
270-
});
271-
}
272-
});
273-
}
274-
275235
tcUuids.forEach(lifecycle::writeTestCase);
276236
}
277237

@@ -321,49 +281,4 @@ private List<Link> getLinks(final List<String> labels) {
321281
}
322282
return allureLinks;
323283
}
324-
325-
private void addToStepsAndTcUuids(final String stepUuid, final String tcUuid) {
326-
lock.writeLock().lock();
327-
try {
328-
stepsAndTcUuids.put(stepUuid, tcUuid);
329-
} finally {
330-
lock.writeLock().unlock();
331-
}
332-
}
333-
334-
private void addToStepAndUuids(final String stepUuid, final Step step) {
335-
lock.writeLock().lock();
336-
try {
337-
stepAndUuids.put(stepUuid, step);
338-
} finally {
339-
lock.writeLock().unlock();
340-
}
341-
}
342-
343-
private String getValueFromStepsAndTcUuids(final String stepUuid) {
344-
lock.readLock().lock();
345-
try {
346-
return stepsAndTcUuids.get(stepUuid);
347-
} finally {
348-
lock.readLock().unlock();
349-
}
350-
}
351-
352-
private Step getValueFromStepAndUuids(final String stepUuid) {
353-
lock.readLock().lock();
354-
try {
355-
return stepAndUuids.get(stepUuid);
356-
} finally {
357-
lock.readLock().unlock();
358-
}
359-
}
360-
361-
private Set<String> getKeySetFromStepAndUuids() {
362-
lock.readLock().lock();
363-
try {
364-
return stepAndUuids.keySet();
365-
} finally {
366-
lock.readLock().unlock();
367-
}
368-
}
369284
}

0 commit comments

Comments
 (0)