[eggPlant Functional] filter Errors/Warnings from Test Run

How do I filter Errors and Warning from the Test Run?

The ScriptResults() function returns all the results for the current script (or optionally the name of a scripted passed in).

These results are stored in a list from the first run through to the last run. For this example we ONLY look at the latest run. We can easily filter the results by parsing the log file.


(* InterestingResults -- Returns an Array of Log Lines With Errors or Warnings for the latest run of the current script (or passed in script name) *)

params scriptName

set returnResults to empty

if scriptName is empty then
	put logfile of last item of ScriptResults() into latestLogFile
else
	put logfile of last item of ScriptResults(scriptName) into latestLogFile
end if

repeat with each line logLine of file latestLogFile
	put item 2 delimited by tab of logLine into Command
	if Command equals "logerror" or Command equals "logwarning" then insert logLine after returnResults
end repeat

return returnResults

Hi Jonathan,

I am new to Eggplant.

Tried to execute your script InterestingResults for getting only logwarning and logerrors out of the latest executed logfile, but unfortunately i couldnt get anything.

Can you please briefly explain what parametrs need to be passed to your scripts by considering Hello.script as my input file.

Best Regards,
Suhas

Here’s a script that uses the InterestingResults script to display the “interesting” log entries from the last run of a script called Hello.script:

put interestingResults("Hello") into interesting

repeat with each logEntry of interesting
	put logEntry split by tab into (time, command, img, message)
	put command & ": " & message & " (" & time & ")"
end repeat

Suppose the Hello script looks like this:

logWarning "About to change the RWI"
set the remoteWorkInterval to 1.1 -- this will make a log entry
log "This is unimportant -- not really interesting."
logWarning "This message is definitely interesting"
logError "This will cause the script to fail !"
log "Still running, but doomed"

Each line in this Hello script will produce an entry in the log file, but running the first script above will show only the interesting entries, like this:

logwarning: Just changed the RWI (2008-12-08 16:09:45.233 -0700)
logwarning: This message is definitely interesting (2008-12-08 16:09:45.235 -0700)
logerror: This will cause the script to fail (2008-12-08 16:09:45.235 -0700)

Thanks a Lot…

Regards,
Suhas