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

Fix mutations + math float tests #427

Merged
merged 1 commit into from
Nov 22, 2023
Merged

Conversation

veewee
Copy link
Collaborator

@veewee veewee commented Oct 22, 2023

This PR fixes:

  • Some mutation errors that are popping up
  • Float related errors in PHPunit that are bugging me on mac for some while

(See #425)

@veewee veewee marked this pull request as draft October 22, 2023 13:27
@coveralls
Copy link

coveralls commented Oct 22, 2023

Pull Request Test Coverage Report for Build 6605143985

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.999%

Totals Coverage Status
Change from base Build 6487837444: 0.0%
Covered Lines: 4152
Relevant Lines: 4194

💛 - Coveralls

@veewee veewee force-pushed the fix-test-issues branch 2 times, most recently from c4b736c to 04c4d89 Compare October 22, 2023 17:09
"@default": true,
"Break_": {
"ignore": [
"Psl\\Collection\\*Map::zip"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When the break gets transformed into a continue, it will produce the same output - yet slower.
So this is a false positive:

$u = $elements[0] ?? null;
if (null === $u) {
break;

},
"DecrementInteger": {
"ignore": [
"Psl\\DataStructure\\PriorityQueue::peek"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This fallback to ?? 0 will never occur since we first check the array size.
This is a false positive:

$priority = Math\max($keys) ?? 0;

I could solve it by doing an additional invariant check, but this seems slower for no real reason.

},
"FunctionCallRemoval": {
"ignore": [
"Psl\\Result\\Success::getThrowable"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This one is actually covered - yet infection doesnt seem to be able to link the test to the mutation.

See

public function testGetException(): void
{
$wrapper = new Success('hello');
$this->expectException(InvariantViolationException::class);
$this->expectExceptionMessage('No exception thrown');
$wrapper->getThrowable();
}

},
"LogicalNot": {
"ignore": [
"Psl\\Hash\\Context::update"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hard to cover this one:

// @codeCoverageIgnoreStart
/** @psalm-suppress ImpureFunctionCall - it creates a copy of the context, so we can consider it pure! */
if (!hash_update($internal_context, $data)) {
throw new Exception\RuntimeException('Unable to pump data into the active hashing context.');
}
// @codeCoverageIgnoreEnd

(the code coverage was already added as well.)

},
"MethodCallRemoval": {
"ignore": [
"Psl\\Iter\\Iterator::seek",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These functions were added to speed up the tests : it results in time-outs cause the iterator does not iterate anymore because it removes:

$this->next();

},
"Throw_": {
"ignore": [
"Psl\\File\\ReadHandle::__construct",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've added some tests as well - but didnt want to go into chmodding files and testing for readability / writability at this moment.

See

if (!Filesystem\exists($file)) {
throw Exception\NotFoundException::for($file);
}
if (!Filesystem\is_file($file)) {
throw Exception\NotFileException::for($file);
}
if (!Filesystem\is_readable($file)) {
throw Exception\NotReadableException::for($file);
}

}

public function provideData(): array
{
return [
[
-3.380515006246586,
5.0
5.0,
0.00000000000001
Copy link
Collaborator Author

@veewee veewee Oct 22, 2023

Choose a reason for hiding this comment

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

it is off by one on my system for some odd reason. Therefor I decided to check only the first 14 digits

@veewee veewee changed the title [WIP] Fix mutations + math float tests Fix mutations + math float tests Oct 22, 2023
@veewee veewee requested a review from azjezz October 22, 2023 17:22
@veewee veewee marked this pull request as ready for review October 22, 2023 17:22
@veewee veewee added Priority: High After critical issues are fixed, these should be dealt with before any further issues. Status: Accepted It's clear what the subject of the issue is about, and what the resolution should be. Type: Enhancement Most issues will probably ask for additions or changes. labels Nov 22, 2023
@veewee veewee added this to the 2.8.0 milestone Nov 22, 2023
@veewee veewee merged commit 5a444c5 into azjezz:next Nov 22, 2023
11 checks passed
renovate bot referenced this pull request in ben-challis/sql-migrations Nov 23, 2023
[![Mend Renovate logo
banner](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [azjezz/psl](https://togithub.com/azjezz/psl) | `2.7.0` -> `2.8.0` |
[![age](https://developer.mend.io/api/mc/badges/age/packagist/azjezz%2fpsl/2.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/azjezz%2fpsl/2.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/azjezz%2fpsl/2.7.0/2.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/azjezz%2fpsl/2.7.0/2.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>azjezz/psl (azjezz/psl)</summary>

### [`v2.8.0`](https://togithub.com/azjezz/psl/releases/tag/2.8.0):
Lenalee - 2.8.0

[Compare Source](https://togithub.com/azjezz/psl/compare/2.7.0...2.8.0)

#### What's Changed

- chore(ga): bump actions/checkout from 3 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[https://github.com/azjezz/psl/pull/420](https://togithub.com/azjezz/psl/pull/420)
- Fix mutations + math float tests by
[@&#8203;veewee](https://togithub.com/veewee) in
[https://github.com/azjezz/psl/pull/427](https://togithub.com/azjezz/psl/pull/427)
- Introduce a comparison component by
[@&#8203;veewee](https://togithub.com/veewee) in
[https://github.com/azjezz/psl/pull/428](https://togithub.com/azjezz/psl/pull/428)
- Indicate support for PHP 8.3 by
[@&#8203;gsteel](https://togithub.com/gsteel) in
[https://github.com/azjezz/psl/pull/430](https://togithub.com/azjezz/psl/pull/430)

#### New Contributors

- [@&#8203;gsteel](https://togithub.com/gsteel) made their first
contribution in
[https://github.com/azjezz/psl/pull/430](https://togithub.com/azjezz/psl/pull/430)

**Full Changelog**: azjezz/psl@2.7.0...2.8.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/ben-challis/sql-migrations).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy41OS44IiwidXBkYXRlZEluVmVyIjoiMzcuNTkuOCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High After critical issues are fixed, these should be dealt with before any further issues. Status: Accepted It's clear what the subject of the issue is about, and what the resolution should be. Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants