1
0
Fork 0
mirror of https://codeberg.org/icewind/haze.git synced 2026-08-02 12:14:46 +02:00

make it easier to use a specific phpunit version

This commit is contained in:
Robin Appelman 2026-07-14 00:48:56 +02:00
commit d59b99211a
5 changed files with 27 additions and 12 deletions

View file

@ -85,28 +85,28 @@
name = "phpunit";
runtimeInputs = [jq];
text = ''
MAJOR=$(jq -r 'first(.require."phpunit/phpunit" | scan("[[:digit:]]+"))' vendor-bin/phpunit/composer.json)
MAJOR=$(jq -r 'first(.require."phpunit/phpunit" | scan("[[:digit:]]+"))' vendor-bin/phpunit/composer.json || echo "")
case "$MAJOR" in
9)
PKG=${phpunitUnwrapped "9"}
BIN="${getExe (phpunitUnwrapped "9")}"
;;
10)
PKG=${phpunitUnwrapped "10"}
BIN="${getExe (phpunitUnwrapped "10")}"
;;
11)
PKG=${phpunitUnwrapped "11"}
BIN="${getExe (phpunitUnwrapped "11")}"
;;
12)
PKG=${phpunitUnwrapped "12"}
BIN="${getExe (phpunitUnwrapped "12")}"
;;
13)
PKG=${phpunitUnwrapped "13"}
BIN="${getExe (phpunitUnwrapped "13")}"
;;
*)
PKG=${phpunitUnwrapped "10"}
BIN="${getExe (phpunitUnwrapped "10")}"
;;
esac
"$PKG"/bin/phpunit "$@"
"$BIN" "$@"
'';
};
@ -160,6 +160,7 @@
phpEnv.packages.composer
phpunit
]
++ (map phpunitUnwrapped ["9" "10" "11" "12" "13"])
++ optionals ((compareVersions phpVersion "8.2") == 1) [
(frankenphp.override {
php = php.withExtensions (

View file

@ -45,12 +45,16 @@ in
doInstallCheck = false;
postInstall = ''
mv $out/bin/phpunit $out/bin/phpunit${majorVersion}
'';
meta = {
changelog = "https://github.com/sebastianbergmann/phpunit/blob/${finalAttrs.version}/ChangeLog-${lib.versions.majorMinor finalAttrs.version}.md";
description = "PHP Unit Testing framework";
homepage = "https://phpunit.de";
license = lib.licenses.bsd3;
mainProgram = "phpunit";
mainProgram = "phpunit${majorVersion}";
maintainers = with lib.maintainers; [onny];
teams = [lib.teams.php];
};

View file

@ -3,5 +3,15 @@
def --wrapped main [...rest] {
cd $env.WEBROOT
XDEBUG_SESSION=haze phpunit --configuration $"($env.WEBROOT)/tests/phpunit-autotest.xml" ...$rest
mut args = $rest;
mut command = "phpunit";
if (($args | first | detect type | describe) == "int") {
let phpunit_version = $rest | first
$command = $"phpunit($phpunit_version)"
$args = $args | skip 1
}
let command = $command
let args = $args
XDEBUG_SESSION=haze exec $command --configuration $"($env.WEBROOT)/tests/phpunit-autotest.xml" ...$args
}