Skip to content

Commit

Permalink
Waits for result of coverage and prints message Fixes #716
Browse files Browse the repository at this point in the history
  • Loading branch information
idhugoid committed Aug 12, 2020
1 parent 1afdbcd commit 134c0be
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2047,9 +2047,10 @@ private void processWriteCoverage(DBGPCommand c) throws DBGPException,
{
file.mkdirs();
writeCoverage(interpreter, file);
StringBuilder hdr = new StringBuilder("success=\"1\"");
StringBuilder sb = new StringBuilder();
sb.append("Coverage written to: " + file.toURI().toASCIIString());
xcmdOvertureResponse(DBGPXCmdOvertureCommandType.WRITE_COMPLETE_COVERAGE, null, sb);
xcmdOvertureResponse(DBGPXCmdOvertureCommandType.WRITE_COMPLETE_COVERAGE, hdr, sb);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface IDbgpOvertureCommands

public void getCoverage(File file) throws DbgpException;

public void writeCompleteCoverage(File file) throws DbgpException;
public String writeCompleteCoverage(File file) throws DbgpException;

public void writeLog(String file) throws DbgpException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,27 @@
import org.overture.ide.debug.core.dbgp.IDbgpCommunicator;
import org.overture.ide.debug.core.dbgp.commands.IDbgpOvertureCommands;
import org.overture.ide.debug.core.dbgp.exceptions.DbgpException;
import org.overture.ide.debug.core.dbgp.internal.utils.DbgpXmlParser;
import org.overture.util.Base64;
import org.w3c.dom.Element;

public class DbgpOvertureCommands extends DbgpBaseCommands implements
public class DbgpOvertureCommands extends DbgpExtendedCommands implements
IDbgpOvertureCommands
{

private final static String OVERTURE_COMMAND = "xcmd_overture_cmd";

public DbgpOvertureCommands(IDbgpCommunicator communicator)
private String parseResponse(Element response)
{
if (DbgpXmlParser.parseSuccess(response))
{
return response.getTextContent();
}
return "";
}


public DbgpOvertureCommands(IDbgpCommunicator communicator) throws DbgpException
{
super(communicator);

Expand All @@ -53,13 +65,13 @@ public void getCoverage(File file) throws DbgpException

}

public void writeCompleteCoverage(File file) throws DbgpException
public String writeCompleteCoverage(File file) throws DbgpException
{
DbgpRequest request = createRequest(OVERTURE_COMMAND);
request.addOption("-c", "write_complete_coverage"); //$NON-NLS-1$
request.setData(file.toURI().toString());

send(request);
return parseResponse(communicate(request));
}

public void writeLog(String file) throws DbgpException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public synchronized void terminate()
private static final String RESPONSE_TAG = "response"; //$NON-NLS-1$
private static final String STREAM_TAG = "stream"; //$NON-NLS-1$
private static final String NOTIFY_TAG = "notify"; //$NON-NLS-1$
private static final String XCMD_OVERTURE_RESPONSE_TAG = "xcmd_overture_response"; //$NON-NLS-1$

private final ResponcePacketWaiter responseWaiter;
private final PacketWaiter notifyWaiter;
Expand Down Expand Up @@ -192,6 +193,10 @@ protected void addDocument(Document doc)
} else if (tag.equals(NOTIFY_TAG))
{
notifyWaiter.put(DbgpXmlPacketParser.parseNotifyPacket(element));
}else if (tag.equals(XCMD_OVERTURE_RESPONSE_TAG)) {
DbgpResponsePacket packet = DbgpXmlPacketParser.parseResponsePacket(element);

responseWaiter.put(packet);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,9 @@ public void handleCustomTerminationCommands(IDbgpSession dbgpSession)

coverageDir.mkdirs();

dbgpSession.getOvertureCommands().writeCompleteCoverage(coverageDir);
final String result = dbgpSession.getOvertureCommands().writeCompleteCoverage(coverageDir);
this.streamProxy.writeStdout("\n");
this.streamProxy.writeStdout(result);

for (IVdmSourceUnit source : this.vdmProject.getSpecFiles())
{
Expand Down

0 comments on commit 134c0be

Please sign in to comment.