Giter Club home page Giter Club logo

Comments (10)

jadb avatar jadb commented on June 13, 2024

@Laykou - can you paste the content of the codecept binary please? Or just confirm if it uses some Cake\ classes or not.

I don't have Windows and haven't tested it on that (yet) but have a feeling it is not over-writing the binary.

from codeception.

Laykou avatar Laykou commented on June 13, 2024

Yes, I looked at it and this is my

\vendor\bin\codecept

#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd "../codeception/codeception"
BIN_TARGET="`pwd`/codecept"
cd "$SRC_DIR"
"$BIN_TARGET" "$@"

\vendor\bin\codecept.bat

@ECHO OFF
SET BIN_TARGET=%~dp0/../codeception/codeception/codecept
php "%BIN_TARGET%" %*

They look like original bin files from codeception. I saw that the file vendor\cakephp\codeception\src\Command\Bootstrap.php should update the codecept file, but even the content is wrong.....

Let me know if there is anything I can test for you on the windows. I tried it several times with the fresh composer update and always ended upt like thi.s

from codeception.

jadb avatar jadb commented on June 13, 2024

Ok. Thanks, this confirms what I had suspected. Looks like I have some work to do on Windows.

I am curious to know why your files are different from the ones in Codeception repo:

The Cake\Codeception\Console\Installer::postAutoloadDump() script will only edit codecept and only if it is in a format like the one I linked to on the Codeception repo.

Here's how the codecept file looks like on *NIX platforms (after being edited by the installer):

#!/usr/bin/env php
<?php
/**
 * Codeception CLI
 */

require_once dirname(__FILE__).'/autoload.php';

use Symfony\Component\Console\Application;

$app = new Application('Codeception', Codeception\Codecept::VERSION);
$app->add(new Cake\Codeception\Command\Build('build'));
$app->add(new Codeception\Command\Run('run'));
$app->add(new Codeception\Command\Console('console'));
$app->add(new Cake\Codeception\Command\Bootstrap('bootstrap'));
$app->add(new Codeception\Command\GenerateCept('generate:cept'));
$app->add(new Codeception\Command\GenerateCest('generate:cest'));
$app->add(new Codeception\Command\GenerateTest('generate:test'));
$app->add(new Codeception\Command\GeneratePhpUnit('generate:phpunit'));
$app->add(new Codeception\Command\GenerateSuite('generate:suite'));
$app->add(new Codeception\Command\GenerateHelper('generate:helper'));
$app->add(new Codeception\Command\GenerateScenarios('generate:scenarios'));
$app->add(new Codeception\Command\Clean('clean'));
$app->add(new Cake\Codeception\Command\GenerateGroup('generate:group'));
$app->add(new Codeception\Command\GeneratePageObject('generate:pageobject'));
$app->add(new Codeception\Command\GenerateStepObject('generate:stepobject'));
$app->run();

It won't work no matter how many times you will try since it just doesn't seem to autoload the same way on both platforms.

Maybe if we identify why it has a different codecept file, we'll get to the solution?

from codeception.

Laykou avatar Laykou commented on June 13, 2024

What line of script (what file) is responsible for copying the file into vendor\bin folder? I'm not that skilled with composer and how it works, but I learn quickly and I will do my best to find the solution :)

from codeception.

jadb avatar jadb commented on June 13, 2024

@Laykou - in the case of Codeception, I believe this part of Composer's code:

https://github.com/composer/composer/blob/master/src/Composer/Installer/LibraryInstaller.php#L186-L252

from codeception.

Laykou avatar Laykou commented on June 13, 2024

@jadb You got it! So that's how composer works: for windows it doesn't copy the file but only creates the proxy link to the real file:

// From the composer/LibraryInstaller.php
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
 file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
} else {
  symlink($relativeBin, $link)
}

// The proxy code function
 protected function generateUnixyProxyCode($bin, $link)
{
    $binPath = $this->filesystem->findShortestPath($link, $bin);
    return "#!/usr/bin/env sh\n".
        'SRC_DIR="`pwd`"'."\n".
        'cd "`dirname "$0"`"'."\n".
        'cd '.ProcessExecutor::escape(dirname($binPath))."\n".
        'BIN_TARGET="`pwd`/'.basename($binPath)."\"\n".
        'cd "$SRC_DIR"'."\n".
        '"$BIN_TARGET" "$@"'."\n";
}

Thats because on unix systems the symlink is created which is not available in the Windows. But then is the concept of ovewriting the file good? Because even in the Linux the original file codeception\codeception\codecept will be overwritten (because of the symlink). Am I wrong?

from codeception.

jadb avatar jadb commented on June 13, 2024

While it's not what I would have preferred, overwriting is the only solution for now.

Codeception, even though object-oriented, gives no other way but to either:

a- overwrite the codecept binary
b- create our own to instantiate the right classes for templates and folder structure

For now, I am content with this solution as when using codecept in a CakePHP application environment, rarely (if ever), will one need the original Codeception behavior.

from codeception.

Laykou avatar Laykou commented on June 13, 2024

What if the Installer.php would create the new content of the codecept file instead of just overwritting the namespaces?

from codeception.

jadb avatar jadb commented on June 13, 2024

@Laykou if that's the only way to resolve it for Windows, then yes. The original reasons I prefer modifying it instead of re-writing it was that maybe codeception upgrades, adds a new command but we don't need to customize that command, why have to update our code? If that makes any sense. So again, if it's the only solution, then it can be considered, otherwise, sticking to the way it is now is better IMO.

Also, it's good to add, that this is a temporary solution. I do have plans for this library to have a TestShell ala MigrationShell (for phinx) but no time yet. I'll be happy to help anyone who wants to do it though.

from codeception.

Laykou avatar Laykou commented on June 13, 2024

What if the codecept file was edited directly in the vendor/codeception/codeception? Technically there is no change on the Linux machine while making the Windows to do the same work.

Closing as there is a pull request.

from codeception.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.