[xharness] Don't run into an infinite loop if failing to run sqlite3. (#515)

This commit is contained in:
Rolf Bjarne Kvinge 2016-08-01 16:36:14 +02:00 коммит произвёл GitHub
Родитель eed9b5d8d0
Коммит c30a2f52ce
1 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -158,6 +158,10 @@ namespace xharness
watch.Start (); watch.Start ();
do { do {
if (failure) {
log.WriteLine ("Failed to edit TCC.db, trying again in 1 second... ", (int) (tcc_edit_timeout - watch.Elapsed.TotalSeconds));
await Task.Delay (TimeSpan.FromSeconds (1));
}
failure = false; failure = false;
foreach (var bundle_identifier in bundle_identifiers) { foreach (var bundle_identifier in bundle_identifiers) {
var sql = new System.Text.StringBuilder (); var sql = new System.Text.StringBuilder ();
@ -169,16 +173,12 @@ namespace xharness
} }
sql.Append ("\""); sql.Append ("\"");
var rv = await ProcessHelper.ExecuteCommandAsync ("sqlite3", sql.ToString (), log, TimeSpan.FromSeconds (5)); var rv = await ProcessHelper.ExecuteCommandAsync ("sqlite3", sql.ToString (), log, TimeSpan.FromSeconds (5));
if (!rv.Succeeded) if (!rv.Succeeded) {
failure = true; failure = true;
if (failure) { break;
if (watch.Elapsed.TotalSeconds > tcc_edit_timeout)
break;
log.WriteLine ("Failed to edit TCC.db, trying again in 1 second... ", (int) (tcc_edit_timeout - watch.Elapsed.TotalSeconds));
await Task.Delay (TimeSpan.FromSeconds (1));
} }
} }
} while (failure); } while (failure && watch.Elapsed.TotalSeconds <= tcc_edit_timeout);
if (failure) { if (failure) {
log.WriteLine ("Failed to edit TCC.db, the test run might hang due to permission request dialogs"); log.WriteLine ("Failed to edit TCC.db, the test run might hang due to permission request dialogs");