Skip to content

Commit

Permalink
Merge branch 'autFailFatal'
Browse files Browse the repository at this point in the history
  • Loading branch information
basilevs committed Apr 4, 2024
2 parents 0909c75 + 42ec2e9 commit 7077a55
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
7 changes: 3 additions & 4 deletions releng/Jenkinsfile.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,15 @@ $SSH_DEPLOY_CONTAINER_VOLUMES
}

private void _run_tests(String runner, String dir, String args) {
try {
this.script.warnError(message: "Tests failed") {
this.script.sh "mvn clean verify -B -f ${dir}/pom.xml \
-Dmaven.repo.local=${getWorkspace()}/m2 -e \
-Dci-maven-version=2.0.0-SNAPSHOT \
-DexplicitRunner=`readlink -f ${runner}` \
${args} || true"
${args}"
this.script.sh "test -f ${dir}/target/results/tests.html"
} finally {
this.script.archiveArtifacts allowEmptyArchive: false, artifacts: "${dir}/target/results/**/*, ${dir}/target/**/*log,${dir}/target/surefire-reports/**"
}
this.script.archiveArtifacts allowEmptyArchive: false, artifacts: "${dir}/target/results/**/*, ${dir}/target/**/*log,${dir}/target/surefire-reports/**"
}

void post_build_actions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ public int performCoolThings() throws Exception {

TestsRunner testsRunner = new TestsRunner(conf, this,
new ResultsHandler(conf, runnerOptions.isRestartAUTOnFailures()));
Q7ReportIterator reportIterator = testsRunner.findAndRunTests();

reporter.report(reportIterator, this, conf);
try(Q7ReportIterator reportIterator = testsRunner.findAndRunTests()) {
reporter.report(reportIterator, this, conf);
}
testsRunner.throwOnError();

return testsRunner.getFailedCount();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicReference;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
Expand Down Expand Up @@ -68,6 +69,7 @@ public class TestsRunner {
private final ResultsHandler resultsHandler;
private final AUTsManager auts;
private int failedCount = 0;
private AtomicReference<Exception> error = new AtomicReference<>(null);

public int getFailedCount() {
return failedCount;
Expand Down Expand Up @@ -257,21 +259,13 @@ private Q7ReportIterator runTests(final TestSuite[] tests) throws DebugException
Assert.isTrue(auts.isClean(), "AUTs manages should not have been used before");
List<ScenarioRunnable> runnables = Collections.synchronizedList(new ArrayList<ScenarioRunnable>());
failedCount = 0;
final SherlockReportOutputStream reportWriter;
File reportFile = new File(conf.getQ7ReportLocation());

createFolderForFile(reportFile);

try {
reportWriter = new SherlockReportOutputStream(
new BufferedOutputStream(new FileOutputStream(reportFile)));
} catch (FileNotFoundException e1) {
System.out.println("Failed to create report file:" + conf.getQ7ReportLocation());
HeadlessRunnerPlugin.getDefault().info("Failed to create report file:" + conf.getQ7ReportLocation());
throw new RuntimeException(e1);
}
Set<String> failed = new HashSet<String>();
try {
try (SherlockReportOutputStream reportWriter = new SherlockReportOutputStream(
new BufferedOutputStream(new FileOutputStream(reportFile)))) {
int count = 0;
for (final TestSuite suite : tests) {
suite.setLimit(conf.limit);
Expand Down Expand Up @@ -353,6 +347,7 @@ private Q7ReportIterator runTests(final TestSuite[] tests) throws DebugException
}
}
if (!alive) {
error.compareAndSet(null, new AutLaunchFail("AUT is not available", null));
// No alive threads -> finish
skipRemaining(runnables, "AUT is not available");
break;
Expand All @@ -367,6 +362,10 @@ private Q7ReportIterator runTests(final TestSuite[] tests) throws DebugException
System.out.println(scenario);
}
}
} catch (FileNotFoundException e1) {
System.out.println("Failed to create report file:" + conf.getQ7ReportLocation());
HeadlessRunnerPlugin.getDefault().info("Failed to create report file:" + conf.getQ7ReportLocation());
throw new RuntimeException(e1);
} catch (InterruptedException e) {
HeadlessRunnerPlugin.getDefault().info("Execution interrupted");
}
Expand All @@ -383,8 +382,6 @@ private Q7ReportIterator runTests(final TestSuite[] tests) throws DebugException
}
auts.removeShutdownHook();
failedCount = failed.size();
if (reportWriter != null)
reportWriter.close();
TestEngineManager.getInstance().fireTestRunCompleted();
}

Expand Down Expand Up @@ -436,4 +433,11 @@ private void createFolderForFile(File reportFile) {
}
}

public void throwOnError() throws Exception {
Exception result = error.get();
if (result != null) {
throw result;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.rcptt.sherlock.core.streams;

import java.io.Closeable;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
Expand All @@ -18,7 +19,7 @@
import org.eclipse.rcptt.sherlock.core.SherlockCore;
import org.eclipse.rcptt.sherlock.core.model.sherlock.report.Report;

public class SherlockReportOutputStream {
public class SherlockReportOutputStream implements Closeable {
private ZipOutputStream stream;
int index = 0;

Expand Down

0 comments on commit 7077a55

Please sign in to comment.