Skip to content

Commit

Permalink
Re-run failed behat scenarios to see if they pass on a retry
Browse files Browse the repository at this point in the history
And name the debug log differently for each behat run to ensure we can
keep logs for first and second attempt separate.
  • Loading branch information
acoulton committed Sep 15, 2022
1 parent 7e47235 commit 30cfa31
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/ChromeDriverDebugLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ChromeDriverDebugLogger

private $page_ready = NULL;

private string $log_file;

public static function instance(): ChromeDriverDebugLogger
{
static $instance;
Expand All @@ -23,9 +25,14 @@ public static function instance(): ChromeDriverDebugLogger
return $instance;
}

public function __construct()
private function __construct()
{

// Use a unique file so it survives --rerun
$now = new \DateTimeImmutable;
$this->log_file = sprintf(
PROJECT_BASE_DIR.'/build/logs/chromedriver-debug.%s.log.jsonl',
$now->format('Y-m-d-H-i-s-u')
);
}

public function logCommandSent(DevToolsConnection $connection, array $payload): void
Expand Down Expand Up @@ -105,7 +112,7 @@ private function writeLog(array $vars)
$last_logged = $now;

\file_put_contents(
PROJECT_BASE_DIR.'/build/logs/chromedriver-debug.log.jsonl',
$this->log_file,
JSON::encode($vars, FALSE)."\n",
FILE_APPEND
);
Expand Down

0 comments on commit 30cfa31

Please sign in to comment.