Skip to content

Commit

Permalink
[JENKINS-33457] fixed test execution handling when aborting the build
Browse files Browse the repository at this point in the history
  • Loading branch information
cpoenisch committed Mar 11, 2016
1 parent fb16376 commit d58a865
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 33 deletions.
Expand Up @@ -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;
Expand Down
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -239,7 +244,7 @@ private static final class RunPackageCallable implements Callable<TestInfoHolder
}

@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();
Expand Down Expand Up @@ -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;
}
Expand Down
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -244,7 +249,7 @@ private static final class RunProjectCallable implements Callable<TestInfoHolder
}

@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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit d58a865

Please sign in to comment.