Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant C3_CODECOVERAGE_MEDIATE_STORAGE can be used before it's defined #37

Open
CJDennis opened this issue Oct 30, 2017 · 2 comments
Open

Comments

@CJDennis
Copy link

If these lines fail:

try {
    \Codeception\Configuration::config($config_file);
} catch (\Exception $e) {
    __c3_error($e->getMessage());
}

due to \Codeception\Configuration not existing, then

        $errorLogFile = defined('C3_CODECOVERAGE_ERROR_LOG_FILE') ?
            C3_CODECOVERAGE_ERROR_LOG_FILE :
            C3_CODECOVERAGE_MEDIATE_STORAGE . DIRECTORY_SEPARATOR . 'error.txt';

is called before

    define('C3_CODECOVERAGE_MEDIATE_STORAGE', Codeception\Configuration::logDir() . 'c3tmp');
    define('C3_CODECOVERAGE_PROJECT_ROOT', Codeception\Configuration::projectDir());
    define('C3_CODECOVERAGE_TESTNAME', $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE']);

is run.

@bscheshirwork
Copy link

This like a true...

c3/c3.php

Lines 33 to 49 in 777e3b6

if (!function_exists('__c3_error')) {
function __c3_error($message)
{
$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";
}
if (!headers_sent()) {
header('X-Codeception-CodeCoverage-Error: ' . str_replace("\n", ' ', $message), true, 500);
}
setcookie('CODECEPTION_CODECOVERAGE_ERROR', $message);
}
}

is a function definition.

In this code

c3/c3.php

Lines 95 to 99 in 777e3b6

try {
\Codeception\Configuration::config($config_file);
} catch (\Exception $e) {
__c3_error($e->getMessage());
}

Function __c3_error is called before check

c3/c3.php

Line 101 in 777e3b6

if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {

@willpower232
Copy link

This is still an issue, I am using Laravel so I have made the following change:

$mediateStorage = defined('C3_CODECOVERAGE_MEDIATE_STORAGE') ?
    C3_CODECOVERAGE_MEDIATE_STORAGE :
    'storage';

$errorLogFile = defined('C3_CODECOVERAGE_ERROR_LOG_FILE') ?
    C3_CODECOVERAGE_ERROR_LOG_FILE :
    $mediateStorage . DIRECTORY_SEPARATOR . 'error.txt';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants