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

Check the test framework adapter version before proceeding #1227

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

theofidry
Copy link
Member

@theofidry theofidry commented Mar 28, 2020

When instantiating an adapter, we are now checking the version used to warn the user of potential undesired behaviour if the version is not the expected one.

We are not interrupting the process to provide greater flexibility, but at the very least we will warn the user.


Outdated

I think it would be beneficial to provide an API for the test framework adapter to check that the test framework used is a valid version. Here is the example with this PoC with PHPUnit 5:

Screen Shot 2020-03-28 at 12 58 46

Screen Shot 2020-03-28 at 13 00 26

(verbose mode with the trace cut off)

src/TestFramework/AbstractTestFrameworkAdapter.php Outdated Show resolved Hide resolved
src/TestFramework/AbstractTestFrameworkAdapter.php Outdated Show resolved Hide resolved
src/TestFramework/AbstractTestFrameworkAdapter.php Outdated Show resolved Hide resolved
src/TestFramework/Factory.php Outdated Show resolved Hide resolved
src/TestFramework/Factory.php Outdated Show resolved Hide resolved
src/TestFramework/PhpUnit/Adapter/PhpUnitAdapter.php Outdated Show resolved Hide resolved
src/TestFramework/AbstractTestFrameworkAdapter.php Outdated Show resolved Hide resolved
src/TestFramework/Factory.php Outdated Show resolved Hide resolved
src/TestFramework/PhpUnit/Adapter/PhpUnitAdapter.php Outdated Show resolved Hide resolved
src/TestFramework/AbstractTestFrameworkAdapter.php Outdated Show resolved Hide resolved
src/TestFramework/Version/VersionParser.php Show resolved Hide resolved
@sanmai
Copy link
Member

sanmai commented Apr 1, 2020

This looks like a good idea on the one hand, but on the other hand I don't see a substantial evidence backing the need for such drastic measures.

Yes, there are couple of places where we have to track for older formats of coverage, but they can be (if not) thoroughly unit-tested, therefore there isn't a parsing problem per se.

@theofidry
Copy link
Member Author

@sanmai it's not only about the coverage reports (so far even supporting PHPUnit 5.x is still ok), but also the test framework instrumentation which includes:

  • retrieving the version
  • generating the command line for the tests
  • generating the command line for the tests for mutations
  • generating the config file (in some cases) for the mutations
  • parsing the output to know if the test failed or not

I'll be honest here: I'm not quite sure we are thorough in testing all of those either so I would not be surprised if we have a few non-working cases.


But again, since you are not sure (and me as well) what is the minimum PhpSpec version supported by Infection, and we don't even know criteria, I still think it shouldn't be on the TestFrameworkAdapter level, but as a separate interface

What minimum version we want to support means what minimum version we are willing to look at in case of a bug. So it also depends on your, personally I never used neither phpspec or codeception so I'm not keen to look at it even on recent versions at all.

But I admit if that was only based on that, I would be a lot more aggressive in the minimum version too. So maybe a solution is to go first for a permissive arbitrary version and we can always adapt it later, e.g:

After all, we don't want to break stuff for users. So one thing is say we are in theory pushing for phpspec 4.0.0 minimum and users come at us saying they would still like to have it work with phpspec 3.0.0, then we can lower that option and we know at least what minimum version to look at for our testing.

I would also like at some point us to be more through with the tests (see the full list above) and have this unit/integration tests at least for each major version, (e.g. if we support PHPUnit 5.x, then it means 5.x, 6.x, 7.x, 8.x, 9.x). Is that a lot? For sure, but also realistically between each major version something can break there.


@maks-rafalko provided we go for a minimum version for each major framework (and if you disagree on the specific versions proposed up there I propose 1.0.0 for them...), would you agree to add this to TestFrameworkAdapter?

@maks-rafalko
Copy link
Member

would you agree to add this to TestFrameworkAdapter?

sure, thanks, proposed versions sounds good to me

codeception 3.0.0 (https://packagist.org/packages/codeception/codeception#3.0.0): same – although is it compatible with it @maks-rafalko?

When I had the first implementation of codeception adapter, the minimum version with my fixes inside codeception/codeception was 3.1.1. But after that, we completely changed implementation and those fixes in 3.1.1 are no longer needed for Infection, so I think that 3.0.0 would work, however I had no chance to check it

@BackEndTea
Copy link
Member

BackEndTea commented Apr 12, 2020

This also fixes #197

@theofidry theofidry changed the title PoC: check the test framework adapter version before proceeding Check the test framework adapter version before proceeding May 6, 2020
Copy link
Member

@maks-rafalko maks-rafalko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 0.4.0 is a Pre-release. Is it expected?
  2. are you going to update phpspec / codeception?

@@ -127,11 +131,32 @@ public function getVersion(): string
return $this->version ?? $this->version = $this->retrieveVersion();
}

/**
* @throws UnsupportedTestFrameworkVersion
* TODO: add this to the interface upstream
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this TODO still relevant?

);
if ($matched === 0) {
throw new InvalidVersion(sprintf(
'Expected "%s" to be contain a valid SemVer (sub)string value.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably just to contain? Just see such construction for the first time :)

@maks-rafalko maks-rafalko added this to the 0.17.0 milestone May 7, 2020
@maks-rafalko maks-rafalko modified the milestones: 0.17.0, 0.18.0 Aug 16, 2020
@maks-rafalko maks-rafalko modified the milestones: 0.18.0, 0.19 Oct 17, 2020
@maks-rafalko maks-rafalko modified the milestones: 0.19, 0.20.0, 0.21.0 Oct 28, 2020
@maks-rafalko maks-rafalko removed this from the 0.21.0 milestone Feb 11, 2021
maks-rafalko added a commit to infection/abstract-testframework-adapter that referenced this pull request Aug 12, 2021
* we can't release new versions of `infection/abstract-testframework-adapter` since no test framework implemented `checkVersion()`, see infection/infection#1227
* this will be easier transition for test framework to be updated
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

Successfully merging this pull request may close these issues.

None yet

4 participants