Skip to content
Permalink
Browse files
[JENKINS-33457] fixed test execution handling when aborting the build
  • Loading branch information
cpoenisch committed Mar 11, 2016
1 parent fb16376 commit d58a865232fe5412c1f6b1ce1e447b503283f975
@@ -141,14 +141,14 @@ public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher,
final TTConsoleLogger logger = new TTConsoleLogger(listener);
logger.logInfo("- Closing running ECU-TEST and Tool-Server instances...");
if (checkETInstance(launcher, true)) {
logger.logInfo("-> No running ECU-TEST instance found.");
} else {
logger.logInfo("-> ECU-TEST closed successfully.");
}
if (!checkTSInstance(launcher, true)) {
logger.logInfo("-> No running Tool-Server instance found.");
} else {
logger.logInfo("-> No running ECU-TEST instance found.");
}
if (checkTSInstance(launcher, true)) {
logger.logInfo("-> Tool-Server closed successfully.");
} else {
logger.logInfo("-> No running Tool-Server instance found.");
}
}
return performed;
@@ -89,7 +89,7 @@ public PackageConfig getPackageConfig() {

@Override
public boolean runTestCase(final Launcher launcher, final BuildListener listener) throws IOException,
InterruptedException {
InterruptedException {
final TTConsoleLogger logger = new TTConsoleLogger(listener);

// Load JACOB library
@@ -116,15 +116,20 @@ public boolean runTestCase(final Launcher launcher, final BuildListener listener
return false;
}

// Run package
final TestInfoHolder testInfo = launcher.getChannel().call(
new RunPackageCallable(getTestFile(), getPackageConfig(), getExecutionConfig(), listener));

// Set test result information
if (testInfo != null) {
setTestResult(testInfo.getTestResult());
setTestReportDir(testInfo.getTestReportDir());
} else {
try {
// Run package
final TestInfoHolder testInfo = launcher.getChannel().call(
new RunPackageCallable(getTestFile(), getPackageConfig(), getExecutionConfig(), listener));

// Set test result information
if (testInfo != null) {
setTestResult(testInfo.getTestResult());
setTestReportDir(testInfo.getTestReportDir());
} else {
return false;
}
} catch (final InterruptedException e) {
logger.logError("Test execution has been interrupted!");
return false;
}

@@ -209,7 +214,7 @@ public PackageInfoHolder call() throws IOException {
/**
* {@link Callable} providing remote access to run a package via COM.
*/
private static final class RunPackageCallable implements Callable<TestInfoHolder, IOException> {
private static final class RunPackageCallable implements Callable<TestInfoHolder, InterruptedException> {

private static final long serialVersionUID = 1L;

@@ -239,7 +244,7 @@ public PackageInfoHolder call() throws IOException {
}

@Override
public TestInfoHolder call() throws IOException {
public TestInfoHolder call() throws InterruptedException {
final boolean runTest = packageConfig.isRunTest();
final boolean runTraceAnalysis = packageConfig.isRunTraceAnalysis();
final int timeout = executionConfig.getTimeout();
@@ -283,8 +288,6 @@ public TestInfoHolder call() throws IOException {
}
} catch (final ETComException e) {
logger.logError("Caught ComException: " + e.getMessage());
} catch (final InterruptedException e) {
logger.logError("Caught InterruptedException: " + e.getMessage());
}
return testInfo;
}
@@ -87,7 +87,7 @@ public ProjectConfig getProjectConfig() {

@Override
public boolean runTestCase(final Launcher launcher, final BuildListener listener) throws IOException,
InterruptedException {
InterruptedException {
final TTConsoleLogger logger = new TTConsoleLogger(listener);

// Load JACOB library
@@ -109,19 +109,24 @@ public boolean runTestCase(final Launcher launcher, final BuildListener listener
return false;
}

// Run project
final TestInfoHolder testInfo = launcher.getChannel().call(
new RunProjectCallable(getTestFile(), getProjectConfig(), getExecutionConfig(), listener));

// Set default project information
setTestDescription("");
setTestName(FilenameUtils.getBaseName(new File(getTestFile()).getName()));

// Set project information
if (testInfo != null) {
setTestResult(testInfo.getTestResult());
setTestReportDir(testInfo.getTestReportDir());
} else {
try {
// Run project
final TestInfoHolder testInfo = launcher.getChannel().call(
new RunProjectCallable(getTestFile(), getProjectConfig(), getExecutionConfig(), listener));

// Set project information
if (testInfo != null) {
setTestResult(testInfo.getTestResult());
setTestReportDir(testInfo.getTestReportDir());
} else {
return false;
}
} catch (final InterruptedException e) {
logger.logError("Test execution has been interrupted!");
return false;
}

@@ -214,7 +219,7 @@ public Boolean call() throws IOException {
/**
* {@link Callable} providing remote access to run a project via COM.
*/
private static final class RunProjectCallable implements Callable<TestInfoHolder, IOException> {
private static final class RunProjectCallable implements Callable<TestInfoHolder, InterruptedException> {

private static final long serialVersionUID = 1L;

@@ -244,7 +249,7 @@ public Boolean call() throws IOException {
}

@Override
public TestInfoHolder call() throws IOException {
public TestInfoHolder call() throws InterruptedException {
final int jobExecutionMode = projectConfig.getJobExecMode().getValue();
final int timeout = executionConfig.getTimeout();
TestInfoHolder testInfo = null;
@@ -282,8 +287,6 @@ public TestInfoHolder call() throws IOException {
}
} catch (final ETComException e) {
logger.logError("Caught ComException: " + e.getMessage());
} catch (final InterruptedException e) {
logger.logError("Caught InterruptedException: " + e.getMessage());
}
return testInfo;
}

0 comments on commit d58a865

Please sign in to comment.