From 021d21d78228deb70c9d4086a553005184cfbac8 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Mon, 23 Oct 2023 22:21:50 +0200 Subject: [PATCH] Fixes --- bugs/1_infection.php | 80 ++++++++++++++++++++++++++++++++++++++++++++ bugs/1_infection.sh | 33 ++++++++++++++++++ bugs/2_psalm.sh | 25 ++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 bugs/1_infection.php create mode 100755 bugs/1_infection.sh create mode 100755 bugs/2_psalm.sh diff --git a/bugs/1_infection.php b/bugs/1_infection.php new file mode 100644 index 0000000..fae7bae --- /dev/null +++ b/bugs/1_infection.php @@ -0,0 +1,80 @@ +validate($rawConfig, json_decode('{ + "$schema": "https://json-schema.org/draft-07/schema#", + "properties": { + "source": {"type": "string"} + } + }')); + + $actual = (new SchemaConfigurationFactory())->create( + '/path/to/config', + $rawConfig + ); +} + +function provideRawConfig(): iterable +{ + + yield '[timeout] nominal' => [ + <<<'JSON' +{ +"timeout": 100, +"source": { + "directories": ["src"] +} +} +JSON + , + ]; + + + yield '[logs][text] nominal' => [ + <<<'JSON' +{ +"source": { + "directories": ["src"] +}, +"logs": { + "text": "text.log" +} +} +JSON + , + ]; + yield '[logs][html] nominal' => [ + <<<'JSON' +{ +"source": { + "directories": ["src"] +}, +"logs": { + "html": "report.html" +} +} +JSON + , + ]; +} + +for ($x = 0; $x < 10000; $x++) { + foreach (provideRawConfig() as [$a]) { + test_it_can_create_a_config($a); + } +} \ No newline at end of file diff --git a/bugs/1_infection.sh b/bugs/1_infection.sh new file mode 100755 index 0000000..6388a22 --- /dev/null +++ b/bugs/1_infection.sh @@ -0,0 +1,33 @@ +#!/bin/bash -e + +#!/bin/bash -e + +standalone=$PWD/bugs/1_infection.php + +cd /tmp + +rm -rf infection + +git clone https://github.com/infection/infection +cd infection +git checkout fe7cbe78e5838608df42ec7688d353ef1d631fee + +composer i --ignore-platform-reqs + +cp $standalone . + +echo "About to run the standalone test" + +docker run -v $PWD:/app --rm --privileged -it asan_tests /usr/bin/php /app/2_infection.php + +echo "About to run the testsuite" + +docker run -v $PWD:/app --rm --privileged -it asan_tests /usr/bin/php vendor/bin/phpunit + +echo "About to run composer" + +rm -rf vendor + +docker run -v $PWD:/app --rm --privileged -it asan_tests composer update + +echo "OK, no bugs!" \ No newline at end of file diff --git a/bugs/2_psalm.sh b/bugs/2_psalm.sh new file mode 100755 index 0000000..8525d96 --- /dev/null +++ b/bugs/2_psalm.sh @@ -0,0 +1,25 @@ +#!/bin/bash -e + +cd /tmp + +rm -rf psalm + +git clone https://github.com/vimeo/psalm +cd psalm +git checkout 7428e49b115a2a837aa29cf0fafd0ca902fe2457 + +export PSALM_ALLOW_XDEBUG=1 + +composer i --ignore-platform-reqs + +echo "About to run phpunit" + +docker run -v $PWD:/app --rm --privileged -it asan_tests /usr/bin/php /app/vendor/bin/phpunit --debug tests/MagicMethodAnnotationTest.php + +echo "About to run composer" + +rm -rf vendor + +docker run -v $PWD:/app --rm --privileged -it asan_tests composer update + +echo "OK, no bugs!" \ No newline at end of file