mirror of
https://github.com/pestphp/pest.git
synced 2026-09-05 14:23:34 +02:00
Compare commits
229 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d187dd50a | |||
| 758778fe22 | |||
| 1b83b8fcda | |||
| ff4aba2ffa | |||
| feaac1ab7e | |||
| bbc6ada21e | |||
| 3927dbfcdf | |||
| 5dc49a71d6 | |||
| 1adb484d3f | |||
| aadf7e92a6 | |||
| df42b9ed7b | |||
| 632ae79c8b | |||
| ee2e97e932 | |||
| b561236325 | |||
| e685179b7e | |||
| ac8feafdcc | |||
| 87882a8561 | |||
| 77ef7e0df1 | |||
| 12100dd901 | |||
| 20c12d006e | |||
| 3aab02d2eb | |||
| 553aac65e6 | |||
| be49a3ce18 | |||
| 04c9d41895 | |||
| dfb7b870af | |||
| 37821e1108 | |||
| cd711a25d5 | |||
| eee60c9e11 | |||
| c40c8dbc24 | |||
| 2d93c9c373 | |||
| e5ab3af05b | |||
| 40b88b62ef | |||
| e3361bc321 | |||
| 92e76eb5ab | |||
| bd22f478b8 | |||
| eeaac34cf6 | |||
| b9b07d8983 | |||
| 6aa7d2f891 | |||
| 1c21a7647a | |||
| d649de1988 | |||
| 783ca4bcd6 | |||
| ba07497219 | |||
| 1ca021dea6 | |||
| 2fc75cfcf0 | |||
| 6cc48f63f8 | |||
| e0419d1328 | |||
| faa6988801 | |||
| c12247fafd | |||
| 29b4452443 | |||
| 1b168aba1c | |||
| 6aabd977cd | |||
| a882543c53 | |||
| c250b9da4f | |||
| 46bc3dc628 | |||
| d3ce498b8a | |||
| e1a4b98b71 | |||
| 9afbcd5c18 | |||
| 75593b6454 | |||
| 89590d6120 | |||
| fb0978c9bf | |||
| a3796daa42 | |||
| e3004db666 | |||
| 99cc4e0146 | |||
| a47e6f8fef | |||
| 536d79f765 | |||
| 65c0fbc528 | |||
| 9e4cf4b665 | |||
| 7bea819978 | |||
| 4280233b40 | |||
| d6db3a8a20 | |||
| 51c8ce4df6 | |||
| 5b8393b925 | |||
| e4d9b61fdf | |||
| e2d940cd53 | |||
| 380ccd30b4 | |||
| 31c200716d | |||
| 6add4da543 | |||
| 8ddcd3e853 | |||
| e3e178fd94 | |||
| 7b1ec9f003 | |||
| 1e48c5d473 | |||
| d00ec95dd9 | |||
| 89f3d6cb39 | |||
| a07a2e512a | |||
| 57eecb2b3d | |||
| 9f804dc954 | |||
| 7cbad4c589 | |||
| 5cae93b059 | |||
| df829ad19d | |||
| 635460653c | |||
| 1aa80dc398 | |||
| 8a14056111 | |||
| f247dd8e7b | |||
| 1c7c9754fd | |||
| 5f37939fda | |||
| 28305fcb7a | |||
| 5242803694 | |||
| 925935a7e8 | |||
| 460401c379 | |||
| 348b439172 | |||
| a4e77766c5 | |||
| 4a8c2d7d78 | |||
| 7d51601120 | |||
| 631bbe318b | |||
| 9b7c15d5b6 | |||
| 872796bd9b | |||
| c38d32ae86 | |||
| 6407c4f78f | |||
| 6e1bf63f6a | |||
| 1d3e8bb5dd | |||
| 3cc9b169e3 | |||
| c4911d046b | |||
| d0295f6168 | |||
| 21efbc3107 | |||
| e59b99cd73 | |||
| bf48e20880 | |||
| 53db68e005 | |||
| 34f1e9a7f2 | |||
| 57fd5ce042 | |||
| 3bcabfb63b | |||
| aa3a7c303a | |||
| 5c08a135f7 | |||
| 6e0e030d71 | |||
| b2c07561e7 | |||
| 97600b6f0b | |||
| 8a51f15d65 | |||
| a349f53964 | |||
| a725e774c0 | |||
| bed5e5b54a | |||
| 45b1d4ce20 | |||
| d106b70766 | |||
| 6ac6c1518e | |||
| fda515a17f | |||
| 0a97d3a288 | |||
| 3802fa80e6 | |||
| 5c3cbc14d2 | |||
| 6b9c768172 | |||
| 4a2fc179ae | |||
| b5bb2139dc | |||
| 07416a3c61 | |||
| 30b94e3034 | |||
| be34eecb2f | |||
| 5d9f95f8d4 | |||
| 48b70a03d5 | |||
| 4b8642b972 | |||
| 8711d51eac | |||
| 58dfb6da64 | |||
| d7735d1faa | |||
| 6b59166f3c | |||
| 3a26028d17 | |||
| 3c91bf4ad2 | |||
| 6a434be0f6 | |||
| f355b99bbf | |||
| 95a00341e9 | |||
| 466259646d | |||
| 00f8d56083 | |||
| ca2dca592d | |||
| 405d8d4406 | |||
| b944ee5841 | |||
| f4e22dcafe | |||
| 339c1e8cac | |||
| d4c7362132 | |||
| 81bfdbf8fe | |||
| f45cbf43c5 | |||
| b9088d23fb | |||
| 7250185423 | |||
| e457eb0e9c | |||
| 48357c6f30 | |||
| b46f051550 | |||
| 3d3c5d41ac | |||
| caabebf2a1 | |||
| 470a5833d4 | |||
| c1feefbb9e | |||
| e876dba8ba | |||
| d9c18f9c02 | |||
| 660b57b365 | |||
| 68527c996f | |||
| c6a42a2b28 | |||
| fcf5c27914 | |||
| 856a370032 | |||
| e24882c486 | |||
| 51fc380789 | |||
| f6609f4039 | |||
| 2941f9821f | |||
| ed399af43e | |||
| 0d66dc4322 | |||
| 7e4280bf83 | |||
| a5915b16ab | |||
| 1476b529a1 | |||
| 2892341c28 | |||
| 59e781e77b | |||
| 55a3394f8c | |||
| 0d99c33c4e | |||
| adc5aae6f8 | |||
| 980667e845 | |||
| 8c849c5f40 | |||
| 47f1fc2d94 | |||
| 9c8033d60c | |||
| 42d1092a9e | |||
| c7e32f5d33 | |||
| d379128cc4 | |||
| f09d6f2064 | |||
| 494cc6e2a4 | |||
| f52a455773 | |||
| 184f5d2742 | |||
| 1d81069a2a | |||
| 4b9bb77b54 | |||
| c440031e28 | |||
| bff44562a9 | |||
| 9ebb990f96 | |||
| cabff738f7 | |||
| 0746173a32 | |||
| 87db0b4847 | |||
| 6ba373a772 | |||
| 945d476409 | |||
| a8cf0fe2cb | |||
| 2ae072bb95 | |||
| 59d066950c | |||
| 0dd1aa72ef | |||
| 4e03cd3edb | |||
| eeab24e2bb | |||
| 9b64d5425a | |||
| 0acab1cbb4 | |||
| e616eab9fb | |||
| 7cbb1fcdb2 | |||
| cb5f6e1bd2 | |||
| 985dadd934 | |||
| 10aee6045c | |||
| 4ac14b2528 |
@@ -0,0 +1,13 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
**PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY, [SEE BELOW](#reporting-a-vulnerability).**
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
If you discover a security vulnerability in Pest, please report it privately using one of the following channels:
|
||||||
|
|
||||||
|
1. **GitHub Private Vulnerability Reporting** (preferred) — go to the repository's **Security** tab and click **"Report a vulnerability"**. This creates a private advisory visible only to maintainers and provides a structured workflow for triage, fix coordination, and CVE assignment.
|
||||||
|
|
||||||
|
2. **Email** — send the details to Nuno Maduro at **enunomaduro@gmail.com**.
|
||||||
|
|
||||||
|
All security vulnerabilities will be promptly addressed.
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
cooldown:
|
||||||
|
default-days: 5
|
||||||
|
groups:
|
||||||
|
github-actions:
|
||||||
|
patterns:
|
||||||
|
- "*"
|
||||||
@@ -11,6 +11,9 @@ concurrency:
|
|||||||
group: static-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
group: static-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
static:
|
static:
|
||||||
if: github.event_name != 'schedule' || github.repository == 'pestphp/pest'
|
if: github.event_name != 'schedule' || github.repository == 'pestphp/pest'
|
||||||
@@ -21,14 +24,14 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
dependency-version: [prefer-lowest, prefer-stable]
|
dependency-version: [prefer-stable]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
|
||||||
with:
|
with:
|
||||||
php-version: 8.3
|
php-version: 8.3
|
||||||
tools: composer:v2
|
tools: composer:v2
|
||||||
@@ -41,15 +44,17 @@ jobs:
|
|||||||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Cache Composer dependencies
|
- name: Cache Composer dependencies
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
key: static-php-8.3-${{ matrix.dependency-version }}-composer-${{ hashFiles('**/composer.json') }}
|
key: static-php-8.3-${{ matrix.dependency-version }}-composer-${{ hashFiles('**/composer.json', '**/composer.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
static-php-8.3-${{ matrix.dependency-version }}-composer-
|
static-php-8.3-${{ matrix.dependency-version }}-composer-
|
||||||
static-php-8.3-composer-
|
static-php-8.3-composer-
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
|
env:
|
||||||
|
COMPOSER_ROOT_VERSION: 4.x-dev
|
||||||
run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress --ansi
|
run: composer update --${{ matrix.dependency-version }} --no-interaction --no-progress --ansi
|
||||||
|
|
||||||
- name: Profanity Check
|
- name: Profanity Check
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ concurrency:
|
|||||||
group: tests-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
group: tests-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
if: github.event_name != 'schedule' || github.repository == 'pestphp/pest'
|
if: github.event_name != 'schedule' || github.repository == 'pestphp/pest'
|
||||||
@@ -32,10 +35,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php }}
|
php-version: ${{ matrix.php }}
|
||||||
tools: composer:v2
|
tools: composer:v2
|
||||||
@@ -48,10 +51,10 @@ jobs:
|
|||||||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Cache Composer dependencies
|
- name: Cache Composer dependencies
|
||||||
uses: actions/cache@v5
|
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v5
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
key: ${{ matrix.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles('**/composer.json') }}
|
key: ${{ matrix.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ hashFiles('**/composer.json', '**/composer.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ matrix.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-
|
${{ matrix.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-
|
||||||
${{ matrix.os }}-php-${{ matrix.php }}-composer-
|
${{ matrix.os }}-php-${{ matrix.php }}-composer-
|
||||||
@@ -63,6 +66,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Install PHP dependencies
|
- name: Install PHP dependencies
|
||||||
shell: bash
|
shell: bash
|
||||||
|
env:
|
||||||
|
COMPOSER_ROOT_VERSION: 4.x-dev
|
||||||
run: composer update --${{ matrix.dependency_version }} --no-interaction --no-progress --ansi --with="symfony/console:^${{ matrix.symfony }}"
|
run: composer update --${{ matrix.dependency_version }} --no-interaction --no-progress --ansi --with="symfony/console:^${{ matrix.symfony }}"
|
||||||
|
|
||||||
- name: Unit Tests
|
- name: Unit Tests
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="https://raw.githubusercontent.com/pestphp/art/master/v4/social.png" width="600" alt="PEST">
|
<img src="https://raw.githubusercontent.com/pestphp/art/master/v4/social.png" width="600" alt="PEST">
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/pestphp/pest/actions"><img alt="GitHub Workflow Status (master)" src="https://img.shields.io/github/actions/workflow/status/pestphp/pest/tests.yml?branch=4.x&label=Tests%204.x"></a>
|
<a href="https://github.com/pestphp/pest/actions"><img alt="GitHub Workflow Status (4.x)" src="https://img.shields.io/github/actions/workflow/status/pestphp/pest/tests.yml?branch=4.x&label=Tests%204.x"></a>
|
||||||
<a href="https://packagist.org/packages/pestphp/pest"><img alt="Total Downloads" src="https://img.shields.io/packagist/dt/pestphp/pest"></a>
|
<a href="https://packagist.org/packages/pestphp/pest"><img alt="Total Downloads" src="https://img.shields.io/packagist/dt/pestphp/pest"></a>
|
||||||
<a href="https://packagist.org/packages/pestphp/pest"><img alt="Latest Version" src="https://img.shields.io/packagist/v/pestphp/pest"></a>
|
<a href="https://packagist.org/packages/pestphp/pest"><img alt="Latest Version" src="https://img.shields.io/packagist/v/pestphp/pest"></a>
|
||||||
<a href="https://packagist.org/packages/pestphp/pest"><img alt="License" src="https://img.shields.io/packagist/l/pestphp/pest"></a>
|
<a href="https://packagist.org/packages/pestphp/pest"><img alt="License" src="https://img.shields.io/packagist/l/pestphp/pest"></a>
|
||||||
<a href="https://whyphp.dev"><img src="https://img.shields.io/badge/Why_PHP-in_2026-7A86E8?style=flat-square&labelColor=18181b" alt="Why PHP in 2026"></a>
|
<a href="https://whyphp.dev"><img src="https://img.shields.io/badge/Why_PHP-in_2026-7A86E8?style=flat-square&labelColor=18181b" alt="Why PHP in 2026"></a>
|
||||||
|
<a href="https://youtube.com/@nunomaduro?sub_confirmation=1"><img alt="YouTube Channel Subscribers" src="https://img.shields.io/youtube/channel/subscribers/UCO_hYZF2gb_CyG5sA7ArlGg?style=flat&label=youtube&color=brightgreen"></a>
|
||||||
</p>
|
</p>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ use Symfony\Component\Console\Output\ConsoleOutput;
|
|||||||
|
|
||||||
// Get $rootPath based on $autoloadPath
|
// Get $rootPath based on $autoloadPath
|
||||||
$rootPath = dirname($autoloadPath, 2);
|
$rootPath = dirname($autoloadPath, 2);
|
||||||
|
|
||||||
$input = new ArgvInput;
|
$input = new ArgvInput;
|
||||||
|
|
||||||
$testSuite = TestSuite::getInstance(
|
$testSuite = TestSuite::getInstance(
|
||||||
|
|||||||
+7
-6
@@ -19,18 +19,19 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.3.0",
|
"php": "^8.3.0",
|
||||||
"brianium/paratest": "^7.20.0",
|
"brianium/paratest": "^7.20.0",
|
||||||
"nunomaduro/collision": "^11.0.0",
|
"composer/xdebug-handler": "^3.0.5",
|
||||||
|
"nunomaduro/collision": "^8.9.5",
|
||||||
"nunomaduro/termwind": "^2.4.0",
|
"nunomaduro/termwind": "^2.4.0",
|
||||||
"pestphp/pest-plugin": "^4.0.0",
|
"pestphp/pest-plugin": "^4.0.0",
|
||||||
"pestphp/pest-plugin-arch": "^4.0.2",
|
"pestphp/pest-plugin-arch": "^4.0.2",
|
||||||
"pestphp/pest-plugin-mutate": "^4.0.1",
|
"pestphp/pest-plugin-mutate": "^4.0.1",
|
||||||
"pestphp/pest-plugin-profanity": "^4.2.1",
|
"pestphp/pest-plugin-profanity": "^4.2.1",
|
||||||
"phpunit/phpunit": "^12.5.16",
|
"phpunit/phpunit": "^12.5.33",
|
||||||
"symfony/process": "^7.4.8|^8.0.8"
|
"symfony/process": "^7.4.13|^8.1.0"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"filp/whoops": "<2.18.3",
|
"filp/whoops": "<2.18.3",
|
||||||
"phpunit/phpunit": ">12.5.16",
|
"phpunit/phpunit": ">12.5.33",
|
||||||
"sebastian/exporter": "<7.0.0",
|
"sebastian/exporter": "<7.0.0",
|
||||||
"webmozart/assert": "<1.11.0"
|
"webmozart/assert": "<1.11.0"
|
||||||
},
|
},
|
||||||
@@ -58,11 +59,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"mrpunyapal/peststan": "^0.2.5",
|
"mrpunyapal/peststan": "^0.2.12",
|
||||||
"pestphp/pest-dev-tools": "^4.1.0",
|
"pestphp/pest-dev-tools": "^4.1.0",
|
||||||
"pestphp/pest-plugin-browser": "^4.3.1",
|
"pestphp/pest-plugin-browser": "^4.3.1",
|
||||||
"pestphp/pest-plugin-type-coverage": "^4.0.4",
|
"pestphp/pest-plugin-type-coverage": "^4.0.4",
|
||||||
"psy/psysh": "^0.12.22"
|
"psy/psysh": "^0.12.24"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
|
|||||||
@@ -1,6 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BSD 3-Clause License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2001-2023, Sebastian Bergmann
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of PHPUnit.
|
* This file is part of PHPUnit.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,388 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* BSD 3-Clause License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2001-2023, Sebastian Bergmann
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived from
|
||||||
|
* this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of PHPUnit.
|
||||||
|
*
|
||||||
|
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace PHPUnit\Runner;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\DataProviderTestSuite;
|
||||||
|
use PHPUnit\Framework\Reorderable;
|
||||||
|
use PHPUnit\Framework\Test;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use PHPUnit\Framework\TestSuite;
|
||||||
|
use PHPUnit\Runner\ResultCache\NullResultCache;
|
||||||
|
use PHPUnit\Runner\ResultCache\ResultCache;
|
||||||
|
use PHPUnit\Runner\ResultCache\ResultCacheId;
|
||||||
|
|
||||||
|
use function array_diff;
|
||||||
|
use function array_merge;
|
||||||
|
use function array_reverse;
|
||||||
|
use function array_splice;
|
||||||
|
use function assert;
|
||||||
|
use function count;
|
||||||
|
use function in_array;
|
||||||
|
use function max;
|
||||||
|
use function shuffle;
|
||||||
|
use function usort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal This class is not covered by the backward compatibility promise for PHPUnit
|
||||||
|
*/
|
||||||
|
final class TestSuiteSorter
|
||||||
|
{
|
||||||
|
public const int ORDER_DEFAULT = 0;
|
||||||
|
|
||||||
|
public const int ORDER_RANDOMIZED = 1;
|
||||||
|
|
||||||
|
public const int ORDER_REVERSED = 2;
|
||||||
|
|
||||||
|
public const int ORDER_DEFECTS_FIRST = 3;
|
||||||
|
|
||||||
|
public const int ORDER_DURATION = 4;
|
||||||
|
|
||||||
|
public const int ORDER_SIZE = 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var non-empty-array<non-empty-string, positive-int>
|
||||||
|
*/
|
||||||
|
private const array SIZE_SORT_WEIGHT = [
|
||||||
|
'small' => 1,
|
||||||
|
'medium' => 2,
|
||||||
|
'large' => 3,
|
||||||
|
'unknown' => 4,
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array<string, int> Associative array of (string => DEFECT_SORT_WEIGHT) elements
|
||||||
|
*/
|
||||||
|
private array $defectSortOrder = [];
|
||||||
|
|
||||||
|
private readonly ResultCache $cache;
|
||||||
|
|
||||||
|
public function __construct(?ResultCache $cache = null)
|
||||||
|
{
|
||||||
|
$this->cache = $cache ?? new NullResultCache;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function reorderTestsInSuite(Test $suite, int $order, bool $resolveDependencies, int $orderDefects): void
|
||||||
|
{
|
||||||
|
$allowedOrders = [
|
||||||
|
self::ORDER_DEFAULT,
|
||||||
|
self::ORDER_REVERSED,
|
||||||
|
self::ORDER_RANDOMIZED,
|
||||||
|
self::ORDER_DURATION,
|
||||||
|
self::ORDER_SIZE,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (! in_array($order, $allowedOrders, true)) {
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
|
throw new InvalidOrderException;
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
}
|
||||||
|
|
||||||
|
$allowedOrderDefects = [
|
||||||
|
self::ORDER_DEFAULT,
|
||||||
|
self::ORDER_DEFECTS_FIRST,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (! in_array($orderDefects, $allowedOrderDefects, true)) {
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
|
throw new InvalidOrderException;
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($suite instanceof TestSuite) {
|
||||||
|
foreach ($suite as $_suite) {
|
||||||
|
$this->reorderTestsInSuite($_suite, $order, $resolveDependencies, $orderDefects);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($orderDefects === self::ORDER_DEFECTS_FIRST) {
|
||||||
|
$this->addSuiteToDefectSortOrder($suite);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->sort($suite, $order, $resolveDependencies, $orderDefects);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sort(TestSuite $suite, int $order, bool $resolveDependencies, int $orderDefects): void
|
||||||
|
{
|
||||||
|
if ($suite->tests() === []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($order === self::ORDER_REVERSED) {
|
||||||
|
$suite->setTests($this->reverse($suite->tests()));
|
||||||
|
} elseif ($order === self::ORDER_RANDOMIZED) {
|
||||||
|
$suite->setTests($this->randomize($suite->tests()));
|
||||||
|
} elseif ($order === self::ORDER_DURATION) {
|
||||||
|
$suite->setTests($this->sortByDuration($suite->tests()));
|
||||||
|
} elseif ($order === self::ORDER_SIZE) {
|
||||||
|
$suite->setTests($this->sortBySize($suite->tests()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($orderDefects === self::ORDER_DEFECTS_FIRST) {
|
||||||
|
$suite->setTests($this->sortDefectsFirst($suite->tests()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($resolveDependencies && ! ($suite instanceof DataProviderTestSuite)) {
|
||||||
|
$tests = $suite->tests();
|
||||||
|
|
||||||
|
/** @noinspection PhpParamsInspection */
|
||||||
|
/** @phpstan-ignore argument.type */
|
||||||
|
$suite->setTests($this->resolveDependencies($tests));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function addSuiteToDefectSortOrder(TestSuite $suite): void
|
||||||
|
{
|
||||||
|
$max = 0;
|
||||||
|
|
||||||
|
foreach ($suite->tests() as $test) {
|
||||||
|
assert($test instanceof Reorderable);
|
||||||
|
|
||||||
|
$sortId = $test->sortId();
|
||||||
|
|
||||||
|
if (! isset($this->defectSortOrder[$sortId])) {
|
||||||
|
$this->defectSortOrder[$sortId] = $this->cache->status(ResultCacheId::fromReorderable($test))->asInt();
|
||||||
|
$max = max($max, $this->defectSortOrder[$sortId]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->defectSortOrder[$suite->sortId()] = $max;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<Test> $tests
|
||||||
|
* @return list<Test>
|
||||||
|
*/
|
||||||
|
private function reverse(array $tests): array
|
||||||
|
{
|
||||||
|
return array_reverse($tests);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<Test> $tests
|
||||||
|
* @return list<Test>
|
||||||
|
*/
|
||||||
|
private function randomize(array $tests): array
|
||||||
|
{
|
||||||
|
shuffle($tests);
|
||||||
|
|
||||||
|
return $tests;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<Test> $tests
|
||||||
|
* @return list<Test>
|
||||||
|
*/
|
||||||
|
private function sortDefectsFirst(array $tests): array
|
||||||
|
{
|
||||||
|
usort(
|
||||||
|
$tests,
|
||||||
|
fn (Test $left, Test $right) => $this->cmpDefectPriorityAndTime($left, $right),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $tests;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<Test> $tests
|
||||||
|
* @return list<Test>
|
||||||
|
*/
|
||||||
|
private function sortByDuration(array $tests): array
|
||||||
|
{
|
||||||
|
usort(
|
||||||
|
$tests,
|
||||||
|
fn (Test $left, Test $right) => $this->cmpDuration($left, $right),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $tests;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<Test> $tests
|
||||||
|
* @return list<Test>
|
||||||
|
*/
|
||||||
|
private function sortBySize(array $tests): array
|
||||||
|
{
|
||||||
|
usort(
|
||||||
|
$tests,
|
||||||
|
fn (Test $left, Test $right) => $this->cmpSize($left, $right),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $tests;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comparator callback function to sort tests for "reach failure as fast as possible".
|
||||||
|
*
|
||||||
|
* 1. sort tests by defect weight defined in self::DEFECT_SORT_WEIGHT
|
||||||
|
* 2. when tests are equally defective, sort the fastest to the front
|
||||||
|
* 3. do not reorder successful tests
|
||||||
|
*/
|
||||||
|
private function cmpDefectPriorityAndTime(Test $a, Test $b): int
|
||||||
|
{
|
||||||
|
assert($a instanceof Reorderable);
|
||||||
|
assert($b instanceof Reorderable);
|
||||||
|
|
||||||
|
$priorityA = $this->defectSortOrder[$a->sortId()] ?? 0;
|
||||||
|
$priorityB = $this->defectSortOrder[$b->sortId()] ?? 0;
|
||||||
|
|
||||||
|
if ($priorityA !== $priorityB) {
|
||||||
|
// Sort defect weight descending
|
||||||
|
return $priorityB <=> $priorityA;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($priorityA > 0 || $priorityB > 0) {
|
||||||
|
return $this->cmpDuration($a, $b);
|
||||||
|
}
|
||||||
|
|
||||||
|
// do not change execution order
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares test duration for sorting tests by duration ascending.
|
||||||
|
*/
|
||||||
|
private function cmpDuration(Test $a, Test $b): int
|
||||||
|
{
|
||||||
|
if (! ($a instanceof Reorderable && $b instanceof Reorderable)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->cache->time(ResultCacheId::fromReorderable($a)) <=> $this->cache->time(ResultCacheId::fromReorderable($b));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares test size for sorting tests small->medium->large->unknown.
|
||||||
|
*/
|
||||||
|
private function cmpSize(Test $a, Test $b): int
|
||||||
|
{
|
||||||
|
$sizeA = ($a instanceof TestCase || $a instanceof DataProviderTestSuite)
|
||||||
|
? $a->size()->asString()
|
||||||
|
: 'unknown';
|
||||||
|
$sizeB = ($b instanceof TestCase || $b instanceof DataProviderTestSuite)
|
||||||
|
? $b->size()->asString()
|
||||||
|
: 'unknown';
|
||||||
|
|
||||||
|
return self::SIZE_SORT_WEIGHT[$sizeA] <=> self::SIZE_SORT_WEIGHT[$sizeB];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reorder Tests within a TestCase in such a way as to resolve as many dependencies as possible.
|
||||||
|
* The algorithm will leave the tests in original running order when it can.
|
||||||
|
* For more details see the documentation for test dependencies.
|
||||||
|
*
|
||||||
|
* Short description of algorithm:
|
||||||
|
* 1. Pick the next Test from remaining tests to be checked for dependencies.
|
||||||
|
* 2. If the test has no dependencies: mark done, start again from the top
|
||||||
|
* 3. If the test has dependencies but none left to do: mark done, start again from the top
|
||||||
|
* 4. When we reach the end add any leftover tests to the end. These will be marked 'skipped' during execution.
|
||||||
|
*
|
||||||
|
* @param array<TestCase> $tests
|
||||||
|
* @return array<TestCase>
|
||||||
|
*/
|
||||||
|
private function resolveDependencies(array $tests): array
|
||||||
|
{
|
||||||
|
// Pest: Fast-path. If no test in this suite declares dependencies, the
|
||||||
|
// original O(N^2) algorithm is wasted work — it would splice each test
|
||||||
|
// one-by-one back into the same order. The check deliberately walks
|
||||||
|
// TestCase instances directly instead of calling TestSuite::requires(),
|
||||||
|
// because the latter lazily builds TestSuite::provides() via
|
||||||
|
// ExecutionOrderDependency::mergeUnique, which is O(N^2) in the total
|
||||||
|
// number of tests. With thousands of tests that single call alone can
|
||||||
|
// burn several seconds before the sort even begins. Reading the
|
||||||
|
// cached TestCase::$dependencies property stays O(N) and costs nothing
|
||||||
|
// when no test uses `->depends()` / PHPUnit `@depends`.
|
||||||
|
if (! $this->anyTestHasDependencies($tests)) {
|
||||||
|
return $tests;
|
||||||
|
}
|
||||||
|
|
||||||
|
$newTestOrder = [];
|
||||||
|
$i = 0;
|
||||||
|
$provided = [];
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (array_diff($tests[$i]->requires(), $provided) === []) {
|
||||||
|
$provided = array_merge($provided, $tests[$i]->provides());
|
||||||
|
$newTestOrder = array_merge($newTestOrder, array_splice($tests, $i, 1));
|
||||||
|
$i = 0;
|
||||||
|
} else {
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
} while ($tests !== [] && ($i < count($tests)));
|
||||||
|
|
||||||
|
return array_merge($newTestOrder, $tests);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cheaply determines whether any test in the tree declares @depends.
|
||||||
|
*
|
||||||
|
* Walks `TestSuite` containers recursively and inspects each `TestCase`
|
||||||
|
* directly so it never triggers `TestSuite::provides()`, which is O(N^2)
|
||||||
|
* in the total number of aggregated tests.
|
||||||
|
*
|
||||||
|
* @param iterable<Test> $tests
|
||||||
|
*/
|
||||||
|
private function anyTestHasDependencies(iterable $tests): bool
|
||||||
|
{
|
||||||
|
foreach ($tests as $test) {
|
||||||
|
if ($test instanceof TestSuite) {
|
||||||
|
if ($this->anyTestHasDependencies($test->tests())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($test instanceof TestCase && $test->requires() !== []) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,10 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
use Rector\CodingStyle\Rector\ArrowFunction\ArrowFunctionDelegatingCallToFirstClassCallableRector;
|
use Rector\CodingStyle\Rector\ArrowFunction\ArrowFunctionDelegatingCallToFirstClassCallableRector;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
|
use Rector\DeadCode\Rector\ClassMethod\RemoveDuplicatedReturnSelfDocblockRector;
|
||||||
use Rector\DeadCode\Rector\ClassMethod\RemoveParentDelegatingConstructorRector;
|
use Rector\DeadCode\Rector\ClassMethod\RemoveParentDelegatingConstructorRector;
|
||||||
|
use Rector\DeadCode\Rector\ClassMethod\RemoveReturnTagIncompatibleWithNativeTypeRector;
|
||||||
|
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessUnionReturnDocblockRector;
|
||||||
use Rector\TypeDeclaration\Rector\ClassMethod\NarrowObjectReturnTypeRector;
|
use Rector\TypeDeclaration\Rector\ClassMethod\NarrowObjectReturnTypeRector;
|
||||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
|
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
|
||||||
|
|
||||||
@@ -18,6 +21,11 @@ return RectorConfig::configure()
|
|||||||
ArrowFunctionDelegatingCallToFirstClassCallableRector::class,
|
ArrowFunctionDelegatingCallToFirstClassCallableRector::class,
|
||||||
NarrowObjectReturnTypeRector::class,
|
NarrowObjectReturnTypeRector::class,
|
||||||
RemoveParentDelegatingConstructorRector::class,
|
RemoveParentDelegatingConstructorRector::class,
|
||||||
|
RemoveDuplicatedReturnSelfDocblockRector::class,
|
||||||
|
RemoveUselessUnionReturnDocblockRector::class,
|
||||||
|
RemoveReturnTagIncompatibleWithNativeTypeRector::class => [
|
||||||
|
__DIR__.'/src/Expectations/HigherOrderExpectation.php',
|
||||||
|
],
|
||||||
])
|
])
|
||||||
->withPreparedSets(
|
->withPreparedSets(
|
||||||
deadCode: true,
|
deadCode: true,
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
[$bgBadgeColor, $bgBadgeText] = match ($type) {
|
[$bgBadgeColor, $bgBadgeText] = match ($type) {
|
||||||
'INFO' => ['blue', 'INFO'],
|
'INFO' => ['blue', 'INFO'],
|
||||||
'ERROR' => ['red', 'ERROR'],
|
'ERROR' => ['red', 'ERROR'],
|
||||||
|
'WARN' => ['yellow', 'WARN'],
|
||||||
|
'SUCCESS' => ['green', 'SUCCESS'],
|
||||||
};
|
};
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -176,9 +176,5 @@ final class Laravel extends AbstractPreset
|
|||||||
->toImplement('Illuminate\Contracts\Container\ContextualAttribute')
|
->toImplement('Illuminate\Contracts\Container\ContextualAttribute')
|
||||||
->toHaveAttribute('Attribute')
|
->toHaveAttribute('Attribute')
|
||||||
->toHaveMethod('resolve');
|
->toHaveMethod('resolve');
|
||||||
|
|
||||||
$this->expectations[] = expect('App\Rules')
|
|
||||||
->classes()
|
|
||||||
->toImplement('Illuminate\Contracts\Validation\ValidationRule');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ final class BootOverrides implements Bootstrapper
|
|||||||
'Runner/Filter/NameFilterIterator.php',
|
'Runner/Filter/NameFilterIterator.php',
|
||||||
'Runner/ResultCache/DefaultResultCache.php',
|
'Runner/ResultCache/DefaultResultCache.php',
|
||||||
'Runner/TestSuiteLoader.php',
|
'Runner/TestSuiteLoader.php',
|
||||||
|
'Runner/TestSuiteSorter.php',
|
||||||
'TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php',
|
'TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php',
|
||||||
'TextUI/Output/Default/ProgressPrinter/Subscriber/TestSkippedSubscriber.php',
|
'TextUI/Output/Default/ProgressPrinter/Subscriber/TestSkippedSubscriber.php',
|
||||||
'TextUI/TestSuiteFilterProcessor.php',
|
'TextUI/TestSuiteFilterProcessor.php',
|
||||||
|
|||||||
@@ -368,6 +368,11 @@ trait Testable
|
|||||||
|
|
||||||
if ($hasOutputExpectation) {
|
if ($hasOutputExpectation) {
|
||||||
ob_clean();
|
ob_clean();
|
||||||
|
|
||||||
|
Closure::bind(function (): void {
|
||||||
|
$this->outputExpectedString = null;
|
||||||
|
$this->outputExpectedRegex = null;
|
||||||
|
}, $this, TestCase::class)();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setUp();
|
$this->setUp();
|
||||||
|
|||||||
@@ -59,12 +59,15 @@ final class Project
|
|||||||
/**
|
/**
|
||||||
* Sets the test project to GitLab.
|
* Sets the test project to GitLab.
|
||||||
*/
|
*/
|
||||||
public function gitlab(string $project): self
|
public function gitlab(string $project, string $hostname = 'gitlab.com'): self
|
||||||
{
|
{
|
||||||
$this->issues = "https://gitlab.com/{$project}/issues/%s";
|
// Simple way to ensure only the host is used
|
||||||
$this->prs = "https://gitlab.com/{$project}/merge_requests/%s";
|
$hostname = parse_url($hostname, PHP_URL_HOST) ?? $hostname;
|
||||||
|
|
||||||
$this->assignees = 'https://gitlab.com/%s';
|
$this->issues = "https://{$hostname}/{$project}/-/work_items/%s";
|
||||||
|
$this->prs = "https://{$hostname}/{$project}/-/merge_requests/%s";
|
||||||
|
|
||||||
|
$this->assignees = "https://{$hostname}/%s";
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Pest\Exceptions;
|
||||||
|
|
||||||
|
use RuntimeException;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
final class DatasetProviderError extends RuntimeException
|
||||||
|
{
|
||||||
|
public function __construct(Throwable $previous)
|
||||||
|
{
|
||||||
|
parent::__construct($previous->getMessage(), (int) $previous->getCode(), $previous);
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
-5
@@ -112,7 +112,7 @@ final class Expectation
|
|||||||
if (function_exists('dump')) {
|
if (function_exists('dump')) {
|
||||||
dump($this->value, ...$arguments);
|
dump($this->value, ...$arguments);
|
||||||
} else {
|
} else {
|
||||||
var_dump($this->value);
|
var_dump($this->value, ...$arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -120,16 +120,22 @@ final class Expectation
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump the expectation value and end the script.
|
* Dump the expectation value and end the script.
|
||||||
*
|
|
||||||
* @return never
|
|
||||||
*/
|
*/
|
||||||
public function dd(mixed ...$arguments): void
|
public function dd(mixed ...$arguments): never
|
||||||
{
|
{
|
||||||
if (function_exists('dd')) {
|
if (function_exists('dd')) {
|
||||||
dd($this->value, ...$arguments);
|
dd($this->value, ...$arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
var_dump($this->value);
|
if (getenv('PARATEST') !== false || isset($_SERVER['COLLISION_PRINTER'])) {
|
||||||
|
ob_start();
|
||||||
|
var_dump($this->value, ...$arguments);
|
||||||
|
$output = ob_get_clean();
|
||||||
|
|
||||||
|
throw new ExpectationFailedException($output);
|
||||||
|
}
|
||||||
|
|
||||||
|
var_dump($this->value, ...$arguments);
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ final class TestCaseFactory
|
|||||||
$filename = (string) preg_replace_callback('~^(?P<drive>[a-z]+:\\\)~i', static fn (array $match): string => strtolower($match['drive']), $filename);
|
$filename = (string) preg_replace_callback('~^(?P<drive>[a-z]+:\\\)~i', static fn (array $match): string => strtolower($match['drive']), $filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
$filename = str_replace('\\\\', '\\', addslashes((string) realpath($filename)));
|
$realpath = (string) realpath($filename);
|
||||||
|
$filename = str_replace('\\\\', '\\', addslashes($realpath));
|
||||||
$rootPath = TestSuite::getInstance()->rootPath;
|
$rootPath = TestSuite::getInstance()->rootPath;
|
||||||
$relativePath = str_replace($rootPath.DIRECTORY_SEPARATOR, '', $filename);
|
$relativePath = str_replace($rootPath.DIRECTORY_SEPARATOR, '', $filename);
|
||||||
|
|
||||||
@@ -149,6 +150,8 @@ final class TestCaseFactory
|
|||||||
|
|
||||||
$attributesCode = Attributes::code($this->attributes);
|
$attributesCode = Attributes::code($this->attributes);
|
||||||
|
|
||||||
|
$filenameLiteral = var_export($realpath, true);
|
||||||
|
|
||||||
$methodsCode = implode('', array_map(
|
$methodsCode = implode('', array_map(
|
||||||
fn (TestCaseMethodFactory $methodFactory): string => $methodFactory->buildForEvaluation(),
|
fn (TestCaseMethodFactory $methodFactory): string => $methodFactory->buildForEvaluation(),
|
||||||
$methods
|
$methods
|
||||||
@@ -158,6 +161,7 @@ final class TestCaseFactory
|
|||||||
$classCode = <<<PHP
|
$classCode = <<<PHP
|
||||||
namespace $namespace;
|
namespace $namespace;
|
||||||
|
|
||||||
|
use Pest\Exceptions\DatasetProviderError as __PestDatasetProviderError;
|
||||||
use Pest\Repositories\DatasetsRepository as __PestDatasets;
|
use Pest\Repositories\DatasetsRepository as __PestDatasets;
|
||||||
use Pest\TestSuite as __PestTestSuite;
|
use Pest\TestSuite as __PestTestSuite;
|
||||||
|
|
||||||
@@ -166,7 +170,7 @@ final class TestCaseFactory
|
|||||||
final class $className extends $baseClass implements $hasPrintableTestCaseClassFQN {
|
final class $className extends $baseClass implements $hasPrintableTestCaseClassFQN {
|
||||||
$traitsCode
|
$traitsCode
|
||||||
|
|
||||||
private static \$__filename = '$filename';
|
public static \$__filename = $filenameLiteral;
|
||||||
|
|
||||||
$methodsCode
|
$methodsCode
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,6 +235,10 @@ final class TestCaseMethodFactory
|
|||||||
$attributesCode
|
$attributesCode
|
||||||
public function $methodName(...\$arguments)
|
public function $methodName(...\$arguments)
|
||||||
{
|
{
|
||||||
|
if (count(\$arguments) === 1 && \$arguments[0] instanceof __PestDatasetProviderError) {
|
||||||
|
throw \$arguments[0]->getPrevious() ?? \$arguments[0];
|
||||||
|
}
|
||||||
|
|
||||||
return \$this->__runTest(
|
return \$this->__runTest(
|
||||||
\$this->__test,
|
\$this->__test,
|
||||||
...\$arguments,
|
...\$arguments,
|
||||||
@@ -261,7 +265,11 @@ final class TestCaseMethodFactory
|
|||||||
|
|
||||||
public static function $dataProviderName()
|
public static function $dataProviderName()
|
||||||
{
|
{
|
||||||
return __PestDatasets::get(self::\$__filename, "$methodName");
|
try {
|
||||||
|
return __PestDatasets::get(self::\$__filename, "$methodName");
|
||||||
|
} catch (\Throwable \$throwable) {
|
||||||
|
return [[new __PestDatasetProviderError(\$throwable)]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EOF;
|
EOF;
|
||||||
|
|||||||
+19
-9
@@ -27,8 +27,13 @@ use Whoops\Exception\Inspector;
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final readonly class Kernel
|
final class Kernel
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Either the kernel is terminated or not.
|
||||||
|
*/
|
||||||
|
private bool $terminated = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Kernel bootstrappers.
|
* The Kernel bootstrappers.
|
||||||
*
|
*
|
||||||
@@ -46,12 +51,7 @@ final readonly class Kernel
|
|||||||
/**
|
/**
|
||||||
* Creates a new Kernel instance.
|
* Creates a new Kernel instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(private readonly Application $application, private readonly OutputInterface $output) {}
|
||||||
private Application $application,
|
|
||||||
private OutputInterface $output,
|
|
||||||
) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boots the Kernel.
|
* Boots the Kernel.
|
||||||
@@ -112,9 +112,13 @@ final readonly class Kernel
|
|||||||
$configuration = Registry::get();
|
$configuration = Registry::get();
|
||||||
$result = Facade::result();
|
$result = Facade::result();
|
||||||
|
|
||||||
return CallsAddsOutput::execute(
|
$result = CallsAddsOutput::execute(
|
||||||
Result::exitCode($configuration, $result),
|
Result::exitCode($configuration, $result),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->terminate();
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,6 +126,12 @@ final readonly class Kernel
|
|||||||
*/
|
*/
|
||||||
public function terminate(): void
|
public function terminate(): void
|
||||||
{
|
{
|
||||||
|
if ($this->terminated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->terminated = true;
|
||||||
|
|
||||||
$preBufferOutput = Container::getInstance()->get(KernelDump::class);
|
$preBufferOutput = Container::getInstance()->get(KernelDump::class);
|
||||||
|
|
||||||
assert($preBufferOutput instanceof KernelDump);
|
assert($preBufferOutput instanceof KernelDump);
|
||||||
@@ -139,7 +149,7 @@ final readonly class Kernel
|
|||||||
$this->terminate();
|
$this->terminate();
|
||||||
|
|
||||||
if (is_array($error = error_get_last())) {
|
if (is_array($error = error_get_last())) {
|
||||||
if (! in_array($error['type'], [E_ERROR, E_CORE_ERROR], true)) {
|
if (! in_array($error['type'], [E_ERROR, E_COMPILE_ERROR, E_CORE_ERROR], true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Pest;
|
namespace Pest;
|
||||||
|
|
||||||
|
use Laravel\Pao\Execution;
|
||||||
use Pest\Support\View;
|
use Pest\Support\View;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
|
||||||
@@ -28,6 +29,10 @@ final class KernelDump
|
|||||||
*/
|
*/
|
||||||
public function enable(): void
|
public function enable(): void
|
||||||
{
|
{
|
||||||
|
if (class_exists(Execution::class) && Execution::running()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ob_start(function (string $message): string {
|
ob_start(function (string $message): string {
|
||||||
$this->buffer .= $message;
|
$this->buffer .= $message;
|
||||||
|
|
||||||
@@ -68,6 +73,10 @@ final class KernelDump
|
|||||||
|
|
||||||
$type = 'INFO';
|
$type = 'INFO';
|
||||||
|
|
||||||
|
if (is_array($error = error_get_last()) && in_array($error['type'], [E_ERROR, E_COMPILE_ERROR, E_CORE_ERROR], true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->isInternalError($this->buffer)) {
|
if ($this->isInternalError($this->buffer)) {
|
||||||
$type = 'ERROR';
|
$type = 'ERROR';
|
||||||
$this->buffer = str_replace(
|
$this->buffer = str_replace(
|
||||||
@@ -107,7 +116,6 @@ final class KernelDump
|
|||||||
*/
|
*/
|
||||||
private function isInternalError(string $output): bool
|
private function isInternalError(string $output): bool
|
||||||
{
|
{
|
||||||
return str_contains($output, 'An error occurred inside PHPUnit.')
|
return str_contains($output, 'An error occurred inside PHPUnit.');
|
||||||
|| str_contains($output, 'Fatal error');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ use PHPUnit\Event\Code\Test;
|
|||||||
use PHPUnit\Event\Code\TestMethod;
|
use PHPUnit\Event\Code\TestMethod;
|
||||||
use PHPUnit\Event\Code\Throwable;
|
use PHPUnit\Event\Code\Throwable;
|
||||||
use PHPUnit\Event\Test\AfterLastTestMethodErrored;
|
use PHPUnit\Event\Test\AfterLastTestMethodErrored;
|
||||||
|
use PHPUnit\Event\Test\AfterLastTestMethodFailed;
|
||||||
use PHPUnit\Event\Test\BeforeFirstTestMethodErrored;
|
use PHPUnit\Event\Test\BeforeFirstTestMethodErrored;
|
||||||
|
use PHPUnit\Event\Test\BeforeFirstTestMethodFailed;
|
||||||
use PHPUnit\Event\Test\ConsideredRisky;
|
use PHPUnit\Event\Test\ConsideredRisky;
|
||||||
use PHPUnit\Event\Test\Errored;
|
use PHPUnit\Event\Test\Errored;
|
||||||
use PHPUnit\Event\Test\Failed;
|
use PHPUnit\Event\Test\Failed;
|
||||||
@@ -255,9 +257,11 @@ final readonly class Converter
|
|||||||
$numberOfNotPassedTests = count(
|
$numberOfNotPassedTests = count(
|
||||||
array_unique(
|
array_unique(
|
||||||
array_map(
|
array_map(
|
||||||
function (AfterLastTestMethodErrored|BeforeFirstTestMethodErrored|Errored|Failed|Skipped|ConsideredRisky|MarkedIncomplete $event): string {
|
function (AfterLastTestMethodErrored|AfterLastTestMethodFailed|BeforeFirstTestMethodErrored|BeforeFirstTestMethodFailed|Errored|Failed|Skipped|ConsideredRisky|MarkedIncomplete $event): string {
|
||||||
if ($event instanceof BeforeFirstTestMethodErrored
|
if ($event instanceof BeforeFirstTestMethodErrored
|
||||||
|| $event instanceof AfterLastTestMethodErrored) {
|
|| $event instanceof AfterLastTestMethodErrored
|
||||||
|
|| $event instanceof BeforeFirstTestMethodFailed
|
||||||
|
|| $event instanceof AfterLastTestMethodFailed) {
|
||||||
return $event->testClassName();
|
return $event->testClassName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use InvalidArgumentException;
|
|||||||
use JsonSerializable;
|
use JsonSerializable;
|
||||||
use Pest\Exceptions\InvalidExpectationValue;
|
use Pest\Exceptions\InvalidExpectationValue;
|
||||||
use Pest\Matchers\Any;
|
use Pest\Matchers\Any;
|
||||||
|
use Pest\Plugins\Snapshot;
|
||||||
use Pest\Support\Arr;
|
use Pest\Support\Arr;
|
||||||
use Pest\Support\Exporter;
|
use Pest\Support\Exporter;
|
||||||
use Pest\Support\NullClosure;
|
use Pest\Support\NullClosure;
|
||||||
@@ -851,18 +852,31 @@ final class Expectation
|
|||||||
default => InvalidExpectationValue::expected('array|object|string'),
|
default => InvalidExpectationValue::expected('array|object|string'),
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($snapshots->has()) {
|
if (! $snapshots->has()) {
|
||||||
[$filename, $content] = $snapshots->get();
|
|
||||||
|
|
||||||
Assert::assertSame(
|
|
||||||
strtr($content, ["\r\n" => "\n", "\r" => "\n"]),
|
|
||||||
strtr($string, ["\r\n" => "\n", "\r" => "\n"]),
|
|
||||||
$message === '' ? "Failed asserting that the string value matches its snapshot ($filename)." : $message
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$filename = $snapshots->save($string);
|
$filename = $snapshots->save($string);
|
||||||
|
|
||||||
TestSuite::getInstance()->registerSnapshotChange("Snapshot created at [$filename]");
|
TestSuite::getInstance()->registerSnapshotChange("Snapshot created at [$filename]");
|
||||||
|
} else {
|
||||||
|
[$filename, $content] = $snapshots->get();
|
||||||
|
|
||||||
|
$normalizedContent = strtr($content, ["\r\n" => "\n", "\r" => "\n"]);
|
||||||
|
$normalizedString = strtr($string, ["\r\n" => "\n", "\r" => "\n"]);
|
||||||
|
|
||||||
|
if (Snapshot::$updateSnapshots && $normalizedContent !== $normalizedString) {
|
||||||
|
$snapshots->save($string);
|
||||||
|
|
||||||
|
TestSuite::getInstance()->registerSnapshotChange("Snapshot updated at [$filename]");
|
||||||
|
} else {
|
||||||
|
if (Snapshot::$updateSnapshots) {
|
||||||
|
TestSuite::getInstance()->registerSnapshotChange("Snapshot unchanged at [$filename]");
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert::assertSame(
|
||||||
|
$normalizedContent,
|
||||||
|
$normalizedString,
|
||||||
|
$message === '' ? "Failed asserting that the string value matches its snapshot ($filename)." : $message
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -940,6 +954,7 @@ final class Expectation
|
|||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
|
|
||||||
if ($exception instanceof Throwable) {
|
if ($exception instanceof Throwable) {
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
expect($e)
|
expect($e)
|
||||||
->toBeInstanceOf($exception::class, $message)
|
->toBeInstanceOf($exception::class, $message)
|
||||||
->and($e->getMessage())->toBe($exceptionMessage ?? $exception->getMessage(), $message);
|
->and($e->getMessage())->toBe($exceptionMessage ?? $exception->getMessage(), $message);
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '4.4.4';
|
return '4.7.7';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ final readonly class Help implements HandlesArguments
|
|||||||
'arg' => '--update-snapshots',
|
'arg' => '--update-snapshots',
|
||||||
'desc' => 'Update snapshots for tests using the "toMatchSnapshot" expectation',
|
'desc' => 'Update snapshots for tests using the "toMatchSnapshot" expectation',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'arg' => '--update-shards',
|
||||||
|
'desc' => 'Update shards.json with test timing data for time-balanced sharding',
|
||||||
|
],
|
||||||
], ...$content['Execution']];
|
], ...$content['Execution']];
|
||||||
|
|
||||||
$content['Selection'] = [[
|
$content['Selection'] = [[
|
||||||
|
|||||||
@@ -146,7 +146,6 @@ final class WrapperRunner implements RunnerInterface
|
|||||||
public function run(): int
|
public function run(): int
|
||||||
{
|
{
|
||||||
$directory = dirname(__DIR__);
|
$directory = dirname(__DIR__);
|
||||||
assert($directory !== '');
|
|
||||||
ExcludeList::addDirectory($directory);
|
ExcludeList::addDirectory($directory);
|
||||||
TestResultFacade::init();
|
TestResultFacade::init();
|
||||||
EventFacade::instance()->seal();
|
EventFacade::instance()->seal();
|
||||||
|
|||||||
+357
-4
@@ -6,7 +6,13 @@ namespace Pest\Plugins;
|
|||||||
|
|
||||||
use Pest\Contracts\Plugins\AddsOutput;
|
use Pest\Contracts\Plugins\AddsOutput;
|
||||||
use Pest\Contracts\Plugins\HandlesArguments;
|
use Pest\Contracts\Plugins\HandlesArguments;
|
||||||
|
use Pest\Contracts\Plugins\Terminable;
|
||||||
use Pest\Exceptions\InvalidOption;
|
use Pest\Exceptions\InvalidOption;
|
||||||
|
use Pest\Subscribers\EnsureShardTimingFinished;
|
||||||
|
use Pest\Subscribers\EnsureShardTimingsAreCollected;
|
||||||
|
use Pest\Subscribers\EnsureShardTimingStarted;
|
||||||
|
use Pest\TestSuite;
|
||||||
|
use PHPUnit\Event;
|
||||||
use Symfony\Component\Console\Input\ArgvInput;
|
use Symfony\Component\Console\Input\ArgvInput;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
@@ -15,7 +21,7 @@ use Symfony\Component\Process\Process;
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final class Shard implements AddsOutput, HandlesArguments
|
final class Shard implements AddsOutput, HandlesArguments, Terminable
|
||||||
{
|
{
|
||||||
use Concerns\HandleArguments;
|
use Concerns\HandleArguments;
|
||||||
|
|
||||||
@@ -33,6 +39,40 @@ final class Shard implements AddsOutput, HandlesArguments
|
|||||||
*/
|
*/
|
||||||
private static ?array $shard = null;
|
private static ?array $shard = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to update the shards.json file.
|
||||||
|
*/
|
||||||
|
private static bool $updateShards = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether time-balanced sharding was used.
|
||||||
|
*/
|
||||||
|
private static bool $timeBalanced = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the shards.json file is outdated.
|
||||||
|
*/
|
||||||
|
private static bool $shardsOutdated = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the test suite passed.
|
||||||
|
*/
|
||||||
|
private static bool $passed = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collected timings from workers or subscribers.
|
||||||
|
*
|
||||||
|
* @var array<string, float>|null
|
||||||
|
*/
|
||||||
|
private static ?array $collectedTimings = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The canonical list of test classes from --list-tests.
|
||||||
|
*
|
||||||
|
* @var list<string>|null
|
||||||
|
*/
|
||||||
|
private static ?array $knownTests = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Plugin instance.
|
* Creates a new Plugin instance.
|
||||||
*/
|
*/
|
||||||
@@ -47,6 +87,19 @@ final class Shard implements AddsOutput, HandlesArguments
|
|||||||
*/
|
*/
|
||||||
public function handleArguments(array $arguments): array
|
public function handleArguments(array $arguments): array
|
||||||
{
|
{
|
||||||
|
if ($this->hasArgument('--update-shards', $arguments)) {
|
||||||
|
return $this->handleUpdateShards($arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Parallel::isWorker() && Parallel::getGlobal('UPDATE_SHARDS') === true) {
|
||||||
|
self::$updateShards = true;
|
||||||
|
|
||||||
|
Event\Facade::instance()->registerSubscriber(new EnsureShardTimingStarted);
|
||||||
|
Event\Facade::instance()->registerSubscriber(new EnsureShardTimingFinished);
|
||||||
|
|
||||||
|
return $arguments;
|
||||||
|
}
|
||||||
|
|
||||||
if (! $this->hasArgument('--shard', $arguments)) {
|
if (! $this->hasArgument('--shard', $arguments)) {
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
@@ -63,7 +116,24 @@ final class Shard implements AddsOutput, HandlesArguments
|
|||||||
|
|
||||||
/** @phpstan-ignore-next-line */
|
/** @phpstan-ignore-next-line */
|
||||||
$tests = $this->allTests($arguments);
|
$tests = $this->allTests($arguments);
|
||||||
$testsToRun = (array_chunk($tests, max(1, (int) ceil(count($tests) / $total))))[$index - 1] ?? [];
|
|
||||||
|
$timings = $this->loadShardsFile();
|
||||||
|
if ($timings !== null) {
|
||||||
|
$knownTests = array_values(array_filter($tests, fn (string $test): bool => isset($timings[$test])));
|
||||||
|
$newTests = array_values(array_diff($tests, $knownTests));
|
||||||
|
|
||||||
|
$partitions = $this->partitionByTime($knownTests, $timings, $total);
|
||||||
|
|
||||||
|
foreach ($newTests as $i => $test) {
|
||||||
|
$partitions[$i % $total][] = $test;
|
||||||
|
}
|
||||||
|
|
||||||
|
$testsToRun = $partitions[$index - 1] ?? [];
|
||||||
|
self::$timeBalanced = true;
|
||||||
|
self::$shardsOutdated = $newTests !== [];
|
||||||
|
} else {
|
||||||
|
$testsToRun = (array_chunk($tests, max(1, (int) ceil(count($tests) / $total))))[$index - 1] ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
self::$shard = [
|
self::$shard = [
|
||||||
'index' => $index,
|
'index' => $index,
|
||||||
@@ -72,9 +142,43 @@ final class Shard implements AddsOutput, HandlesArguments
|
|||||||
'testsCount' => count($tests),
|
'testsCount' => count($tests),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($testsToRun === []) {
|
||||||
|
return $arguments;
|
||||||
|
}
|
||||||
|
|
||||||
return [...$arguments, '--filter', $this->buildFilterArgument($testsToRun)];
|
return [...$arguments, '--filter', $this->buildFilterArgument($testsToRun)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles the --update-shards argument.
|
||||||
|
*
|
||||||
|
* @param array<int, string> $arguments
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
private function handleUpdateShards(array $arguments): array
|
||||||
|
{
|
||||||
|
if ($this->hasArgument('--shard', $arguments)) {
|
||||||
|
throw new InvalidOption('The [--update-shards] option cannot be combined with [--shard].');
|
||||||
|
}
|
||||||
|
|
||||||
|
$arguments = $this->popArgument('--update-shards', $arguments);
|
||||||
|
|
||||||
|
self::$updateShards = true;
|
||||||
|
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
|
self::$knownTests = $this->allTests($arguments);
|
||||||
|
|
||||||
|
if ($this->hasArgument('--parallel', $arguments) || $this->hasArgument('-p', $arguments)) {
|
||||||
|
Parallel::setGlobal('UPDATE_SHARDS', true);
|
||||||
|
Parallel::setGlobal('SHARD_RUN_ID', uniqid('pest-shard-', true));
|
||||||
|
} else {
|
||||||
|
Event\Facade::instance()->registerSubscriber(new EnsureShardTimingStarted);
|
||||||
|
Event\Facade::instance()->registerSubscriber(new EnsureShardTimingFinished);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arguments;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all tests that the test suite would run.
|
* Returns all tests that the test suite would run.
|
||||||
*
|
*
|
||||||
@@ -87,7 +191,7 @@ final class Shard implements AddsOutput, HandlesArguments
|
|||||||
'php',
|
'php',
|
||||||
...$this->removeParallelArguments($arguments),
|
...$this->removeParallelArguments($arguments),
|
||||||
'--list-tests',
|
'--list-tests',
|
||||||
]))->mustRun()->getOutput();
|
]))->setTimeout(120)->mustRun()->getOutput();
|
||||||
|
|
||||||
preg_match_all('/ - (?:P\\\\)?(Tests\\\\[^:]+)::/', $output, $matches);
|
preg_match_all('/ - (?:P\\\\)?(Tests\\\\[^:]+)::/', $output, $matches);
|
||||||
|
|
||||||
@@ -116,6 +220,22 @@ final class Shard implements AddsOutput, HandlesArguments
|
|||||||
*/
|
*/
|
||||||
public function addOutput(int $exitCode): int
|
public function addOutput(int $exitCode): int
|
||||||
{
|
{
|
||||||
|
self::$passed = $exitCode === 0;
|
||||||
|
|
||||||
|
if (self::$updateShards && self::$passed && ! Parallel::isWorker()) {
|
||||||
|
self::$collectedTimings = $this->collectTimings();
|
||||||
|
|
||||||
|
$count = self::$knownTests !== null
|
||||||
|
? count(array_intersect_key(self::$collectedTimings, array_flip(self::$knownTests)))
|
||||||
|
: count(self::$collectedTimings);
|
||||||
|
|
||||||
|
$this->output->writeln(sprintf(
|
||||||
|
' <fg=gray>Shards:</> <fg=default>shards.json updated with timings for %d test class%s.</>',
|
||||||
|
$count,
|
||||||
|
$count === 1 ? '' : 'es',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if (self::$shard === null) {
|
if (self::$shard === null) {
|
||||||
return $exitCode;
|
return $exitCode;
|
||||||
}
|
}
|
||||||
@@ -128,17 +248,250 @@ final class Shard implements AddsOutput, HandlesArguments
|
|||||||
] = self::$shard;
|
] = self::$shard;
|
||||||
|
|
||||||
$this->output->writeln(sprintf(
|
$this->output->writeln(sprintf(
|
||||||
' <fg=gray>Shard:</> <fg=default>%d of %d</> — %d file%s ran, out of %d.',
|
' <fg=gray>Shard:</> <fg=default>%d of %d</> — %d file%s ran, out of %d%s.',
|
||||||
$index,
|
$index,
|
||||||
$total,
|
$total,
|
||||||
$testsRan,
|
$testsRan,
|
||||||
$testsRan === 1 ? '' : 's',
|
$testsRan === 1 ? '' : 's',
|
||||||
$testsCount,
|
$testsCount,
|
||||||
|
self::$timeBalanced ? ' <fg=gray>(time-balanced)</>' : '',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
if (self::$shardsOutdated) {
|
||||||
|
$this->output->writeln(' <fg=yellow;options=bold>WARN</> <fg=default>The [tests/.pest/shards.json] file is out of date. Run [--update-shards] to update it.</>');
|
||||||
|
}
|
||||||
|
|
||||||
return $exitCode;
|
return $exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Terminates the plugin.
|
||||||
|
*/
|
||||||
|
public function terminate(): void
|
||||||
|
{
|
||||||
|
if (! self::$updateShards) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Parallel::isWorker()) {
|
||||||
|
$this->writeWorkerTimings();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! self::$passed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$timings = self::$collectedTimings ?? $this->collectTimings();
|
||||||
|
|
||||||
|
if ($timings === []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->writeTimings($timings);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects timings from subscribers or worker temp files.
|
||||||
|
*
|
||||||
|
* @return array<string, float>
|
||||||
|
*/
|
||||||
|
private function collectTimings(): array
|
||||||
|
{
|
||||||
|
$runId = Parallel::getGlobal('SHARD_RUN_ID');
|
||||||
|
|
||||||
|
if (is_string($runId)) {
|
||||||
|
return $this->readWorkerTimings($runId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EnsureShardTimingsAreCollected::timings();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the current worker's timing data to a temp file.
|
||||||
|
*/
|
||||||
|
private function writeWorkerTimings(): void
|
||||||
|
{
|
||||||
|
$timings = EnsureShardTimingsAreCollected::timings();
|
||||||
|
|
||||||
|
if ($timings === []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$runId = Parallel::getGlobal('SHARD_RUN_ID');
|
||||||
|
|
||||||
|
if (! is_string($runId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = sys_get_temp_dir().DIRECTORY_SEPARATOR.'__pest_sharding_'.$runId.'-'.getmypid().'.json';
|
||||||
|
|
||||||
|
file_put_contents($path, json_encode($timings, JSON_THROW_ON_ERROR));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads and merges timing data from all worker temp files.
|
||||||
|
*
|
||||||
|
* @return array<string, float>
|
||||||
|
*/
|
||||||
|
private function readWorkerTimings(string $runId): array
|
||||||
|
{
|
||||||
|
$pattern = sys_get_temp_dir().DIRECTORY_SEPARATOR.'__pest_sharding_'.$runId.'-*.json';
|
||||||
|
$files = glob($pattern);
|
||||||
|
|
||||||
|
if ($files === false || $files === []) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$merged = [];
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$contents = file_get_contents($file);
|
||||||
|
|
||||||
|
if ($contents === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$timings = json_decode($contents, true);
|
||||||
|
|
||||||
|
if (is_array($timings)) {
|
||||||
|
$merged = array_merge($merged, $timings);
|
||||||
|
}
|
||||||
|
|
||||||
|
unlink($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $merged;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path to shards.json.
|
||||||
|
*/
|
||||||
|
private function shardsPath(): string
|
||||||
|
{
|
||||||
|
$testSuite = TestSuite::getInstance();
|
||||||
|
|
||||||
|
return implode(DIRECTORY_SEPARATOR, [$testSuite->rootPath, $testSuite->testPath, '.pest', 'shards.json']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the timings from shards.json.
|
||||||
|
*
|
||||||
|
* @return array<string, float>|null
|
||||||
|
*/
|
||||||
|
private function loadShardsFile(): ?array
|
||||||
|
{
|
||||||
|
$path = $this->shardsPath();
|
||||||
|
|
||||||
|
if (! file_exists($path)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$contents = file_get_contents($path);
|
||||||
|
|
||||||
|
if ($contents === false) {
|
||||||
|
throw new InvalidOption('The [tests/.pest/shards.json] file could not be read. Delete it or run [--update-shards] to regenerate.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = json_decode($contents, true);
|
||||||
|
|
||||||
|
if (! is_array($data) || ! isset($data['timings']) || ! is_array($data['timings'])) {
|
||||||
|
throw new InvalidOption('The [tests/.pest/shards.json] file is corrupted. Delete it or run [--update-shards] to regenerate.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data['timings'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Partitions tests across shards using the LPT (Longest Processing Time) algorithm.
|
||||||
|
*
|
||||||
|
* @param list<string> $tests
|
||||||
|
* @param array<string, float> $timings
|
||||||
|
* @return list<list<string>>
|
||||||
|
*/
|
||||||
|
private function partitionByTime(array $tests, array $timings, int $total): array
|
||||||
|
{
|
||||||
|
$knownTimings = array_filter(
|
||||||
|
array_map(fn (string $test): ?float => $timings[$test] ?? null, $tests),
|
||||||
|
fn (?float $t): bool => $t !== null,
|
||||||
|
);
|
||||||
|
|
||||||
|
$median = $knownTimings !== [] ? $this->median(array_values($knownTimings)) : 1.0;
|
||||||
|
|
||||||
|
$testsWithTimings = array_map(
|
||||||
|
fn (string $test): array => ['test' => $test, 'time' => $timings[$test] ?? $median],
|
||||||
|
$tests,
|
||||||
|
);
|
||||||
|
|
||||||
|
usort($testsWithTimings, fn (array $a, array $b): int => $b['time'] <=> $a['time']);
|
||||||
|
|
||||||
|
/** @var list<list<string>> */
|
||||||
|
$bins = array_fill(0, $total, []);
|
||||||
|
/** @var non-empty-list<float> */
|
||||||
|
$binTimes = array_fill(0, $total, 0.0);
|
||||||
|
|
||||||
|
foreach ($testsWithTimings as $item) {
|
||||||
|
$minIndex = array_search(min($binTimes), $binTimes, strict: true);
|
||||||
|
assert(is_int($minIndex));
|
||||||
|
|
||||||
|
$bins[$minIndex][] = $item['test'];
|
||||||
|
$binTimes[$minIndex] += $item['time'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $bins;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the median of an array of floats.
|
||||||
|
*
|
||||||
|
* @param list<float> $values
|
||||||
|
*/
|
||||||
|
private function median(array $values): float
|
||||||
|
{
|
||||||
|
sort($values);
|
||||||
|
|
||||||
|
$count = count($values);
|
||||||
|
$middle = (int) floor($count / 2);
|
||||||
|
|
||||||
|
if ($count % 2 === 0) {
|
||||||
|
return ($values[$middle - 1] + $values[$middle]) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $values[$middle];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the timings to shards.json.
|
||||||
|
*
|
||||||
|
* @param array<string, float> $timings
|
||||||
|
*/
|
||||||
|
private function writeTimings(array $timings): void
|
||||||
|
{
|
||||||
|
$path = $this->shardsPath();
|
||||||
|
|
||||||
|
$directory = dirname($path);
|
||||||
|
if (! is_dir($directory)) {
|
||||||
|
mkdir($directory, 0755, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self::$knownTests !== null) {
|
||||||
|
$knownSet = array_flip(self::$knownTests);
|
||||||
|
$timings = array_intersect_key($timings, $knownSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
ksort($timings);
|
||||||
|
|
||||||
|
$canonical = self::$knownTests ?? array_keys($timings);
|
||||||
|
sort($canonical);
|
||||||
|
|
||||||
|
file_put_contents($path, json_encode([
|
||||||
|
'timings' => $timings,
|
||||||
|
'checksum' => md5(implode("\n", $canonical)),
|
||||||
|
'updated_at' => date('c'),
|
||||||
|
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)."\n");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the shard information.
|
* Returns the shard information.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||||||
namespace Pest\Plugins;
|
namespace Pest\Plugins;
|
||||||
|
|
||||||
use Pest\Contracts\Plugins\HandlesArguments;
|
use Pest\Contracts\Plugins\HandlesArguments;
|
||||||
use Pest\Exceptions\InvalidOption;
|
|
||||||
use Pest\TestSuite;
|
use Pest\TestSuite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,21 +14,116 @@ final class Snapshot implements HandlesArguments
|
|||||||
{
|
{
|
||||||
use Concerns\HandleArguments;
|
use Concerns\HandleArguments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether snapshots should be updated on this run.
|
||||||
|
*/
|
||||||
|
public static bool $updateSnapshots = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public function handleArguments(array $arguments): array
|
public function handleArguments(array $arguments): array
|
||||||
{
|
{
|
||||||
|
if (Parallel::isWorker() && Parallel::getGlobal('UPDATE_SNAPSHOTS') === true) {
|
||||||
|
self::$updateSnapshots = true;
|
||||||
|
|
||||||
|
return $arguments;
|
||||||
|
}
|
||||||
|
|
||||||
if (! $this->hasArgument('--update-snapshots', $arguments)) {
|
if (! $this->hasArgument('--update-snapshots', $arguments)) {
|
||||||
return $arguments;
|
return $arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->hasArgument('--parallel', $arguments)) {
|
self::$updateSnapshots = true;
|
||||||
throw new InvalidOption('The [--update-snapshots] option is not supported when running in parallel.');
|
|
||||||
|
if ($this->isFullRun($arguments)) {
|
||||||
|
TestSuite::getInstance()->snapshots->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
TestSuite::getInstance()->snapshots->flush();
|
if ($this->hasArgument('--parallel', $arguments) || $this->hasArgument('-p', $arguments)) {
|
||||||
|
Parallel::setGlobal('UPDATE_SNAPSHOTS', true);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->popArgument('--update-snapshots', $arguments);
|
return $this->popArgument('--update-snapshots', $arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options that take a value as the next argument (rather than via "=value").
|
||||||
|
*
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
private const array FLAGS_WITH_VALUES = [
|
||||||
|
'--filter',
|
||||||
|
'--group',
|
||||||
|
'--exclude-group',
|
||||||
|
'--test-suffix',
|
||||||
|
'--covers',
|
||||||
|
'--uses',
|
||||||
|
'--cache-directory',
|
||||||
|
'--cache-result-file',
|
||||||
|
'--configuration',
|
||||||
|
'--colors',
|
||||||
|
'--test-directory',
|
||||||
|
'--bootstrap',
|
||||||
|
'--order-by',
|
||||||
|
'--random-order-seed',
|
||||||
|
'--log-junit',
|
||||||
|
'--log-teamcity',
|
||||||
|
'--log-events-text',
|
||||||
|
'--log-events-verbose-text',
|
||||||
|
'--coverage-clover',
|
||||||
|
'--coverage-cobertura',
|
||||||
|
'--coverage-crap4j',
|
||||||
|
'--coverage-html',
|
||||||
|
'--coverage-php',
|
||||||
|
'--coverage-text',
|
||||||
|
'--coverage-xml',
|
||||||
|
'--assignee',
|
||||||
|
'--issue',
|
||||||
|
'--ticket',
|
||||||
|
'--pr',
|
||||||
|
'--pull-request',
|
||||||
|
'--retry',
|
||||||
|
'--shard',
|
||||||
|
'--repeat',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the command targets the entire suite (no filter, no path).
|
||||||
|
*
|
||||||
|
* @param array<int, string> $arguments
|
||||||
|
*/
|
||||||
|
private function isFullRun(array $arguments): bool
|
||||||
|
{
|
||||||
|
if ($this->hasArgument('--filter', $arguments)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tokens = array_slice($arguments, 1);
|
||||||
|
$skipNext = false;
|
||||||
|
|
||||||
|
foreach ($tokens as $arg) {
|
||||||
|
if ($skipNext) {
|
||||||
|
$skipNext = false;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($arg === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($arg[0] === '-') {
|
||||||
|
if (in_array($arg, self::FLAGS_WITH_VALUES, true)) {
|
||||||
|
$skipNext = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,8 +59,10 @@ final class SnapshotRepository
|
|||||||
{
|
{
|
||||||
$snapshotFilename = $this->getSnapshotFilename();
|
$snapshotFilename = $this->getSnapshotFilename();
|
||||||
|
|
||||||
if (! file_exists(dirname($snapshotFilename))) {
|
$directory = dirname($snapshotFilename);
|
||||||
mkdir(dirname($snapshotFilename), 0755, true);
|
|
||||||
|
if (! is_dir($directory)) {
|
||||||
|
@mkdir($directory, 0755, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents($snapshotFilename, $snapshot);
|
file_put_contents($snapshotFilename, $snapshot);
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Pest\Subscribers;
|
||||||
|
|
||||||
|
use PHPUnit\Event\TestSuite\Finished;
|
||||||
|
use PHPUnit\Event\TestSuite\FinishedSubscriber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
final class EnsureShardTimingFinished implements FinishedSubscriber
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Runs the subscriber.
|
||||||
|
*/
|
||||||
|
public function notify(Finished $event): void
|
||||||
|
{
|
||||||
|
EnsureShardTimingsAreCollected::finished($event);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Pest\Subscribers;
|
||||||
|
|
||||||
|
use PHPUnit\Event\TestSuite\Started;
|
||||||
|
use PHPUnit\Event\TestSuite\StartedSubscriber;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
final class EnsureShardTimingStarted implements StartedSubscriber
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Runs the subscriber.
|
||||||
|
*/
|
||||||
|
public function notify(Started $event): void
|
||||||
|
{
|
||||||
|
EnsureShardTimingsAreCollected::started($event);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Pest\Subscribers;
|
||||||
|
|
||||||
|
use PHPUnit\Event\Telemetry\HRTime;
|
||||||
|
use PHPUnit\Event\TestSuite\Finished;
|
||||||
|
use PHPUnit\Event\TestSuite\Started;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
final class EnsureShardTimingsAreCollected
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The start times for each test class.
|
||||||
|
*
|
||||||
|
* @var array<string, HRTime>
|
||||||
|
*/
|
||||||
|
private static array $startTimes = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The collected timings for each test class.
|
||||||
|
*
|
||||||
|
* @var array<string, float>
|
||||||
|
*/
|
||||||
|
private static array $timings = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Records the start time for a test suite.
|
||||||
|
*/
|
||||||
|
public static function started(Started $event): void
|
||||||
|
{
|
||||||
|
if (! $event->testSuite()->isForTestClass()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = preg_replace('/^P\\\\/', '', $event->testSuite()->name());
|
||||||
|
|
||||||
|
if (is_string($name)) {
|
||||||
|
self::$startTimes[$name] = $event->telemetryInfo()->time();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Records the duration for a test suite.
|
||||||
|
*/
|
||||||
|
public static function finished(Finished $event): void
|
||||||
|
{
|
||||||
|
if (! $event->testSuite()->isForTestClass()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = preg_replace('/^P\\\\/', '', $event->testSuite()->name());
|
||||||
|
|
||||||
|
if (! is_string($name) || ! isset(self::$startTimes[$name])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$duration = $event->telemetryInfo()->time()->duration(self::$startTimes[$name]);
|
||||||
|
|
||||||
|
self::$timings[$name] = round($duration->asFloat(), 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the collected timings.
|
||||||
|
*
|
||||||
|
* @return array<string, float>
|
||||||
|
*/
|
||||||
|
public static function timings(): array
|
||||||
|
{
|
||||||
|
return self::$timings;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,15 +15,20 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
final readonly class EnsureTeamCityEnabled implements ConfiguredSubscriber
|
final class EnsureTeamCityEnabled implements ConfiguredSubscriber
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Indicates if the TeamCity logger has already been registered.
|
||||||
|
*/
|
||||||
|
private static bool $registered = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new Configured Subscriber instance.
|
* Creates a new Configured Subscriber instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private InputInterface $input,
|
private readonly InputInterface $input,
|
||||||
private OutputInterface $output,
|
private readonly OutputInterface $output,
|
||||||
private TestSuite $testSuite,
|
private readonly TestSuite $testSuite,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,10 +36,16 @@ final readonly class EnsureTeamCityEnabled implements ConfiguredSubscriber
|
|||||||
*/
|
*/
|
||||||
public function notify(Configured $event): void
|
public function notify(Configured $event): void
|
||||||
{
|
{
|
||||||
|
if (self::$registered) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (! $this->input->hasParameterOption('--teamcity')) {
|
if (! $this->input->hasParameterOption('--teamcity')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self::$registered = true;
|
||||||
|
|
||||||
$flowId = getenv('FLOW_ID');
|
$flowId = getenv('FLOW_ID');
|
||||||
$flowId = is_string($flowId) ? (int) $flowId : getmypid();
|
$flowId = is_string($flowId) ? (int) $flowId : getmypid();
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ use PHPUnit\Event\Code\TestDoxBuilder;
|
|||||||
use PHPUnit\Event\Code\TestMethod;
|
use PHPUnit\Event\Code\TestMethod;
|
||||||
use PHPUnit\Event\Code\ThrowableBuilder;
|
use PHPUnit\Event\Code\ThrowableBuilder;
|
||||||
use PHPUnit\Event\Test\Errored;
|
use PHPUnit\Event\Test\Errored;
|
||||||
|
use PHPUnit\Event\Test\Failed;
|
||||||
use PHPUnit\Event\Test\PhpunitDeprecationTriggered;
|
use PHPUnit\Event\Test\PhpunitDeprecationTriggered;
|
||||||
use PHPUnit\Event\Test\PhpunitErrorTriggered;
|
use PHPUnit\Event\Test\PhpunitErrorTriggered;
|
||||||
use PHPUnit\Event\Test\PhpunitNoticeTriggered;
|
use PHPUnit\Event\Test\PhpunitNoticeTriggered;
|
||||||
@@ -40,11 +41,16 @@ final class StateGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($testResult->testFailedEvents() as $testResultEvent) {
|
foreach ($testResult->testFailedEvents() as $testResultEvent) {
|
||||||
$state->add(TestResult::fromPestParallelTestCase(
|
if ($testResultEvent instanceof Failed) {
|
||||||
$testResultEvent->test(),
|
$state->add(TestResult::fromPestParallelTestCase(
|
||||||
TestResult::FAIL,
|
$testResultEvent->test(),
|
||||||
$testResultEvent->throwable()
|
TestResult::FAIL,
|
||||||
));
|
$testResultEvent->throwable()
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
|
$state->add(TestResult::fromBeforeFirstTestMethodErrored($testResultEvent));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addTriggeredPhpunitEvents($state, $testResult->testTriggeredPhpunitErrorEvents(), TestResult::FAIL);
|
$this->addTriggeredPhpunitEvents($state, $testResult->testTriggeredPhpunitErrorEvents(), TestResult::FAIL);
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<h1>Snapshot</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
<div class="container">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<h1>Snapshot</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
Pest Testing Framework 4.4.4.
|
Pest Testing Framework 4.7.7.
|
||||||
|
|
||||||
USAGE: pest <file> [options]
|
USAGE: pest <file> [options]
|
||||||
|
|
||||||
@@ -49,6 +49,7 @@
|
|||||||
EXECUTION OPTIONS:
|
EXECUTION OPTIONS:
|
||||||
--parallel ........................................... Run tests in parallel
|
--parallel ........................................... Run tests in parallel
|
||||||
--update-snapshots Update snapshots for tests using the "toMatchSnapshot" expectation
|
--update-snapshots Update snapshots for tests using the "toMatchSnapshot" expectation
|
||||||
|
--update-shards Update shards.json with test timing data for time-balanced sharding
|
||||||
--globals-backup ................. Backup and restore $GLOBALS for each test
|
--globals-backup ................. Backup and restore $GLOBALS for each test
|
||||||
--static-backup ......... Backup and restore static properties for each test
|
--static-backup ......... Backup and restore static properties for each test
|
||||||
--strict-coverage ................... Be strict about code coverage metadata
|
--strict-coverage ................... Be strict about code coverage metadata
|
||||||
@@ -90,7 +91,11 @@
|
|||||||
--cache-result ............................ Write test results to cache file
|
--cache-result ............................ Write test results to cache file
|
||||||
--do-not-cache-result .............. Do not write test results to cache file
|
--do-not-cache-result .............. Do not write test results to cache file
|
||||||
--order-by [order] Run tests in order: default|defects|depends|duration|no-depends|random|reverse|size
|
--order-by [order] Run tests in order: default|defects|depends|duration|no-depends|random|reverse|size
|
||||||
|
--resolve-dependencies ...................... Alias for "--order-by depends"
|
||||||
|
--ignore-dependencies .................... Alias for "--order-by no-depends"
|
||||||
|
--random-order ............................... Alias for "--order-by random"
|
||||||
--random-order-seed [N] Use the specified random seed when running tests in random order
|
--random-order-seed [N] Use the specified random seed when running tests in random order
|
||||||
|
--reverse-order ............................. Alias for "--order-by reverse"
|
||||||
|
|
||||||
REPORTING OPTIONS:
|
REPORTING OPTIONS:
|
||||||
--colors=[flag] ......... Use colors in output ("never", "auto" or "always")
|
--colors=[flag] ......... Use colors in output ("never", "auto" or "always")
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
|
|
||||||
Pest Testing Framework 4.4.4.
|
Pest Testing Framework 4.7.7.
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
✓ preset → strict → ignoring ['usleep']
|
✓ preset → strict → ignoring ['usleep']
|
||||||
✓ preset → security → ignoring ['eval', 'str_shuffle', 'exec', …]
|
✓ preset → security → ignoring ['eval', 'str_shuffle', 'exec', …]
|
||||||
✓ globals
|
✓ globals
|
||||||
✓ contracts
|
|
||||||
|
|
||||||
PASS Tests\Environments\Windows
|
PASS Tests\Environments\Windows
|
||||||
✓ global functions are loaded
|
✓ global functions are loaded
|
||||||
@@ -137,6 +136,11 @@
|
|||||||
✓ describe()->with() preserves depends → first with (9)
|
✓ describe()->with() preserves depends → first with (9)
|
||||||
✓ describe()->with() preserves depends → second with (9)
|
✓ describe()->with() preserves depends → second with (9)
|
||||||
|
|
||||||
|
PASS Tests\Features\DatasetProviderErrors
|
||||||
|
✓ reports missing datasets as errors for a single file run
|
||||||
|
✓ reports missing datasets as errors alongside passing tests
|
||||||
|
✓ reports dataset closure exceptions as errors
|
||||||
|
|
||||||
PASS Tests\Features\DatasetsTests - 1 todo
|
PASS Tests\Features\DatasetsTests - 1 todo
|
||||||
✓ it throws exception if dataset does not exist
|
✓ it throws exception if dataset does not exist
|
||||||
✓ it throws exception if dataset already exist
|
✓ it throws exception if dataset already exist
|
||||||
@@ -1037,8 +1041,6 @@
|
|||||||
✓ pass with toArray
|
✓ pass with toArray
|
||||||
✓ pass with array
|
✓ pass with array
|
||||||
✓ pass with toSnapshot
|
✓ pass with toSnapshot
|
||||||
✓ failures
|
|
||||||
✓ failures with custom message
|
|
||||||
✓ not failures
|
✓ not failures
|
||||||
✓ multiple snapshot expectations
|
✓ multiple snapshot expectations
|
||||||
✓ multiple snapshot expectations with datasets with (1)
|
✓ multiple snapshot expectations with datasets with (1)
|
||||||
@@ -1903,4 +1905,4 @@
|
|||||||
✓ pass with dataset with ('my-datas-set-value')
|
✓ pass with dataset with ('my-datas-set-value')
|
||||||
✓ within describe → pass with dataset with ('my-datas-set-value')
|
✓ within describe → pass with dataset with ('my-datas-set-value')
|
||||||
|
|
||||||
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1296 passed (2977 assertions)
|
Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 40 todos, 35 skipped, 1296 passed (2979 assertions)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
dataset('throws', function () {
|
||||||
|
throw new RuntimeException('boom from dataset');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('x', function ($a) {
|
||||||
|
expect($a)->toBeTrue();
|
||||||
|
})->with('throws');
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
it('references a missing dataset', function ($value) {
|
||||||
|
expect($value)->toBeTruthy();
|
||||||
|
})->with('missing');
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
it('passes normally', function () {
|
||||||
|
expect(true)->toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('references a missing dataset', function ($value) {
|
||||||
|
expect($value)->toBeTruthy();
|
||||||
|
})->with('missing');
|
||||||
+5
-10
@@ -7,6 +7,9 @@ arch()->preset()->php()->ignoring([
|
|||||||
'debug_backtrace',
|
'debug_backtrace',
|
||||||
'var_export',
|
'var_export',
|
||||||
'xdebug_info',
|
'xdebug_info',
|
||||||
|
'xdebug_start_code_coverage',
|
||||||
|
'xdebug_stop_code_coverage',
|
||||||
|
'xdebug_get_code_coverage',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
arch()->preset()->strict()->ignoring([
|
arch()->preset()->strict()->ignoring([
|
||||||
@@ -17,7 +20,9 @@ arch()->preset()->security()->ignoring([
|
|||||||
'eval',
|
'eval',
|
||||||
'str_shuffle',
|
'str_shuffle',
|
||||||
'exec',
|
'exec',
|
||||||
|
'md5',
|
||||||
'unserialize',
|
'unserialize',
|
||||||
|
'uniqid',
|
||||||
'extract',
|
'extract',
|
||||||
'assert',
|
'assert',
|
||||||
]);
|
]);
|
||||||
@@ -26,13 +31,3 @@ arch('globals')
|
|||||||
->expect(['dd', 'dump', 'ray', 'die', 'var_dump', 'sleep'])
|
->expect(['dd', 'dump', 'ray', 'die', 'var_dump', 'sleep'])
|
||||||
->not->toBeUsed()
|
->not->toBeUsed()
|
||||||
->ignoring(Expectation::class);
|
->ignoring(Expectation::class);
|
||||||
|
|
||||||
arch('contracts')
|
|
||||||
->expect('Pest\Contracts')
|
|
||||||
->toOnlyUse([
|
|
||||||
'NunoMaduro\Collision\Contracts',
|
|
||||||
'Pest\Factories\TestCaseMethodFactory',
|
|
||||||
'Symfony\Component\Console',
|
|
||||||
'Pest\Arch\Contracts',
|
|
||||||
'Pest\PendingCalls',
|
|
||||||
])->toBeInterfaces();
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
|
||||||
|
$run = function (string $target): array {
|
||||||
|
$process = new Process(
|
||||||
|
['php', 'bin/pest', $target],
|
||||||
|
dirname(__DIR__, 2),
|
||||||
|
['COLLISION_PRINTER' => 'DefaultPrinter', 'COLLISION_IGNORE_DURATION' => 'true'],
|
||||||
|
);
|
||||||
|
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'output' => removeAnsiEscapeSequences($process->getOutput().$process->getErrorOutput()),
|
||||||
|
'code' => $process->getExitCode(),
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
test('reports missing datasets as errors for a single file run', function () use ($run) {
|
||||||
|
$result = $run('tests/.tests/IssueOnly.php');
|
||||||
|
|
||||||
|
expect($result['output'])
|
||||||
|
->toContain("A dataset with the name `missing` does not exist. You can create it using `dataset('missing', ['a', 'b']);`.")
|
||||||
|
->toContain('FAILED')
|
||||||
|
->toContain('Tests: 1 failed');
|
||||||
|
|
||||||
|
expect($result['code'])->not->toBe(0);
|
||||||
|
})->skipOnWindows();
|
||||||
|
|
||||||
|
test('reports missing datasets as errors alongside passing tests', function () use ($run) {
|
||||||
|
$result = $run('tests/.tests/IssueWithPassing.php');
|
||||||
|
|
||||||
|
expect($result['output'])
|
||||||
|
->toContain("A dataset with the name `missing` does not exist. You can create it using `dataset('missing', ['a', 'b']);`.")
|
||||||
|
->toContain('1 passed')
|
||||||
|
->toContain('1 failed');
|
||||||
|
|
||||||
|
expect($result['code'])->not->toBe(0);
|
||||||
|
})->skipOnWindows();
|
||||||
|
|
||||||
|
test('reports dataset closure exceptions as errors', function () use ($run) {
|
||||||
|
$result = $run('tests/.tests/DatasetClosureThrows.php');
|
||||||
|
|
||||||
|
expect($result['output'])
|
||||||
|
->toContain('boom from dataset');
|
||||||
|
|
||||||
|
expect($result['code'])->not->toBe(0);
|
||||||
|
})->skipOnWindows();
|
||||||
@@ -134,18 +134,6 @@ test('pass with `toSnapshot`', function () {
|
|||||||
expect($object)->toMatchSnapshot();
|
expect($object)->toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('failures', function () {
|
|
||||||
TestSuite::getInstance()->snapshots->save($this->snapshotable);
|
|
||||||
|
|
||||||
expect('contain that does not match snapshot')->toMatchSnapshot();
|
|
||||||
})->throws(ExpectationFailedException::class, 'Failed asserting that two strings are identical.');
|
|
||||||
|
|
||||||
test('failures with custom message', function () {
|
|
||||||
TestSuite::getInstance()->snapshots->save($this->snapshotable);
|
|
||||||
|
|
||||||
expect('contain that does not match snapshot')->toMatchSnapshot('oh no');
|
|
||||||
})->throws(ExpectationFailedException::class, 'oh no');
|
|
||||||
|
|
||||||
test('not failures', function () {
|
test('not failures', function () {
|
||||||
TestSuite::getInstance()->snapshots->save($this->snapshotable);
|
TestSuite::getInstance()->snapshots->save($this->snapshotable);
|
||||||
|
|
||||||
|
|||||||
+8
-1
@@ -86,5 +86,12 @@ dataset('dataset_in_pest_file', ['A', 'B']);
|
|||||||
|
|
||||||
function removeAnsiEscapeSequences(string $input): ?string
|
function removeAnsiEscapeSequences(string $input): ?string
|
||||||
{
|
{
|
||||||
return preg_replace('#\\x1b[[][^A-Za-z]*[A-Za-z]#', '', $input);
|
return preg_replace(
|
||||||
|
[
|
||||||
|
'#\\x1b[[][^A-Za-z]*[A-Za-z]#', // CSI (colors, cursor, etc.)
|
||||||
|
'#\\x1b\\]8;[^\\x1b\\x07]*(?:\\x1b\\\\|\\x07)#', // OSC 8 hyperlinks
|
||||||
|
],
|
||||||
|
'',
|
||||||
|
$input,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ $run = function () {
|
|||||||
|
|
||||||
test('parallel', function () use ($run) {
|
test('parallel', function () use ($run) {
|
||||||
$output = $run('--exclude-group=integration');
|
$output = $run('--exclude-group=integration');
|
||||||
|
$output = implode("\n", array_slice(explode("\n", $output), -10));
|
||||||
|
|
||||||
if (getenv('REBUILD_SNAPSHOTS')) {
|
if (getenv('REBUILD_SNAPSHOTS')) {
|
||||||
preg_match('/Tests:\s+(.+\(\d+ assertions\))/', $output, $matches);
|
preg_match('/Tests:\s+(.+\(\d+ assertions\))/', $output, $matches);
|
||||||
@@ -23,13 +24,13 @@ test('parallel', function () use ($run) {
|
|||||||
$file = file_get_contents(__FILE__);
|
$file = file_get_contents(__FILE__);
|
||||||
$file = preg_replace(
|
$file = preg_replace(
|
||||||
'/\$expected = \'.*?\';/',
|
'/\$expected = \'.*?\';/',
|
||||||
"\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1280 passed (2926 assertions)';",
|
"\$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1280 passed (2928 assertions)';",
|
||||||
$file,
|
$file,
|
||||||
);
|
);
|
||||||
file_put_contents(__FILE__, $file);
|
file_put_contents(__FILE__, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1280 passed (2926 assertions)';
|
$expected = '2 deprecated, 4 warnings, 5 incomplete, 3 notices, 40 todos, 27 skipped, 1280 passed (2928 assertions)';
|
||||||
|
|
||||||
expect($output)
|
expect($output)
|
||||||
->toContain("Tests: {$expected}")
|
->toContain("Tests: {$expected}")
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ test('visual snapshot of test suite on success', function () {
|
|||||||
|
|
||||||
return preg_replace([
|
return preg_replace([
|
||||||
'#\\x1b[[][^A-Za-z]*[A-Za-z]#',
|
'#\\x1b[[][^A-Za-z]*[A-Za-z]#',
|
||||||
|
'#\\x1b\\]8;[^\\x1b\\x07]*(?:\\x1b\\\\|\\x07)#',
|
||||||
'/(Tests\\\PHPUnit\\\CustomAffixes\\\InvalidTestName)([A-Za-z0-9]*)/',
|
'/(Tests\\\PHPUnit\\\CustomAffixes\\\InvalidTestName)([A-Za-z0-9]*)/',
|
||||||
], [
|
], [
|
||||||
|
'',
|
||||||
'',
|
'',
|
||||||
'$1',
|
'$1',
|
||||||
], $process->getOutput());
|
], $process->getOutput());
|
||||||
|
|||||||
Reference in New Issue
Block a user