Skip to content

Commit

Permalink
fixes #217: Implement "Pause/Abort at first error" feature in Eclipse
Browse files Browse the repository at this point in the history
  • Loading branch information
S1artie committed Jan 30, 2019
1 parent 1fc7777 commit ce9747c
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 11 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,38 @@ public class IntegrityTestRunnerView extends ViewPart {
*/
private boolean scrollLockActive;

/**
* The action which toggles between normal mode, pause at first error or abort at first error.
*/
private Action pauseAbortAtFirstErrorAction;

/**
* Whether the test run should be paused when the first error is encountered.
*/
private boolean pauseAtFirstErrorActive;

/**
* Whether the test run should be aborted when the first error is encountered.
*/
private boolean abortAtFirstErrorActive;

/**
* Will be set when the {@link #abortAtFirstErrorActive} flag triggers an abortion of test execution.
*/
private boolean lastRunWasAutoAborted;

/**
* The threshold of accepted test failures before the {@link #pauseAtFirstErrorActive} or
* {@link #abortAtFirstErrorActive} triggers an action.
*/
private int pauseAbortAtFirstErrorFailureThreshold;

/**
* If the last test run has reported its ending normally. This is used to distinguish between connection losses of
* unexpected nature and such losses that occur because testing has ended.
*/
private boolean lastRunEndStatusReceived;

/**
* The last level of node expansion.
*/
Expand Down Expand Up @@ -589,6 +621,11 @@ public class IntegrityTestRunnerView extends ViewPart {
*/
private SetList setList;

/**
* Used to measure the connected time.
*/
private long connectionTimestamp;

/**
* The set of breakpoints currently in use.
*/
Expand Down Expand Up @@ -1501,6 +1538,7 @@ private void fillLocalToolBar(IToolBarManager aManager) {
aManager.add(stepIntoAction);
aManager.add(stepOverAction);
aManager.add(clearBreakpointsAction);
aManager.add(pauseAbortAtFirstErrorAction);
aManager.add(new Separator());
aManager.add(connectToTestRunnerAction);
}
Expand Down Expand Up @@ -1758,6 +1796,40 @@ public void run() {
scrollLockAction.setToolTipText("Toggles the scroll lock setting.");
scrollLockAction.setImageDescriptor(Activator.getImageDescriptor("icons/scrolllock.gif"));

pauseAbortAtFirstErrorAction = new Action("Pause/abort at first test failure", IAction.AS_CHECK_BOX) {
@Override
public void run() {
if (!pauseAtFirstErrorActive && !abortAtFirstErrorActive) {
pauseAtFirstErrorActive = true;
setChecked(true);
setImageDescriptor(Activator.getImageDescriptor("icons/auto_pause_abort_on_pause.gif"));
setToolTipText("Will automatically pause test execution on first test failure.");
} else if (pauseAtFirstErrorActive) {
pauseAtFirstErrorActive = false;
abortAtFirstErrorActive = true;
setChecked(true);
setImageDescriptor(Activator.getImageDescriptor("icons/auto_pause_abort_on_abort.gif"));
setToolTipText("Will automatically abort test execution on first test failure.");
} else {
pauseAtFirstErrorActive = false;
abortAtFirstErrorActive = false;
setChecked(false);
setImageDescriptor(Activator.getImageDescriptor("icons/auto_pause_abort_disabled.gif"));
setToolTipText("Automatically pause or abort on first test failure is currently disabled.");
}

if (setList != null) {
pauseAbortAtFirstErrorFailureThreshold = setList
.getNumberOfEntriesInResultState(SetListEntryResultStates.FAILED)
+ setList.getNumberOfEntriesInResultState(SetListEntryResultStates.EXCEPTION);
}
};
};
pauseAbortAtFirstErrorAction
.setToolTipText("Automatically pause or abort on first test failure is currently disabled.");
pauseAbortAtFirstErrorAction
.setImageDescriptor(Activator.getImageDescriptor("icons/auto_pause_abort_disabled.gif"));

updateActionStatus(null);
}

Expand Down Expand Up @@ -1856,9 +1928,19 @@ public void run() {
pauseAction.setEnabled(false);
stepIntoAction.setEnabled(false);
stepOverAction.setEnabled(false);
updateStatusRunnable(
determineIntermediateTestResultStatusString("Test execution finished (", ")"))
.run();
if (lastRunWasAutoAborted) {
updateStatusRunnable(
determineIntermediateTestResultStatusString("Test was aborted on failure (",
") after " + DateUtil.convertNanosecondTimespanToHumanReadableFormat(
System.nanoTime() - connectionTimestamp, true, false))).run();
} else {
updateStatusRunnable(
determineIntermediateTestResultStatusString("Test execution finished (",
") after " + DateUtil.convertNanosecondTimespanToHumanReadableFormat(
System.nanoTime() - connectionTimestamp, true, false))).run();
}
lastRunWasAutoAborted = false;
lastRunEndStatusReceived = true;
break;
default:
break;
Expand Down Expand Up @@ -2442,6 +2524,8 @@ private void updateSetList(SetList aNewSetList) {
setList = aNewSetList;
breakpointSet.clear();
setListSearch = null;
pauseAbortAtFirstErrorFailureThreshold = 0;
lastRunWasAutoAborted = false;

Display.getDefault().asyncExec(new Runnable() {
@Override
Expand Down Expand Up @@ -2492,11 +2576,6 @@ public boolean isSkippable() {

private class RemotingListener implements IntegrityRemotingClientListener {

/**
* Used to measure the connected time.
*/
private long connectionTimestamp;

@Override
public void onConnectionSuccessful(IntegrityRemotingVersionMessage aRemoteVersion, Endpoint anEndpoint) {
// request set list baseline and execution state
Expand Down Expand Up @@ -2578,9 +2657,20 @@ public void onConnectionLost(Endpoint anEndpoint) {
public void run() {
executionProgress.redraw();
updateActionStatusRunnable(null).run();
updateStatusRunnable(determineIntermediateTestResultStatusString("Test Runner disconnected (",
") after " + DateUtil.convertNanosecondTimespanToHumanReadableFormat(
System.nanoTime() - connectionTimestamp, true, false))).run();
if (lastRunWasAutoAborted) {
updateStatusRunnable(
determineIntermediateTestResultStatusString("Test was aborted on failure (",
") after " + DateUtil.convertNanosecondTimespanToHumanReadableFormat(
System.nanoTime() - connectionTimestamp, true, false))).run();
} else {
if (!lastRunEndStatusReceived) {
updateStatusRunnable(
determineIntermediateTestResultStatusString("Test Runner disconnected (",
") after " + DateUtil.convertNanosecondTimespanToHumanReadableFormat(
System.nanoTime() - connectionTimestamp, true, false))).run();
}
}
lastRunEndStatusReceived = false;
}
});

Expand Down Expand Up @@ -2623,6 +2713,31 @@ public void onSetListUpdate(final SetListEntry[] someUpdatedEntries, final Integ
if (anEntryInExecutionReference != null) {
setList.setEntryInExecutionReference(anEntryInExecutionReference);
}

if (pauseAtFirstErrorActive || abortAtFirstErrorActive) {
int tempCurrentFailures = setList.getNumberOfEntriesInResultState(SetListEntryResultStates.FAILED)
+ setList.getNumberOfEntriesInResultState(SetListEntryResultStates.EXCEPTION);
if (tempCurrentFailures > pauseAbortAtFirstErrorFailureThreshold) {
pauseAbortAtFirstErrorFailureThreshold = tempCurrentFailures;
if (pauseAtFirstErrorActive && isConnected()) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
pauseAction.run();
}
});
} else if (abortAtFirstErrorActive && isConnected()) {
lastRunWasAutoAborted = true;
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
shutdownAction.run();
}
});
}
}
}

Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
Expand Down

0 comments on commit ce9747c

Please sign in to comment.