CPack: Fix retry logic when calls to hdiutil fail

The long-standing sporadic failures of CPack tests on the Mac dashboards
are caused by an occasional problem running hdiutil. To compensate for
this, a retry loop was added in the code in a previous commit: a9fa71a4
... but the logic for breaking out of the retry loop was flawed, breaking
out of the loop (and not retrying) when the hdiutil command returns an
error instead of when it returns success.

This commit fixes the flawed logic, bumps up the number of retries from
4 to 10, and adds a half-second delay in between retries.

The delay is specifically added in case a virus checker or spotlight indexer
is temporarily causing the hdiutil failure by hanging onto a newly created
file longer than hdiutil expects it to.

As with all sporadically occurring issues, we'll never know if this is
really fixed all the way. But I'll be happy even if we can only get it to
happen just a bit less often.
This commit is contained in:
David Cole 2012-03-09 11:39:01 -05:00
parent c7bdef5b48
commit 05a76d53c0
2 changed files with 9 additions and 5 deletions

View File

@ -170,23 +170,25 @@ int cmCPackOSXX11Generator::PackageFiles()
<< "\" create -ov -format UDZO -srcfolder \""
<< diskImageDirectory.c_str()
<< "\" \"" << packageFileNames[0] << "\"";
int retVal = 1;
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Compress disk image using command: "
<< dmgCmd.str().c_str() << std::endl);
// since we get random dashboard failures with this one
// try running it more than once
int numTries = 4;
int retVal = 1;
int numTries = 10;
bool res = false;
while(numTries > 0)
{
res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output,
&retVal, 0,
this->GeneratorVerbose, 0);
if(res && retVal)
if ( res && !retVal )
{
numTries = -1;
break;
}
cmSystemTools::Delay(500);
numTries--;
}
if ( !res || retVal )

View File

@ -319,17 +319,19 @@ int cmCPackPackageMakerGenerator::PackageFiles()
<< "\" \"" << packageFileNames[0] << "\"";
std::string output;
int retVal = 1;
int numTries = 4;
int numTries = 10;
bool res = false;
while(numTries > 0)
{
res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output,
&retVal, 0, this->GeneratorVerbose,
0);
if(res && retVal)
if ( res && !retVal )
{
numTries = -1;
break;
}
cmSystemTools::Delay(500);
numTries--;
}
if ( !res || retVal )