Skip to content

Commit

Permalink
feat: Infection Mutation Testing Framework (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuri Silva <[email protected]>
  • Loading branch information
yknsilva and yknsilva authored Dec 23, 2023
1 parent 967eb00 commit 5f66b24
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ install:
@sudo ln -sf $(shell pwd)/bin/phpctl /usr/local/bin/phpctl
@sudo ln -sf $(shell pwd)/bin/phpstan /usr/local/bin/phpstan
@sudo ln -sf $(shell pwd)/bin/phpunit /usr/local/bin/phpunit
@sudo ln -sf $(shell pwd)/bin/infection /usr/local/bin/infection
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ phpctl sh echo 'Hello, World!' # To run arbitrary sh commands inside the contain
| `repl` | Starts a PHP REPL session (powered by [PsySH](https://psysh.org/)). |
| `php-cs-fixer` | Runs PHP-CS-Fixer. |
| `phpstan` | Runs PHPStan. |
| `infection` | Runs [Infection](https://infection.github.io/). |

### Scaffolders
| Command | Description |
Expand All @@ -71,6 +72,7 @@ phpctl sh echo 'Hello, World!' # To run arbitrary sh commands inside the contain
- `phpunit`
- `php-cs-fixer`
- `phpstan`
- `infection`

### Helpers
| Command | Description |
Expand Down
2 changes: 2 additions & 0 deletions bin/infection
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
phpctl infection $@
2 changes: 2 additions & 0 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ symlink() {
sudo ln -sf "${INSTALL_DIR}/bin/phpctl" /usr/local/bin/pctl
sudo ln -sf "${INSTALL_DIR}/bin/phpctl" /usr/local/bin/phpctl
sudo ln -sf "${INSTALL_DIR}/bin/phpstan" /usr/local/bin/phpstan
sudo ln -sf "${INSTALL_DIR}/bin/infection" /usr/local/bin/infection
sudo ln -sf "${INSTALL_DIR}/bin/phpunit" /usr/local/bin/phpunit
}

Expand All @@ -33,5 +34,6 @@ else
echo " sudo ln -sf ${INSTALL_DIR}/bin/phpunit /usr/local/bin/phpunit"
echo " sudo ln -sf ${INSTALL_DIR}/bin/php-cs-fixer /usr/local/bin/php-cs-fixer"
echo " sudo ln -sf ${INSTALL_DIR}/bin/phpstan /usr/local/bin/phpstan"
echo " sudo ln -sf ${INSTALL_DIR}/bin/infection /usr/local/bin/infection"
echo ""
fi
13 changes: 13 additions & 0 deletions skeletons/infection.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"source": {
"directories": ["src"]
},
"timeout": 10,
"logs": {
"text": "infection.log"
},
"mutators": {},
"testFramework": "phpunit",
"bootstrap": "vendor/autoload.php",
"minMsi": 0
}
1 change: 1 addition & 0 deletions src/help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ help() {
echo -e "\033[0;32m repl \033[0m Starts a PHP REPL session (powered by PsySH)"
echo -e "\033[0;32m php-cs-fixer \033[0m Runs PHP-CS-Fixer"
echo -e "\033[0;32m phpstan \033[0m Runs PHPStan"
echo -e "\033[0;32m infection \033[0m Runs Infection, a PHP Mutation Testing Framework"
echo -e "\033[0;32m create [framework] [dir] \033[0m Creates a new project using the given framework (or package)"
echo -e "\033[0;32m init [skeleton] \033[0m Initializes a skeleton configuration (phpunit, php-cs-fixer)"
echo -e "\033[0;32m help or man \033[0m Displays this help message"
Expand Down
9 changes: 9 additions & 0 deletions src/php.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,13 @@ phpstan() {
fi;

run -- vendor/bin/phpstan ${@}
}

infection() {
if [ ! -f vendor/bin/infection ]; then
echo "Infection not found. Installing..."
run -- composer require --dev infection/infection
fi;

run -- vendor/bin/infection ${@}
}
3 changes: 3 additions & 0 deletions src/scaffold.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ init() {
"phpstan")
skeleton="phpstan.neon"
;;
"infection")
skeleton="infection.json5"
;;
*)
echo -e "\033[0;31mSkeleton ($skeleton_alias) not handled.\033[0m"
exit 1
Expand Down

0 comments on commit 5f66b24

Please sign in to comment.