TYPO3 / testing-framework

TYPO3 testing framework for core and extensions
GNU General Public License v2.0
53 stars 52 forks source link

Wrong test extension linked in consecutive tests #487

Open andreaswolf opened 1 year ago

andreaswolf commented 1 year ago

What are you trying to achieve?

I have the following setup:

What do you get instead?

When executing the test cases individually, everything works. When executing both in one run (with an empty var/tests/ folder), the test extension from the first test case is symlinked to both test systems.

How to reproduce the issue?

See above.

I have an example in the branch "broken-extension-linking" of my EXT:migrations: https://github.com/andreaswolf/typo3-ext-migrations/tree/broken-extension-linking

Additional information you would like to provide?

I think the problem is using static info inside \TYPO3\TestingFramework\Composer\ComposerPackageManager.

Specify some data of the environment

DanielSiepmann commented 7 months ago

We run into the same issue. They are not cleaned up between runs. The corresponding setting seems to be expected to be TestClass instead of test case specific.

Our workaround is to write and call this method after parent::setUp() (Mind the hardcoded path which needs adjustment):

    /**
     * The testing framework doesn't expect the list to change between tests in a single class.
     *
     * We therefore build our own setup to change extensions for each test.
     */
    private function setUpExtensionsToLoad(): void
    {
        $testExtensions = $this->testExtensionsToLoad;
        array_shift($testExtensions);

        foreach ($testExtensions as $testExtension) {
            $path = $this->getInstancePath() . '/typo3conf/ext/' . basename($testExtension);
            unlink($path);

            $source = __DIR__ . str_replace('typo3conf/ext/e2_core/Tests/Functional/Service', '', $testExtension);
            $success = @symlink($source, $path);
            if (!$success) {
                throw new Exception(
                    'Can not link the path ' . $source . ' to ' . $path,
                    1389969623
                );
            }
        }
    }
sbuerk commented 6 days ago

Test fixture extension must be unique regarding composer.json name and extension key.

Note that this would also fail later when moving to a composer based install using a central registration as multiple path extension could not share the same name extension key.

Consider that similar to have two or more local path folders for extensions/packages and having two extension in differnt folders with the same name (composer.json/extension-key).

I was never happy with the base name lookup but it was the only way to make the prior used typo3conf/ext/<extension_key> notation working in some way. It's quite nasty to get all running in some way and badly mangling here now again would not fix it when composer based functional test instance may be introcued at some point.

Better make test fixture extensions unique.

Forgot that I wanted to add a easy way to pre-register test-fixture extensions (which needs to be unique anyway) with some kind of path/path globs so they could be required simply by the unique composer package name then (like any extension/core extension required/required-dev in the root composer.json.

Thus not adding the resymlink approach because the "old" information would be stalled in the static package information cache anyway (clearing it would make the whole thing slower on executiong gathering all the information for each run again).

Will have a look again, but for now I would suggest to make them unique (a good thing anyway to avoid confusion).