Skip to content

Could not write error to log file #41

@petrabarus

Description

@petrabarus

While debugging for this issue Codeception/Codeception#4871, I keep getting message Could not write error to log file.
When I traced the cause, it's from here.

c3/c3.php

Lines 36 to 43 in c7348bb

$errorLogFile = defined('C3_CODECOVERAGE_ERROR_LOG_FILE') ?
C3_CODECOVERAGE_ERROR_LOG_FILE :
C3_CODECOVERAGE_MEDIATE_STORAGE . DIRECTORY_SEPARATOR . 'error.txt';
if (is_writable($errorLogFile)) {
file_put_contents($errorLogFile, $message);
} else {
$message = "Could not write error to log file ($errorLogFile), original message: $message";
}

Apparently the c3tmp directory is always emptied by __c3_clear() when the test is executed.

c3/c3.php

Lines 288 to 291 in c7348bb

if ($route === 'clear') {
__c3_clear();
return __c3_exit();
}

This cause problem because is_writable returns true if the file exists and is writable.

http://php.net/manual/en/function.is-writable.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions