Skip to content

Commit

Permalink
Merge branch 'master' into autFailFatal
Browse files Browse the repository at this point in the history
  • Loading branch information
basilevs committed Apr 4, 2024
2 parents 39820fb + 9643ee2 commit 42ec2e9
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -953,17 +953,16 @@ private IStatus internalExecute(Command command, long timeout, IProgressMonitor
try {
long stop = System.currentTimeMillis() + timeout;
return computeInNewSession(TimeoutInterruption.forTimeout(monitor, timeout, this), session -> {
ExecutionStatus result;
restoreState(session, properties);
try {
Command commandCopy = command;
IProcess process = session.execute(commandCopy);
IStatus processResult = process.waitFor(stop - System.currentTimeMillis(), monitor);
return new ExecutionStatus(processResult);
} finally {
if (monitor == null || !monitor.isCanceled()) {
dumpState(session);
}
Command commandCopy = command;
IProcess process = session.execute(commandCopy);
IStatus processResult = process.waitFor(stop - System.currentTimeMillis(), monitor);
result = new ExecutionStatus(processResult);
if (monitor == null || !monitor.isCanceled()) {
dumpState(session);
}
return result;
});
} catch (CoreException e) {
throw new CoreException(new MultiStatus(PLUGIN_ID, 0, new IStatus[] { ((CoreException) e).getStatus() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ConsoleOutputListener implements AutLaunchListener {

private final LogBuilder log;
private AutLaunch launch = null;
private boolean logStarted = false;

public ConsoleOutputListener()
{
Expand Down Expand Up @@ -78,10 +79,11 @@ public void startLogging(AutLaunch launch) {
flushable.setBuffered(false); // Fixes OutOfMemoryError
}
}

logStarted = true;
}

public void stopLogging() {
logStarted = false;
AutLaunch launch2 = launch;
if (launch2 == null)
return;
Expand All @@ -91,6 +93,7 @@ public void stopLogging() {
flushable.setBuffered(true);
}
}
log.clear();
launch = null;
}

Expand All @@ -102,6 +105,9 @@ public void stateChanged(AutLaunch launch, AutLaunchState state) {
}

public String getLog() {
if (!logStarted) {
throw new IllegalStateException("Log is not started");
}
return log.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Element-Type: testcase
Element-Version: 3.0
External-Reference:
Id: _fHHUcPL8EeCE19s6EOk3LA
Runtime-Version: 1.5.0.201407211318
Save-Time: 7/25/14 2:00 PM
Runtime-Version: 2.5.5.202404021936
Save-Time: 4/3/24, 9:38 PM
Tags: selfAUT, ControlPanel
Testcase-Type: ecl

Expand Down Expand Up @@ -38,8 +38,9 @@ Entry-Name: .content

get-view "Test Explorer" | get-tree | select "TestQ7Prj/Test scenario" | double-click -nowait
get-editor "Test scenario" | get-button Record | click
//wait 400
get-window "Control Panel.*" | get-button Stop | click
try -times 10 -delay 20000 -command {
get-window "Control Panel.*" | get-button Stop | click
}
with [get-window "Control Panel - Test scenario (TestQ7Prj) - selfQ7"] {
get-editbox | type-text qqq
get-button Save | click -arrow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Element-Type: testcase
Element-Version: 3.0
External-Reference: https://bugs.eclipse.org/bugs/show_bug.cgi?id=436965
Id: _NuUnkD2QEeSxD9UFwnFS6w
Runtime-Version: 2.2.0.qualifier
Save-Time: 5/23/17 12:20 PM
Runtime-Version: 2.5.5.202404021936
Save-Time: 4/3/24, 3:39 PM
Testcase-Type: ecl

------=_.content-0a7243a0-75d3-3d5f-9791-539de0e5b7ac
Expand All @@ -18,6 +18,10 @@ Entry-Name: .content
get-view Applications | click
get-button "Record a Snippet" | click

try -times 10 -delay 20 -command {
get-window "Control Panel.*" | get-button Stop
}

get-aut "mockupsQ7" | eval {

get-button "Open Perspective" | click
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private class JobInfo {

JobInfo(Job job) {
this.job = job;
status = calcJobStatus(job, 0);
this.status = calcJobStatus(job, 0);
}

synchronized void awake() {
Expand All @@ -132,6 +132,8 @@ synchronized void done(boolean reschedule) {
if (reschedule) {
// Job will be rescheduled
rescheduleCounter += 1;
} else {
status = calcJobStatus(job, startingTime - System.currentTimeMillis());
}
}

Expand All @@ -145,14 +147,11 @@ synchronized void printJobTimeoutLogEntry() {

synchronized boolean isActive() {
if (!JobStatus.REQUIRED.equals(status)) {
debug(this + " not required: " + status);
return false;
}
if (sleeping) {
long delay = startingTime - System.currentTimeMillis();
boolean rv = delay < TeslaLimits.getJobWaitForDelayedTimeout();
if (!rv)
debug(this + " is sleeping");
return rv;
}

Expand All @@ -162,11 +161,6 @@ synchronized boolean isActive() {
synchronized void scheduled(long delay) {
sleeping = false;
status = calcJobStatus(job, delay);
debug(this + " is scheduled as " + status);
if (DEBUG) {
Exception e = new Exception("Scheduled " + this);
e.printStackTrace(System.out);
}
startingTime = System.currentTimeMillis() + delay;
}

Expand All @@ -179,8 +173,8 @@ public String toString() {
case Job.WAITING: state = "WAITING"; break;
default: state = "NONE"; break;
}
return String.format("%s (%s), %s, active for %d, blocked for %d, running for %d",
job.getClass().getName(), job.getName(), state, System.currentTimeMillis() - startingTime,
return String.format("%s (%s), %s, status: %8s, is active: %b, active for %d, blocked for %d, running for %d",
job.getClass().getName(), job.getName(), state, status, isActive(), System.currentTimeMillis() - startingTime,
blocked ? System.currentTimeMillis() - blockedTime : 0, blocked ? 0 : System.currentTimeMillis() - runningTime);
}

Expand Down Expand Up @@ -236,8 +230,8 @@ private JobInfo getOrCreateJobInfo(Job job) {
Q7LoggingManager.get("jobs").log(msg, null);
ReportManager.appendLogExtra(msg);
}
debug("New job: " + rv);
jobs.put(job, rv);
event("new", rv);
}
return rv;
}
Expand All @@ -249,29 +243,39 @@ public void aboutToRun(IJobChangeEvent event) {

@Override
public void awake(IJobChangeEvent event) {
getOrCreateJobInfo(event.getJob()).awake();
Job job = event.getJob();
JobInfo info = getOrCreateJobInfo(job);
info.awake();
event("awake", info);
}

@Override
public void done(IJobChangeEvent event) {
Job job = event.getJob();
synchronized (jobs) {
boolean reschedule = TeslaSWTAccess.getJobEventReSchedule(event) && state;
Job job = event.getJob();
JobInfo info = getOrCreateJobInfo(job);
info.done(reschedule);
if (needDisable && isJoinEmpty()) {
disable();
}
if (!reschedule) {
JobInfo info;
if (reschedule) {
info = getOrCreateJobInfo(job);
info.done(reschedule);
event("rescheduled", info);
} else {
info = jobs.get(job);
if (info != null) {
info.done(reschedule);
event("done", info);
}
// If job is scheduled immediately after cancellation, its "done" event comes after "scheduled".
// We can't remove rescheduled jobs, so we check if it is "truly" done and gone.
// If it is not rescheduled in any sense, we no no longer need it.
if (job.getState() == Job.NONE) {
jobs.remove(job);
}
if (!IGNORED_BY_DEFAULT.contains(job.getClass().getName()))
debug("Job event - Done: " + info + ", rescheduled: " + reschedule);
}

}
}

Expand All @@ -286,7 +290,7 @@ public void scheduled(IJobChangeEvent event) {
}
JobInfo jobInfo = getOrCreateJobInfo(event.getJob());
jobInfo.scheduled(event.getDelay());
debug("Job event - Scheduled: " + jobInfo);
event("scheduled", jobInfo);
if (JobStatus.REQUIRED.equals(jobInfo.status)) {
if (event.getJob().belongsTo(TeslaSWTAccess.getDecoratorManagerFamily())) {
debug("Delay for " + jobInfo + " is nullified as it is a decoration job");
Expand All @@ -297,6 +301,7 @@ public void scheduled(IJobChangeEvent event) {
JobsManager.getInstance().nulifyTime(event.getJob());
}
}

}

protected JobStatus calcJobStatus(Job job, long delay) {
Expand Down Expand Up @@ -382,7 +387,9 @@ public UIJobCollector(IParameters parameters) {

@Override
public void sleeping(IJobChangeEvent event) {
getOrCreateJobInfo(event.getJob()).sleeping();
JobInfo info = getOrCreateJobInfo(event.getJob());
info.sleeping();
event("sleeping", info);
}

private static boolean isModal(Shell shell) {
Expand Down Expand Up @@ -453,6 +460,7 @@ private boolean logReturnResult(boolean result, List<Job> realJobs, List<Job> jo
long curTime = System.currentTimeMillis();
if (result) {
lastSuccessTime = curTime;
debug("No active jobs 1");
return result;
}
for (Job job : jobsInUI) {
Expand All @@ -464,6 +472,7 @@ private boolean logReturnResult(boolean result, List<Job> realJobs, List<Job> jo

if (lastSuccessTime == 0) {
lastSuccessTime = curTime;
debug("Result: " + result);
return result;
}
if (curTime - lastSuccessTime > TeslaLimits.getJobLoggingTimeout()) {
Expand Down Expand Up @@ -798,6 +807,7 @@ protected boolean isAsyncSupported() {
}

public void enable() {
debug("enable");
this.state = true;
this.needDisable = false;
// Add all current jobs to wait queue
Expand Down Expand Up @@ -831,6 +841,7 @@ private static Object getFamilyAutoBuild() {
public void disable() {
this.state = false;
this.needDisable = false;
debug("disable");
}

public void setNeedDisable() {
Expand Down Expand Up @@ -934,6 +945,7 @@ private boolean isJoinEmpty() {
public void clean() {
synchronized (jobs) {
jobs.clear();
debug("clean");
}
}

Expand All @@ -950,4 +962,21 @@ private static void report(String message) {
debug(message);
}
}

private static void check(String message, JobInfo job) {
if (shouldDebug(job.job)) {
debug(String.format("check: %11s: %s", message, job));
}
}


private static void event(String message, JobInfo job) {
if (shouldDebug(job.job)) {
debug(String.format("event: %11s: %s", message, job));
}
}

private static boolean shouldDebug(Job job) {
return DEBUG && !IGNORED_BY_DEFAULT.contains(job.getClass().getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ Require-Bundle: org.junit,
com.google.guava,
org.eclipse.rcptt.tesla.core;bundle-version="2.4.3",
org.eclipse.core.runtime;bundle-version="3.12.0",
org.eclipse.rcptt.tesla.jobs.aspects;bundle-version="2.5.5"
org.eclipse.rcptt.tesla.jobs.aspects;bundle-version="2.5.5",
org.eclipse.core.resources
Loading

0 comments on commit 42ec2e9

Please sign in to comment.