Hi All
I am going crazy trying to resolve this easy task....
I have a log file that is created by xcode; and it contains the results of a build (either success or fail); what i am trying to achieve here is to get the result from the log, and check if is a pass or fail in an IF statement, so if it pass i write in anotehr log the build number, the date and the pass, otherwise i write in the log the fail and also send an email to myself.
the part that is causing me troubles is the extrapolation of the results and the comparison in the IF cycle:
-i tried to grep for the word FAIL in the logs, and save the results in a variable, but this does not work all the times, since i get from grep the entire line where the failure happens, while i just would like to have a bool that tells me "yes, the log has the word FAIL" or "no, the log has no FAIL" (in which case i consider it as pass).
-when i do the if statement; the result is not saved in another variable (it gets empty)
This is what i have so far in code:
checking if the logs has FAIL or PASS
IS_FAILED=`grep -r 'FAILED' ~/build_results.txt`
IF cycle
if [ -ne $IS_FAILED ]; then
RESULT='pass'
echo "is a pass"
else
RESULT='fail'
echo "is a fail"
fi
of course this won't work; and i don't get why the RESULT variable is empty, even if the echo prints the pass or fail; and i do not get how can i take just the "FAILED" string and compare it with "FAILED" in the IF cycle, instead of doing just a check to see if is empty or not (prone to errors)
is there any other way to achieve this result? I would really appreciate any suggestion.
Thanks