Skip to content

Commit

Permalink
Merge pull request #617 from tienvx/stop-running-task-or-recording-bu…
Browse files Browse the repository at this point in the history
…g-if-something-wrong-happen

Stop running task or recording bug if something wrong happen
  • Loading branch information
tienvx committed Apr 27, 2022
2 parents 827514b + 016d868 commit 1eda551
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
27 changes: 15 additions & 12 deletions src/Service/Bug/BugHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,21 @@ public function recordVideo(int $bugId): void
);
}

$this->bugRepository->startRecording($bug);
$bug->setDebug(true);
$this->stepsRunner->run(
$this->stepHelper->cloneAndResetSteps($bug->getSteps(), $bug->getTask()->getModelRevision()),
$bug,
function (Throwable $throwable) use ($bug) {
$bug->getVideo()->setErrorMessage(
$throwable->getMessage() !== $bug->getMessage() ? $throwable->getMessage() : null
);
}
);
$this->bugRepository->stopRecording($bug);
try {
$this->bugRepository->startRecording($bug);
$bug->setDebug(true);
$this->stepsRunner->run(
$this->stepHelper->cloneAndResetSteps($bug->getSteps(), $bug->getTask()->getModelRevision()),
$bug,
function (Throwable $throwable) use ($bug) {
$bug->getVideo()->setErrorMessage(
$throwable->getMessage() !== $bug->getMessage() ? $throwable->getMessage() : null
);
}
);
} finally {
$this->bugRepository->stopRecording($bug);
}
}

protected function getBug(int $bugId, string $action): BugInterface
Expand Down
24 changes: 13 additions & 11 deletions src/Service/Task/TaskHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ public function run(int $taskId): void
);
}

$this->taskRepository->startRunning($task);

$this->stepsRunner->run(
$this->generatorManager->getGenerator($this->config->getGenerator())->generate($task),
$task,
function (BugInterface $bug) use ($task) {
$task->addBug($bug);
}
);

$this->taskRepository->stopRunning($task);
try {
$this->taskRepository->startRunning($task);

$this->stepsRunner->run(
$this->generatorManager->getGenerator($this->config->getGenerator())->generate($task),
$task,
function (BugInterface $bug) use ($task) {
$task->addBug($bug);
}
);
} finally {
$this->taskRepository->stopRunning($task);
}
}
}

0 comments on commit 1eda551

Please sign in to comment.