From f9b6e47fb73e0d75b3e74d624d7d2020373de47b Mon Sep 17 00:00:00 2001 From: Hendrik Prinsloo Date: Tue, 19 Sep 2023 21:41:38 +0200 Subject: [PATCH 01/11] Refactored memory & test --- .env.example | 4 + app/Challenges/A/CleanCode.php | 6 +- app/Challenges/A/CleanCodeDatabase.php | 4 +- app/Challenges/A/Eloquent.php | 41 ++---- app/Challenges/A/Laravel.php | 2 +- app/Challenges/A/MySql.php | 4 +- app/Challenges/A/Php.php | 4 +- app/Challenges/A/Sample.php | 6 +- app/Challenges/B/CleanCode.php | 4 +- app/Challenges/B/CleanCodeDatabase.php | 4 +- app/Challenges/B/Eloquent.php | 29 ++-- app/Challenges/B/Laravel.php | 2 +- app/Challenges/B/MySql.php | 4 +- app/Challenges/B/Php.php | 8 +- app/Challenges/B/Sample.php | 6 +- app/Enums/KataRunnerIterationMode.php | 1 + app/Exceptions/BenchmarkProfileException.php | 9 ++ app/KataChallenge.php | 48 +------ app/KataRunner.php | 112 +++++++++------ app/Objects/KataChallengeResultObject.php | 27 ++-- app/Services/ExchangeRateService.php | 10 ++ app/Utilities/Benchmark.php | 135 ++++++++++++++++++ app/helpers.php | 30 +++- config/laravel-kata.php | 13 +- phpunit.xml | 4 +- routes/api.php | 6 - ..._to_human_with_data_set___0_1____0_1_.snap | 1 + ...ytes_to_human_with_data_set___0____0_.snap | 1 + ...a_set___100000000000____100000000000_.snap | 1 + ...ata_set___10000000000____10000000000_.snap | 1 + ..._data_set___1000000000____1000000000_.snap | 1 + ...th_data_set___100000000____100000000_.snap | 1 + ...with_data_set___10000000____10000000_.snap | 1 + ...n_with_data_set___1000000____1000000_.snap | 1 + ...man_with_data_set___100000____100000_.snap | 1 + ...human_with_data_set___10000____10000_.snap | 1 + ...o_human_with_data_set___1000____1000_.snap | 1 + ..._to_human_with_data_set___100____100_.snap | 1 + ...ytes_to_human_with_data_set___1____1_.snap | 1 + ...set___9999999999999____9999999999999_.snap | 1 + ...a_set___999999999999____999999999999_.snap | 1 + ..._digital__with_data_set___0_1____0_1_.snap | 1 + ...man__digital__with_data_set___0____0_.snap | 1 + ...__with_data_set___1000000____1000000_.snap | 1 + ...al__with_data_set___100000____100000_.snap | 1 + ...ital__with_data_set___10000____10000_.snap | 1 + ...igital__with_data_set___1000____1000_.snap | 1 + ..._digital__with_data_set___100____100_.snap | 1 + ...man__digital__with_data_set___1____1_.snap | 1 + ...with_data_set___99999999____99999999_.snap | 1 + ...__with_data_set___9999999____9999999_.snap | 1 + ...n__false__with_data_set___0_1____0_1_.snap | 1 + ...human__false__with_data_set___0____0_.snap | 1 + ...__with_data_set___1000000____1000000_.snap | 1 + ...se__with_data_set___100000____100000_.snap | 1 + ...alse__with_data_set___10000____10000_.snap | 1 + ..._false__with_data_set___1000____1000_.snap | 1 + ...n__false__with_data_set___100____100_.snap | 1 + ...human__false__with_data_set___1____1_.snap | 1 + ...with_data_set___99999999____99999999_.snap | 1 + ...__with_data_set___9999999____9999999_.snap | 1 + ...ata_set____memory_xt______memory_xt__.snap | 12 ++ ..._data_set____sleep_xt______sleep_xt__.snap | 12 ++ .../Data/Challenges/ChallengesReturnTest.php | 2 +- tests/NoData/HelpersTest.php | 79 ++++++---- tests/NoData/Utilities/BenchmarkTest.php | 13 ++ tests/NoData/Utilities/Files/memory.xt | 25 ++++ tests/NoData/Utilities/Files/sample.xt | 25 ++++ tests/NoData/Utilities/Files/sleep.xt | 12 ++ 69 files changed, 506 insertions(+), 232 deletions(-) create mode 100644 app/Exceptions/BenchmarkProfileException.php create mode 100644 app/Utilities/Benchmark.php create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0_1____0_1_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0____0_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000000____100000000000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000000____10000000000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000000____1000000000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000____100000000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000____10000000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000____1000000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000____100000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000____10000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000____1000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100____100_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1____1_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___9999999999999____9999999999999_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___999999999999____999999999999_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___0_1____0_1_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___0____0_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___1000000____1000000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___100000____100000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___10000____10000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___1000____1000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___100____100_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___1____1_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___99999999____99999999_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___9999999____9999999_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___0_1____0_1_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___0____0_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___1000000____1000000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___100000____100000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___10000____10000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___1000____1000_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___100____100_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___1____1_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___99999999____99999999_.snap create mode 100644 tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___9999999____9999999_.snap create mode 100644 tests/.pest/snapshots/NoData/Utilities/BenchmarkTest/it_can_read_file_with_data_set____memory_xt______memory_xt__.snap create mode 100644 tests/.pest/snapshots/NoData/Utilities/BenchmarkTest/it_can_read_file_with_data_set____sleep_xt______sleep_xt__.snap create mode 100644 tests/NoData/Utilities/BenchmarkTest.php create mode 100644 tests/NoData/Utilities/Files/memory.xt create mode 100644 tests/NoData/Utilities/Files/sample.xt create mode 100644 tests/NoData/Utilities/Files/sleep.xt diff --git a/.env.example b/.env.example index a982e1f..d4e8cb1 100644 --- a/.env.example +++ b/.env.example @@ -12,6 +12,10 @@ LOG_LEVEL=debug # CI_MODE=local # LK_RUN_MODE=debug +# Xdebug +SAIL_XDEBUG_MODE=profile +SAIL_XDEBUG_CONFIG="client_host=host.docker.internal output_dir=/var/www/html/storage/logs/xdebug" + # Database / Main DB_CONNECTION=mysql DB_HOST=mysql diff --git a/app/Challenges/A/CleanCode.php b/app/Challenges/A/CleanCode.php index fd84aed..bf36eef 100644 --- a/app/Challenges/A/CleanCode.php +++ b/app/Challenges/A/CleanCode.php @@ -10,6 +10,8 @@ class CleanCode extends KataChallenge { + protected const MAX_INTERATIONS = 150; + public function productsMake(int $iteration): float { $productController = app()->make(ProductController::class); @@ -26,7 +28,7 @@ public function productsMake(int $iteration): float $sum += $product->price; } - return $this->return($sum); + return $sum; } public function shapes(int $iteration): float @@ -43,6 +45,6 @@ public function shapes(int $iteration): float $shapeRectangle->areaPlusCircumference(); } - return $this->return($sum); + return $sum; } } diff --git a/app/Challenges/A/CleanCodeDatabase.php b/app/Challenges/A/CleanCodeDatabase.php index 7547408..0ee299b 100644 --- a/app/Challenges/A/CleanCodeDatabase.php +++ b/app/Challenges/A/CleanCodeDatabase.php @@ -34,7 +34,7 @@ public function productsCreate(int $iteration): float $sum += $product->price; } - return $this->return($sum); + return $sum; } public function memoryAllocation(int $iteration): array @@ -51,6 +51,6 @@ public function memoryAllocation(int $iteration): array $resultArray[] = strrev($item); } - return $this->return($resultArray); + return $resultArray; } } diff --git a/app/Challenges/A/Eloquent.php b/app/Challenges/A/Eloquent.php index d340489..aa81d2a 100644 --- a/app/Challenges/A/Eloquent.php +++ b/app/Challenges/A/Eloquent.php @@ -8,76 +8,51 @@ class Eloquent extends KataChallenge { - protected const MAX_INTERATIONS = 100; + protected const MAX_INTERATIONS = 50; protected const EXPECTED_MODELS = [ User::class, ExchangeRate::class, ]; - /** - * Eloquent collections / Average - */ public function getCollectionAverage(int $iteration): float { - $value = ExchangeRate::where('id', '<=', $iteration) + return ExchangeRate::where('id', '<=', $iteration) ->get() ->average('id'); - - return $this->return($value); } - /** - * Eloquent collections / Unique - */ public function getCollectionUnique(int $iteration): iterable { - $value = ExchangeRate::all() + return ExchangeRate::query() ->where('id', '<=', $iteration) + ->get() ->pluck('id') ->unique(); - - return $this->return($value); } - /** - * Eloquent collections / Count - */ public function getCollectionCount(int $iteration): int { - $value = ExchangeRate::query() + return ExchangeRate::query() ->where('id', '<=', $iteration) ->get() ->count(); - - return $this->return($value); } - /** - * Eloquent collections / Count - * - * Don’t use a collection to count the number of related entries. - * - * See https://codeburst.io/how-to-use-laravels-eloquent-efficiently-d46f5c392ca8 - */ public function getCollectionRelatedCount(int $iteration): int { - $value = User::all() + return User::all() ->where('id', '<=', $iteration) ->last() ?->blogs->count() ?? 0; - - return $this->return($value); } public function getMaxVersusOrder(int $iteration): float { - $value = ExchangeRate::query() + return ExchangeRate::query() ->where('id', '<=', $iteration) ->orderByDesc('rate') ->first()?->rate; - - return $this->return($value); } public function eagerLoading(int $iteration): float @@ -89,6 +64,6 @@ public function eagerLoading(int $iteration): float $value += $user->blogs()->count(); } - return $this->return($value); + return $value; } } diff --git a/app/Challenges/A/Laravel.php b/app/Challenges/A/Laravel.php index ed37870..97e04b5 100644 --- a/app/Challenges/A/Laravel.php +++ b/app/Challenges/A/Laravel.php @@ -24,7 +24,7 @@ public function modelMutationVersusServiceMultiple(): float ]); } - return $this->return($total); + return $total; } protected function getCountryByIndex(int $iteration): Country diff --git a/app/Challenges/A/MySql.php b/app/Challenges/A/MySql.php index 8e03ec5..1b68db9 100644 --- a/app/Challenges/A/MySql.php +++ b/app/Challenges/A/MySql.php @@ -33,7 +33,7 @@ public function orVersusIn(int $iteration): array $value = $this->select($sql, $params); - return $this->return($value); + return $value; } public function orVersusInAggregate(int $iteration): float @@ -59,7 +59,7 @@ public function orVersusInAggregate(int $iteration): float $value = $this->selectOne($sql, $params)->rate; - return $this->return($value); + return $value; } protected function selectOne(string $sql, array $params = []): mixed diff --git a/app/Challenges/A/Php.php b/app/Challenges/A/Php.php index 068f998..53836c2 100644 --- a/app/Challenges/A/Php.php +++ b/app/Challenges/A/Php.php @@ -22,7 +22,7 @@ public function nativeRange(int $iteration): int $range[] = $i; } - return $this->return(count($range)); + return count($range); } /** @@ -39,7 +39,7 @@ public function nativeSum(int $iteration): int $total += $number; } - return $this->return($total); + return $total; } protected function getRangeLimit(int $iteration): int diff --git a/app/Challenges/A/Sample.php b/app/Challenges/A/Sample.php index 09dcb71..a934a59 100644 --- a/app/Challenges/A/Sample.php +++ b/app/Challenges/A/Sample.php @@ -19,7 +19,7 @@ public function calculatePi(): float $denominator += 2; } - return $this->return(round($sum, 2)); + return round($sum, 2); } public function fizzBuzz(int $iteration): string @@ -53,7 +53,7 @@ public function fizzBuzz(int $iteration): string $result .= $output.'|'; } - return $this->return($result); + return $result; } public function memoryAllocation(int $iteration): array @@ -70,6 +70,6 @@ public function memoryAllocation(int $iteration): array $resultArray[] = strrev($item); } - return $this->return($resultArray); + return $resultArray; } } diff --git a/app/Challenges/B/CleanCode.php b/app/Challenges/B/CleanCode.php index 799b8ff..8118a8e 100644 --- a/app/Challenges/B/CleanCode.php +++ b/app/Challenges/B/CleanCode.php @@ -26,7 +26,7 @@ public function productsMake(int $iteration): float $sum += $product->price; } - return $this->return($sum); + return $sum; } public function shapes(int $iteration): float @@ -39,6 +39,6 @@ public function shapes(int $iteration): float rectangle_area_plus_circumference(3.0 * ($i + 1), 7.0 * ($i + 1)); } - return $this->return($sum); + return $sum; } } diff --git a/app/Challenges/B/CleanCodeDatabase.php b/app/Challenges/B/CleanCodeDatabase.php index 03f09c1..248e3b9 100644 --- a/app/Challenges/B/CleanCodeDatabase.php +++ b/app/Challenges/B/CleanCodeDatabase.php @@ -24,7 +24,7 @@ public function productsCreate(int $iteration): float $sum += $product->price; } - return $this->return($sum); + return $sum; } public function memoryAllocation(int $iteration): array @@ -36,6 +36,6 @@ public function memoryAllocation(int $iteration): array $resultArray[] = strrev(str_repeat($item, 100)); } - return $this->return($resultArray); + return $resultArray; } } diff --git a/app/Challenges/B/Eloquent.php b/app/Challenges/B/Eloquent.php index 2395d68..b2e7246 100644 --- a/app/Challenges/B/Eloquent.php +++ b/app/Challenges/B/Eloquent.php @@ -10,51 +10,40 @@ class Eloquent extends AEloquent { public function getCollectionAverage(int $iteration): float { - $value = ExchangeRate::where('id', '<=', $iteration)->avg('id'); - - return $this->return($value); + return ExchangeRate::where('id', '<=', $iteration)->avg('id'); } public function getCollectionUnique(int $iteration): iterable { - $value = ExchangeRate::select('id') + return ExchangeRate::select('id') ->distinct() ->where('id', '<=', $iteration) ->pluck('id'); - - return $this->return($value); } public function getCollectionCount(int $iteration): int { - $value = ExchangeRate::where('id', '<=', $iteration)->count(); - - return $this->return($value); + return ExchangeRate::where('id', '<=', $iteration)->count(); } public function getCollectionRelatedCount(int $iteration): int { - $value = User::where('id', '<=', $iteration) + return User::where('id', '<=', $iteration) ->orderByDesc('id') ->first() ?->blogs()->count() ?? 0; - - return $this->return($value); } public function getMaxVersusOrder(int $iteration): float { - $value = ExchangeRate::where('id', '<=', $iteration)->max('rate'); - - return $this->return($value); + return ExchangeRate::where('id', '<=', $iteration)->max('rate'); } public function eagerLoading(int $iteration): float { - $value = User::with('blogs')->where('id', '<=', $iteration)->get() - ->reduce( - fn (int $total, User $user) => $total + $user->blogs->count(), 0); - - return $this->return($value); + return User::with('blogs') + ->where('id', '<=', $iteration) + ->get() + ->reduce(fn (int $total, User $user) => $total + $user->blogs->count(), 0); } } diff --git a/app/Challenges/B/Laravel.php b/app/Challenges/B/Laravel.php index c5c2583..b8bd060 100644 --- a/app/Challenges/B/Laravel.php +++ b/app/Challenges/B/Laravel.php @@ -18,6 +18,6 @@ public function modelMutationVersusServiceMultiple(): float $total += array_sum($countryService->getExchangeRatesAggregates($country)); } - return $this->return($total); + return $total; } } diff --git a/app/Challenges/B/MySql.php b/app/Challenges/B/MySql.php index 4cd97dd..b57a41e 100644 --- a/app/Challenges/B/MySql.php +++ b/app/Challenges/B/MySql.php @@ -25,7 +25,7 @@ public function orVersusIn(int $iteration): array $value = $this->select($sql, $params); - return $this->return($value); + return $value; } public function orVersusInAggregate(int $iteration): float @@ -45,6 +45,6 @@ public function orVersusInAggregate(int $iteration): float $value = $this->selectOne($sql, $params)->rate; - return $this->return($value); + return $value; } } diff --git a/app/Challenges/B/Php.php b/app/Challenges/B/Php.php index 658c2e2..6ac6a92 100644 --- a/app/Challenges/B/Php.php +++ b/app/Challenges/B/Php.php @@ -8,15 +8,11 @@ class Php extends APhp { public function nativeRange(int $iteration): int { - $value = count(range(0, $this->getRangeLimit($iteration))); - - return $this->return($value); + return count(range(0, $this->getRangeLimit($iteration))); } public function nativeSum(int $iteration): int { - $numbers = range(0, $this->getRangeLimit($iteration)); - - return $this->return(array_sum($numbers)); + return array_sum(range(0, $this->getRangeLimit($iteration))); } } diff --git a/app/Challenges/B/Sample.php b/app/Challenges/B/Sample.php index ca3d65f..8eddb82 100644 --- a/app/Challenges/B/Sample.php +++ b/app/Challenges/B/Sample.php @@ -8,7 +8,7 @@ class Sample extends ASample { public function calculatePi(): float { - return $this->return(round(M_PI, 2)); + return round(M_PI, 2); } public function fizzBuzz(int $iteration): string @@ -27,7 +27,7 @@ public function fizzBuzz(int $iteration): string $result .= $word.'|'; } - return $this->return($result); + return $result; } public function memoryAllocation(int $iteration): array @@ -39,6 +39,6 @@ public function memoryAllocation(int $iteration): array $resultArray[] = strrev(str_repeat($item, 100)); } - return $this->return($resultArray); + return $resultArray; } } diff --git a/app/Enums/KataRunnerIterationMode.php b/app/Enums/KataRunnerIterationMode.php index 7bc6482..2831b91 100644 --- a/app/Enums/KataRunnerIterationMode.php +++ b/app/Enums/KataRunnerIterationMode.php @@ -6,4 +6,5 @@ enum KataRunnerIterationMode: string { case MAX_ITERATIONS = 'max-iterations'; case MAX_SECONDS = 'max-seconds'; + case XDEBUG_PROFILE = 'xdebug-profile'; } diff --git a/app/Exceptions/BenchmarkProfileException.php b/app/Exceptions/BenchmarkProfileException.php new file mode 100644 index 0000000..687eba0 --- /dev/null +++ b/app/Exceptions/BenchmarkProfileException.php @@ -0,0 +1,9 @@ +memoryUsageStart = memory_get_usage(self::MEMORY_REAL_USAGE); - $this->maxSeconds = $this->request?->get('max-seconds') ?? config( 'laravel-kata.max-seconds', $this->maxSeconds ); $this->maxIterations = $this->request?->get('max-iterations') - ?? static::MAX_INTERATIONS - ?? config( - 'laravel-kata.max-iterations', - $this->maxIterations - ); - - $this->setUp(); - } - - public function return(mixed $value): mixed - { - $this->captureMemoryUsage(); - - return $value; - } + ?? config('laravel-kata.max-iterations', $this->maxIterations); - public function captureMemoryUsage(): void - { - $this->memoryUsageTotal ??= 0; - - $memoryUsageEnd = memory_get_usage(self::MEMORY_REAL_USAGE); - $memoryUsage = $memoryUsageEnd - $this->memoryUsageStart; - - if ($memoryUsage > 0) { - $this->memoryUsageTotal += $memoryUsage; + if (! is_null(static::MAX_INTERATIONS) && $this->maxIterations > static::MAX_INTERATIONS) { + $this->maxIterations = static::MAX_INTERATIONS; } - $this->memoryUsageStart = memory_get_usage(self::MEMORY_REAL_USAGE); - } - - public function getMemoryUsage(): int - { - if (is_null($this->memoryUsageTotal)) { - throw new KataChallengeProfilingException(sprintf( - 'Memory usage not captured for %s, did you forget to call $this->return()?', - static::class, - )); - } - - return $this->memoryUsageTotal; + $this->setUp(); } public function getMaxSeconds(): int diff --git a/app/KataRunner.php b/app/KataRunner.php index b17f271..4244f9c 100644 --- a/app/KataRunner.php +++ b/app/KataRunner.php @@ -8,10 +8,10 @@ use App\Exceptions\KataChallengeScoreException; use App\Objects\KataChallengeResultObject; use App\Traits\HasExitHintsTrait; +use App\Utilities\Benchmark; use App\Utilities\CodeUtility; use Carbon\Carbon; use Illuminate\Console\Command; -use Illuminate\Support\Benchmark; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; @@ -28,11 +28,6 @@ class KataRunner KataRunnerMode::B, ]; - protected const DEFAULT_ITERATION_MODES = [ - KataRunnerIterationMode::MAX_ITERATIONS, - KataRunnerIterationMode::MAX_SECONDS, - ]; - protected array $modes; protected array $iterationModes; @@ -77,7 +72,12 @@ public function __construct( $this->modes = self::DEFAULT_MODES; - $this->iterationModes = self::DEFAULT_ITERATION_MODES; + $this->iterationModes = config('laravel-kata.modes'); + if (app()->runningUnitTests()) { + $this->iterationModes = collect(config('laravel-kata.modes')) + ->reject(fn (string $mode) => KataRunnerIterationMode::XDEBUG_PROFILE->value) + ->values(); + } if (! is_null($this->command) && ! config('laravel-kata.progress-bar-disabled')) { $this->progressBar = $this->command?->getOutput()->createProgressBar(0); @@ -123,19 +123,23 @@ protected function printReport( ): void { $reportData = $this->getReportData($resultA, $resultB); - $getScoreRow = function (string $field, string $title = null) use ($reportData): array { + $getScoreRow = function (string $field, string $title = null, float $weight = 0.0) use ($reportData): array { $valueA = data_get($reportData, sprintf('stats.a.%s', $field)); $valueB = data_get($reportData, sprintf('stats.b.%s', $field)); $displayValueA = match ($field) { 'execution_time_avg' => time_to_human($valueA), - 'memory_usage_avg' => bytes_to_human($valueA), + 'execution_time_sum' => time_to_human($valueA), + 'profile_time_avg' => time_to_human($valueA), + 'profile_memory_usage_avg' => bytes_to_human($valueA), default => $valueA, }; $displayValueB = match ($field) { 'execution_time_avg' => time_to_human($valueB), - 'memory_usage_avg' => bytes_to_human($valueB), + 'execution_time_sum' => time_to_human($valueB), + 'profile_time_avg' => time_to_human($valueB), + 'profile_memory_usage_avg' => bytes_to_human($valueB), default => $valueB, }; @@ -144,7 +148,7 @@ protected function printReport( $performance = match ($field) { 'outputs_md5' => wrap_in_format($success ? '100%' : '0%', $success), - default => wrap_in_format(sprintf('%s%%', $gainsPerc), $success, warn: true), + default => wrap_in_format(sprintf('%s%%', round($gainsPerc)), $success, warn: true), }; return [ @@ -152,18 +156,17 @@ protected function printReport( $displayValueA, $displayValueB, $performance, + sprintf('%s: %s', number_format($weight, 2), number_format($weight * $gainsPerc, 2)), ]; }; $gainsPerc = data_get($reportData, 'stats.b.gains_perc'); - $title = sprintf( - '%s::%s (%s%%)', + '%s::%s (%sX)', $resultA->getClassName(), $resultA->getMethodName(), - $gainsPerc + round($gainsPerc / 100, 2) ); - $this->report('newLine'); $this->report( 'line', @@ -171,16 +174,15 @@ protected function printReport( ); // Show where it comes from - $this->report('line', sprintf( - 'A: %s', help_me_code($resultA->getReflectionMethod()), - )); if (config('laravel-kata.show-code-snippets')) { + $this->report('line', sprintf( + 'A: %s', help_me_code($resultA->getReflectionMethod()), + )); $this->report('comment', $resultA->getCodeSnippet()); - } - $this->report('line', sprintf( - 'B: %s', help_me_code($resultB->getReflectionMethod()), - )); - if (config('laravel-kata.show-code-snippets')) { + + $this->report('line', sprintf( + 'B: %s', help_me_code($resultB->getReflectionMethod()), + )); $this->report('comment', $resultB->getCodeSnippet()); } @@ -190,13 +192,29 @@ protected function printReport( 'A ', 'B ', 'Gains ', + 'Weighted gains ', ], [ - $getScoreRow('line_count', 'Lines'), - $getScoreRow('iteration_count', 'Iterations'), - $getScoreRow('execution_time_avg', 'Execution time'), - $getScoreRow('memory_usage_avg', 'Memory usage'), - ] + $getScoreRow('violations_count', 'Code / Violations', 0.05), + $getScoreRow('line_count', 'Code / Lines', 0.05), + $getScoreRow('iteration_count', sprintf( + 'Benchmark / Iterations in %ss', + config('laravel-kata.max-seconds'), + ), 0.20), + $getScoreRow('execution_time_sum', sprintf( + 'Benchmark / Execution time for %dx', + data_get($reportData, 'stats.a._result.max-iterations.iteration_count', 52), + ), 0.20), + $getScoreRow('profile_time_avg', 'Profiling / Execution time (avg)', 0.25), + $getScoreRow('profile_memory_usage_avg', 'Profiling / Memory usage (avg)', 0.25), + [ + '', + '', + '', + '', + sprintf('1.00: %s', number_format($gainsPerc, 2)), + ], + ], ); if (! data_get($reportData, 'stats.b.outputs_md5_gains_success')) { @@ -285,8 +303,10 @@ protected function calculateGains(array $statsA, array $statsB): array 'line_count' => 'lt', 'violations_count' => 'lt', 'iteration_count' => 'gt', - 'memory_usage_avg' => 'lt', + 'profile_memory_usage_avg' => 'lt', 'execution_time_avg' => 'lt', + 'execution_time_sum' => 'lt', + 'profile_time_avg' => 'lt', ]; foreach ($fields as $field => $mode) { @@ -306,7 +326,7 @@ protected function calculateGains(array $statsA, array $statsB): array $percDiff = 100; } else { $percDiff = $value1 != 0 - ? round(abs(($value1 - $value2) / $value1) * 100, 2) + ? abs(($value1 - $value2) / $value1) * 100 : 0; } @@ -329,10 +349,12 @@ protected function calculateGains(array $statsA, array $statsB): array } $gainsWeights = [ + 'violations_count_gains_perc' => 0.05, 'line_count_gains_perc' => 0.05, - 'memory_usage_avg_gains_perc' => 0.25, - 'iteration_count_gains_perc' => 0.35, - 'execution_time_avg_gains_perc' => 0.35, + 'iteration_count_gains_perc' => 0.20, + 'execution_time_sum_gains_perc' => 0.20, + 'profile_time_avg_gains_perc' => 0.25, + 'profile_memory_usage_avg_gains_perc' => 0.25, ]; $statsB['gains_perc'] = collect($gainsWeights)->map( @@ -468,7 +490,6 @@ protected function runChallengeMethod( $maxSeconds, ); - $challengeOutputs['memory_usage_peak'] = memory_get_peak_usage(false); $result[$iterationMode->value] = $challengeOutputs; } @@ -507,6 +528,9 @@ protected function runChallengeMethodMaxMode( KataRunnerIterationMode::MAX_SECONDS => $this->runChallengeMethodMaxSeconds( $reflectionMethod, $maxSeconds + ), + KataRunnerIterationMode::XDEBUG_PROFILE => $this->runChallengeMethodProfile( + $reflectionMethod, ) }; @@ -531,7 +555,6 @@ protected function runChallengeMethodMaxIterations( } $executionTimeSum = 0; - $memoryUsageSum = 0; $startTime = microtime(true); $outputs = []; @@ -549,7 +572,6 @@ protected function runChallengeMethodMaxIterations( $outputs[] = $instance->{$methodName}($iteration + 1); }); - $memoryUsageSum += $instance->getMemoryUsage(); $this->progressBar?->advance(); } @@ -569,8 +591,6 @@ protected function runChallengeMethodMaxIterations( 'outputs_json' => json_encode($outputs), 'outputs_md5' => $outputsMd5, 'iteration_count' => $iterationCount, - 'memory_usage_sum' => $memoryUsageSum, - 'memory_usage_avg' => $memoryUsageSum / $iterationCount, 'execution_time' => microtime(true) - $startTime, 'execution_time_sum' => $executionTimeSum, 'execution_time_avg' => $executionTimeSum / $iterationCount, @@ -591,7 +611,6 @@ protected function runChallengeMethodMaxSeconds( } $executionTimeSum = 0; - $memoryUsageSum = 0; $startTime = microtime(true); $msMax = $maxSeconds * 1000; $dateTimeEnd = now()->addMilliseconds($msMax); @@ -607,7 +626,6 @@ protected function runChallengeMethodMaxSeconds( $executionTimeSum += Benchmark::measure(function () use ($instance, $methodName, $iteration, &$outputs) { $outputs[] = $instance->{$methodName}($iteration); }); - $memoryUsageSum += $instance->getMemoryUsage(); $this->progressBar?->setProgress($msMax - $msLeft); $this->progressBar?->setMessage(sprintf( @@ -635,11 +653,21 @@ protected function runChallengeMethodMaxSeconds( 'outputs_md5' => $outputsMd5, 'outputs' => $outputs, 'iteration_count' => $iteration, - 'memory_usage_sum' => $memoryUsageSum, - 'memory_usage_avg' => $memoryUsageSum / $iteration, 'execution_time' => microtime(true) - $startTime, 'execution_time_sum' => $executionTimeSum, 'execution_time_avg' => $executionTimeSum / $iteration, ]; } + + protected function runChallengeMethodProfile(ReflectionMethod $reflectionMethod): array + { + $className = $reflectionMethod->class; + /** @var \App\KataChallenge $instance */ + $instance = app()->make($className); + $methodName = $reflectionMethod->name; + + $maxIterations = ceil($instance->getMaxIterations() / 2); + + return Benchmark::profile(fn () => $instance->{$methodName}($maxIterations), maxIterations: $maxIterations); + } } diff --git a/app/Objects/KataChallengeResultObject.php b/app/Objects/KataChallengeResultObject.php index 85f8ba4..29054fe 100644 --- a/app/Objects/KataChallengeResultObject.php +++ b/app/Objects/KataChallengeResultObject.php @@ -45,14 +45,21 @@ public function getStats(): array $violations = $this->getViolations(); return [ + '_result' => $this->result, // Why normalize? + 'violations' => $violations, 'violations_count' => count($violations), 'iteration_count' => $this->getStat('iteration_count', KataRunnerIterationMode::MAX_SECONDS), 'outputs_md5' => $this->getStat('outputs_md5', KataRunnerIterationMode::MAX_ITERATIONS), - 'execution_time_avg' => $this->getExecutionTimeAvg(), - 'memory_usage_avg' => $this->getMemoryUsageAvg(), + 'execution_time_avg' => $this->getStat('execution_time_avg', KataRunnerIterationMode::MAX_ITERATIONS), + 'execution_time_sum' => $this->getStat('execution_time_sum', KataRunnerIterationMode::MAX_ITERATIONS), + + 'profile_memory_usage_avg' => $this->result[KataRunnerIterationMode::XDEBUG_PROFILE->value]['memory_usage']['total'] / 100, + 'profile_time_avg' => $this->result[KataRunnerIterationMode::XDEBUG_PROFILE->value]['time']['total'] / 100, + // 'profile_memory_usage_avg' => $this->result['profile']['memory_usage']['total'] / 100, + // 'profile_time_avg' => $this->result['profile']['time']['total'] / 100, 'line_count' => $this->reflectionMethod->getEndLine() - $this->reflectionMethod->getStartLine(), ]; @@ -74,22 +81,6 @@ public function getStat( return array_sum($values); } - public function getExecutionTimeAvg(): float - { - $count = $this->getStat('iteration_count', KataRunnerIterationMode::MAX_ITERATIONS); - $sum = $this->getStat('execution_time_sum', KataRunnerIterationMode::MAX_ITERATIONS); - - return $sum / $count; - } - - public function getMemoryUsageAvg(): float - { - $count = $this->getStat('iteration_count', KataRunnerIterationMode::MAX_ITERATIONS); - $sum = $this->getStat('memory_usage_sum', KataRunnerIterationMode::MAX_ITERATIONS); - - return $sum / $count; - } - public function getOutputsJson( KataRunnerIterationMode $kataRunnerIterationMode = KataRunnerIterationMode::MAX_ITERATIONS, ): mixed { diff --git a/app/Services/ExchangeRateService.php b/app/Services/ExchangeRateService.php index 14a824f..9412936 100644 --- a/app/Services/ExchangeRateService.php +++ b/app/Services/ExchangeRateService.php @@ -20,6 +20,16 @@ class ExchangeRateService public function getCurrencies(): CurrencyCollection { + if (app()->runningUnitTests()) { + $currencies = collect(CurrencyCode::cases()) + ->map(fn (CurrencyCode $currencyCode) => Currency::make([ + 'code' => $currencyCode, + 'name' => $currencyCode->value, + ])); + + return CurrencyCollection::make($currencies); + } + $codes = CurrencyCode::all()->pluck('code'); $response = Http::get(sprintf('%s/symbols', self::API_HOST)); $symbols = collect($response->json('symbols')) diff --git a/app/Utilities/Benchmark.php b/app/Utilities/Benchmark.php new file mode 100644 index 0000000..1d66f9c --- /dev/null +++ b/app/Utilities/Benchmark.php @@ -0,0 +1,135 @@ + $memoryUsageMax) { + $memoryUsageMax = $memoryUsageLine; + } + + $end = $lineParts; + if ($functionName === 'xdebug_stop_trace') { + break; + } + + } + + if (is_null($start)) { + throw new BenchmarkProfileException('No start found'); + } + + $timeStart = floatval(self::getTraceLineValue($start, 'time')); + $timeEnd = floatval(self::getTraceLineValue($end, 'time')); + $time = $timeEnd - $timeStart; + + $memoryUsageStart = floatval(self::getTraceLineValue($start, 'memory_usage')); + $memoryUsage = $memoryUsageMax - $memoryUsageStart; + + return [ + 'time' => [ + 'start' => $timeStart, + 'end' => $timeEnd, + 'total' => $time, + ], + 'memory_usage' => [ + 'start' => $memoryUsageStart, + 'end' => $memoryUsageMax, + 'total' => $memoryUsage < 0 ? 0 : $memoryUsage, + ], + ]; + } + + public static function profile( + Closure $benchmarkable, + int $maxIterations = 1, + int $maxTries = 3 + ): array { + if ($maxTries <= 0) { + throw new BenchmarkProfileException('Max tries failed'); + } + + // Might want to save the static file for debugging... + // copy($tempFilePath.'.xt', sprintf('/var/www/html/sample-memory-%s.xt', now()->format('ymd_His'))); + + try { + $tempFile = tmpfile(); + $tempFilePath = stream_get_meta_data($tempFile)['uri']; + xdebug_start_trace($tempFilePath, XDEBUG_TRACE_COMPUTERIZED); + $benchmarkable(); + xdebug_stop_trace(); + + return [ + ...self::profileGetStats($tempFilePath), + 'max_iterations' => $maxIterations, + ]; + } catch (BenchmarkProfileException $exception) { + return self::profile($benchmarkable, $maxIterations, $maxTries - 1); + } finally { + unlink($tempFilePath.'.xt'); + } + } +} diff --git a/app/helpers.php b/app/helpers.php index 7204b35..abc79fe 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -45,21 +45,41 @@ function wrap_in_format(string $string, bool $success, bool $warn = false): stri if (! function_exists('bytes_to_human')) { function bytes_to_human(float $bytes): string { - $precision = 5; + $precision = 9; $units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; $factor = floor((strlen($bytes) - 1) / 3); return sprintf( - "%.{$precision}f %s", - $bytes / (1024 ** $factor), + '%s %s', + number_format($bytes / (1024 ** $factor), $precision), $units[$factor] ); } } if (! function_exists('time_to_human')) { - function time_to_human(float $milliseconds): string + function time_to_human(float $milliseconds, bool $digital = true): string { - return sprintf('%s ms', number_format($milliseconds, 5)); + return $digital ? ms_to_time($milliseconds) : sprintf('%s s', number_format($milliseconds, 9)); + } +} + +if (! function_exists('ms_to_time')) { + function ms_to_time(float $milliseconds) + { + $seconds = floor($milliseconds / 1000); + $minutes = floor($seconds / 60); + $hours = floor($minutes / 60); + + $minutes = $minutes - ($hours * 60); + $seconds = $seconds - ($hours * 60 * 60) - ($minutes * 60); + $ms = $milliseconds % 1000; + + $timeFormat = sprintf('%02d:%02d:%02d.%03d', $hours, $minutes, $seconds, $ms); + if ($timeFormat === '00:00:00.000') { + return time_to_human($milliseconds, false); + } + + return $timeFormat; } } diff --git a/config/laravel-kata.php b/config/laravel-kata.php index e37510c..9b3dc09 100644 --- a/config/laravel-kata.php +++ b/config/laravel-kata.php @@ -8,6 +8,7 @@ use App\Challenges\A\Php; use App\Challenges\A\Sample; use App\Enums\KataRunMode; +use App\Enums\KataRunnerIterationMode; use App\Exceptions\KataInvalidRunModeException; $runMode = KataRunMode::tryFrom(env('LK_RUN_MODE', KataRunMode::DEBUG->value)); @@ -17,8 +18,10 @@ $defaults = match ($runMode) { KataRunMode::DEBUG => [ - 'LK_MAX_SECONDS' => 1, - 'LK_MAX_ITERATIONS' => 100, + // 'LK_MAX_SECONDS' => 1, + // 'LK_MAX_ITERATIONS' => 1, + 'LK_MAX_SECONDS' => 3, + 'LK_MAX_ITERATIONS' => 1000, 'LK_DD_MAX_USERS' => 1, 'LK_DD_MAX_USER_BLOGS' => 3, @@ -57,6 +60,12 @@ 'max-iterations' => $getValue('LK_MAX_ITERATIONS'), 'progress-bar-disabled' => env('LK_PROGRESS_BAR_DISABLED', false), + 'modes' => [ + KataRunnerIterationMode::MAX_ITERATIONS, + KataRunnerIterationMode::MAX_SECONDS, + KataRunnerIterationMode::XDEBUG_PROFILE, + ], + // To be converted to env variables 'save-results-to-storage' => true, 'debug-mode' => false, diff --git a/phpunit.xml b/phpunit.xml index 87462b1..dd035f2 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -28,8 +28,8 @@ - - + + diff --git a/routes/api.php b/routes/api.php index 32406d7..8117d8e 100644 --- a/routes/api.php +++ b/routes/api.php @@ -20,18 +20,12 @@ return $request->user(); }); -/** - * A teapot for Jason - */ Route::any('/', function (Request $request) { $message = "I'm a teapot!"; return response($message, 418); }); -/** - * Check the app health - */ Route::get('health', function (Request $request) { return JsonResource::make([ 'success' => true, diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0_1____0_1_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0_1____0_1_.snap new file mode 100644 index 0000000..4a8c96c --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0_1____0_1_.snap @@ -0,0 +1 @@ +0.100000000 B \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0____0_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0____0_.snap new file mode 100644 index 0000000..c56a114 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0____0_.snap @@ -0,0 +1 @@ +0.000000000 B \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000000____100000000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000000____100000000000_.snap new file mode 100644 index 0000000..332d5f9 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000000____100000000000_.snap @@ -0,0 +1 @@ +93.132257462 GB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000000____10000000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000000____10000000000_.snap new file mode 100644 index 0000000..8ca44e4 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000000____10000000000_.snap @@ -0,0 +1 @@ +9.313225746 GB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000000____1000000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000000____1000000000_.snap new file mode 100644 index 0000000..74fb4da --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000000____1000000000_.snap @@ -0,0 +1 @@ +0.931322575 GB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000____100000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000____100000000_.snap new file mode 100644 index 0000000..6112ff5 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000____100000000_.snap @@ -0,0 +1 @@ +95.367431641 MB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000____10000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000____10000000_.snap new file mode 100644 index 0000000..cb88f1d --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000____10000000_.snap @@ -0,0 +1 @@ +9.536743164 MB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000____1000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000____1000000_.snap new file mode 100644 index 0000000..c9549ef --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000____1000000_.snap @@ -0,0 +1 @@ +0.953674316 MB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000____100000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000____100000_.snap new file mode 100644 index 0000000..72cc351 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000____100000_.snap @@ -0,0 +1 @@ +97.656250000 kB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000____10000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000____10000_.snap new file mode 100644 index 0000000..3297585 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000____10000_.snap @@ -0,0 +1 @@ +9.765625000 kB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000____1000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000____1000_.snap new file mode 100644 index 0000000..76ed606 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000____1000_.snap @@ -0,0 +1 @@ +0.976562500 kB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100____100_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100____100_.snap new file mode 100644 index 0000000..c0c625f --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100____100_.snap @@ -0,0 +1 @@ +100.000000000 B \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1____1_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1____1_.snap new file mode 100644 index 0000000..e834229 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1____1_.snap @@ -0,0 +1 @@ +1.000000000 B \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___9999999999999____9999999999999_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___9999999999999____9999999999999_.snap new file mode 100644 index 0000000..a4e6526 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___9999999999999____9999999999999_.snap @@ -0,0 +1 @@ +9.094947018 TB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___999999999999____999999999999_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___999999999999____999999999999_.snap new file mode 100644 index 0000000..3a0fd0e --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___999999999999____999999999999_.snap @@ -0,0 +1 @@ +931.322574615 GB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___0_1____0_1_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___0_1____0_1_.snap new file mode 100644 index 0000000..65402ca --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___0_1____0_1_.snap @@ -0,0 +1 @@ +0.100000000 s \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___0____0_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___0____0_.snap new file mode 100644 index 0000000..68d7b97 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___0____0_.snap @@ -0,0 +1 @@ +0.000000000 s \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___1000000____1000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___1000000____1000000_.snap new file mode 100644 index 0000000..9408260 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___1000000____1000000_.snap @@ -0,0 +1 @@ +00:16:40.000 \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___100000____100000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___100000____100000_.snap new file mode 100644 index 0000000..ba224c0 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___100000____100000_.snap @@ -0,0 +1 @@ +00:01:40.000 \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___10000____10000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___10000____10000_.snap new file mode 100644 index 0000000..3fb59fa --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___10000____10000_.snap @@ -0,0 +1 @@ +00:00:10.000 \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___1000____1000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___1000____1000_.snap new file mode 100644 index 0000000..d6035cf --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___1000____1000_.snap @@ -0,0 +1 @@ +00:00:01.000 \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___100____100_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___100____100_.snap new file mode 100644 index 0000000..6f45589 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___100____100_.snap @@ -0,0 +1 @@ +00:00:00.100 \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___1____1_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___1____1_.snap new file mode 100644 index 0000000..fe1aaab --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___1____1_.snap @@ -0,0 +1 @@ +00:00:00.001 \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___99999999____99999999_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___99999999____99999999_.snap new file mode 100644 index 0000000..01cc3cd --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___99999999____99999999_.snap @@ -0,0 +1 @@ +27:46:39.999 \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___9999999____9999999_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___9999999____9999999_.snap new file mode 100644 index 0000000..6997e1e --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__digital__with_data_set___9999999____9999999_.snap @@ -0,0 +1 @@ +02:46:39.999 \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___0_1____0_1_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___0_1____0_1_.snap new file mode 100644 index 0000000..65402ca --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___0_1____0_1_.snap @@ -0,0 +1 @@ +0.100000000 s \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___0____0_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___0____0_.snap new file mode 100644 index 0000000..68d7b97 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___0____0_.snap @@ -0,0 +1 @@ +0.000000000 s \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___1000000____1000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___1000000____1000000_.snap new file mode 100644 index 0000000..cbeb8ba --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___1000000____1000000_.snap @@ -0,0 +1 @@ +1,000,000.000000000 s \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___100000____100000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___100000____100000_.snap new file mode 100644 index 0000000..6d6a358 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___100000____100000_.snap @@ -0,0 +1 @@ +100,000.000000000 s \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___10000____10000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___10000____10000_.snap new file mode 100644 index 0000000..90c1923 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___10000____10000_.snap @@ -0,0 +1 @@ +10,000.000000000 s \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___1000____1000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___1000____1000_.snap new file mode 100644 index 0000000..1d0ba0d --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___1000____1000_.snap @@ -0,0 +1 @@ +1,000.000000000 s \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___100____100_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___100____100_.snap new file mode 100644 index 0000000..d24fd24 --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___100____100_.snap @@ -0,0 +1 @@ +100.000000000 s \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___1____1_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___1____1_.snap new file mode 100644 index 0000000..465800b --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___1____1_.snap @@ -0,0 +1 @@ +1.000000000 s \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___99999999____99999999_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___99999999____99999999_.snap new file mode 100644 index 0000000..c44358a --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___99999999____99999999_.snap @@ -0,0 +1 @@ +99,999,999.000000000 s \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___9999999____9999999_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___9999999____9999999_.snap new file mode 100644 index 0000000..6c3e8fb --- /dev/null +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_time_to_human__false__with_data_set___9999999____9999999_.snap @@ -0,0 +1 @@ +9,999,999.000000000 s \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/Utilities/BenchmarkTest/it_can_read_file_with_data_set____memory_xt______memory_xt__.snap b/tests/.pest/snapshots/NoData/Utilities/BenchmarkTest/it_can_read_file_with_data_set____memory_xt______memory_xt__.snap new file mode 100644 index 0000000..39f0a83 --- /dev/null +++ b/tests/.pest/snapshots/NoData/Utilities/BenchmarkTest/it_can_read_file_with_data_set____memory_xt______memory_xt__.snap @@ -0,0 +1,12 @@ +{ + "time": { + "start": 1.607359, + "end": 1.607404, + "total": 4.500000000007276e-5 + }, + "memory_usage": { + "start": 25400640, + "end": 25402024, + "total": 1384 + } +} \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/Utilities/BenchmarkTest/it_can_read_file_with_data_set____sleep_xt______sleep_xt__.snap b/tests/.pest/snapshots/NoData/Utilities/BenchmarkTest/it_can_read_file_with_data_set____sleep_xt______sleep_xt__.snap new file mode 100644 index 0000000..24d776d --- /dev/null +++ b/tests/.pest/snapshots/NoData/Utilities/BenchmarkTest/it_can_read_file_with_data_set____sleep_xt______sleep_xt__.snap @@ -0,0 +1,12 @@ +{ + "time": { + "start": 4.350688, + "end": 7.353963, + "total": 3.0032750000000004 + }, + "memory_usage": { + "start": 25029952, + "end": 25029952, + "total": 0 + } +} \ No newline at end of file diff --git a/tests/Data/Challenges/ChallengesReturnTest.php b/tests/Data/Challenges/ChallengesReturnTest.php index c78f251..59ab1a7 100644 --- a/tests/Data/Challenges/ChallengesReturnTest.php +++ b/tests/Data/Challenges/ChallengesReturnTest.php @@ -16,4 +16,4 @@ expect($returnB)->not->toBeEmpty(); expect($returnA)->toEqual($returnB); -})->with([1, 10, 100])->with('challenge-methods'); +})->with([1, 3])->with('challenge-methods'); diff --git a/tests/NoData/HelpersTest.php b/tests/NoData/HelpersTest.php index e962e2d..6580032 100644 --- a/tests/NoData/HelpersTest.php +++ b/tests/NoData/HelpersTest.php @@ -44,47 +44,64 @@ ['is false (warn)', false, true, 'is false (warn)'], ]); -it('can convert bytes to human', function (float $bytes, string $expected) { +it('can convert bytes to human', function (float $bytes) { $human = bytes_to_human($bytes); - expect($human)->toBe($expected); + expect($human)->toMatchSnapshot(); })->with([ - [0, '0.00000 B'], - [0.1, '0.10000 B'], - [1, '1.00000 B'], - [100, '100.00000 B'], - [1000, '0.97656 kB'], - [10000, '9.76562 kB'], - [100000, '97.65625 kB'], - [1000000, '0.95367 MB'], - [10000000, '9.53674 MB'], - [100000000, '95.36743 MB'], - [1000000000, '0.93132 GB'], - [10000000000, '9.31323 GB'], - [100000000000, '93.13226 GB'], - [999999999999, '931.32257 GB'], - [9999999999999, '9.09495 TB'], + 0, + 0.1, + 1, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000, + 10000000000, + 100000000000, + 999999999999, + 9999999999999, ]); -it('can convert time to human', function (float $bytes, string $expected) { - $human = time_to_human($bytes); +it('can convert time to human (digital)', function (float $bytes) { + $human = time_to_human($bytes, digital: true); - expect($human)->toBe($expected); + expect($human)->toMatchSnapshot(); })->with([ - [0, '0.00000 ms'], - [0.1, '0.10000 ms'], - [1, '1.00000 ms'], - [100, '100.00000 ms'], - [1000, '1,000.00000 ms'], - [10000, '10,000.00000 ms'], - [100000, '100,000.00000 ms'], - [1000000, '1,000,000.00000 ms'], - [9999999, '9,999,999.00000 ms'], - [99999999, '99,999,999.00000 ms'], + 0, + 0.1, + 1, + 100, + 1000, + 10000, + 100000, + 1000000, + 9999999, + 99999999, +]); + +it('can convert time to human (false)', function (float $bytes) { + $human = time_to_human($bytes, digital: false); + + expect($human)->toMatchSnapshot(); +})->with([ + 0, + 0.1, + 1, + 100, + 1000, + 10000, + 100000, + 1000000, + 9999999, + 99999999, ]); it('will not redefine functions', function () { include 'app/helpers.php'; - expect(time_to_human(0))->toBe('0.00000 ms'); + expect(time_to_human(0))->toBe('0.000000000 s'); }); diff --git a/tests/NoData/Utilities/BenchmarkTest.php b/tests/NoData/Utilities/BenchmarkTest.php new file mode 100644 index 0000000..adfb7d6 --- /dev/null +++ b/tests/NoData/Utilities/BenchmarkTest.php @@ -0,0 +1,13 @@ +toMatchSnapshot(); +})->with([ + 'sleep.xt', + 'memory.xt', +]); diff --git a/tests/NoData/Utilities/Files/memory.xt b/tests/NoData/Utilities/Files/memory.xt new file mode 100644 index 0000000..42d162f --- /dev/null +++ b/tests/NoData/Utilities/Files/memory.xt @@ -0,0 +1,25 @@ +Version: 3.2.1 +File format: 4 +TRACE START [2023-09-17 18:55:32.313909] +22 438545 0 1.607350 25400640 App\KataRunner->App\{closure:/var/www/html/app/KataRunner.php:659-659} 1 /var/www/html/app/Utilities/Benchmark.php 106 0 +23 438546 0 1.607359 25400640 App\Challenges\A\Sample->memoryAllocation 1 /var/www/html/app/KataRunner.php 659 1 3 +24 438547 0 1.607367 25400640 range 0 /var/www/html/app/Challenges/A/Sample.php 68 2 1 3 +24 438547 1 1.607372 25400920 +24 438548 0 1.607374 25400856 str_repeat 0 /var/www/html/app/Challenges/A/Sample.php 72 2 1 100 +24 438548 1 1.607377 25401080 +24 438549 0 1.607379 25401232 str_repeat 0 /var/www/html/app/Challenges/A/Sample.php 72 2 2 100 +24 438549 1 1.607381 25401456 +24 438550 0 1.607382 25401392 str_repeat 0 /var/www/html/app/Challenges/A/Sample.php 72 2 3 100 +24 438550 1 1.607384 25401616 +24 438551 0 1.607385 25401552 strrev 0 /var/www/html/app/Challenges/A/Sample.php 77 1 '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111' +24 438551 1 1.607389 25401712 +24 438552 0 1.607390 25401896 strrev 0 /var/www/html/app/Challenges/A/Sample.php 77 1 '2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222' +24 438552 1 1.607392 25402056 +24 438553 0 1.607393 25402024 strrev 0 /var/www/html/app/Challenges/A/Sample.php 77 1 '3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333' +24 438553 1 1.607395 25402184 +23 438546 1 1.607399 25401240 +22 438545 1 1.607403 25400640 +22 438554 0 1.607404 25400640 xdebug_stop_trace 0 /var/www/html/app/Utilities/Benchmark.php 108 0 + 1.607406 25400688 +TRACE END [2023-09-17 18:55:32.314016] + diff --git a/tests/NoData/Utilities/Files/sample.xt b/tests/NoData/Utilities/Files/sample.xt new file mode 100644 index 0000000..3e5a71e --- /dev/null +++ b/tests/NoData/Utilities/Files/sample.xt @@ -0,0 +1,25 @@ +Version: 3.2.1 +File format: 4 +TRACE START [2023-09-17 18:08:26.147880] +22 442274 0 1.724884 25397288 App\KataRunner->App\{closure:/var/www/html/app/KataRunner.php:659-659} 1 /var/www/html/app/Utilities/Benchmark.php 77 0 +23 442275 0 1.724897 25397288 App\Challenges\A\Sample->memoryAllocation 1 /var/www/html/app/KataRunner.php 659 1 3 +24 442276 0 1.724911 25397288 range 0 /var/www/html/app/Challenges/A/Sample.php 68 2 1 3 +24 442276 1 1.724916 25397568 +24 442277 0 1.724917 25397504 str_repeat 0 /var/www/html/app/Challenges/A/Sample.php 72 2 1 100 +24 442277 1 1.724921 25397728 +24 442278 0 1.724922 25397880 str_repeat 0 /var/www/html/app/Challenges/A/Sample.php 72 2 2 100 +24 442278 1 1.724924 25398104 +24 442279 0 1.724925 25398040 str_repeat 0 /var/www/html/app/Challenges/A/Sample.php 72 2 3 100 +24 442279 1 1.724927 25398264 +24 442280 0 1.724928 25398200 strrev 0 /var/www/html/app/Challenges/A/Sample.php 77 1 '1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111' +24 442280 1 1.724932 25398360 +24 442281 0 1.724933 25398544 strrev 0 /var/www/html/app/Challenges/A/Sample.php 77 1 '2222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222' +24 442281 1 1.724935 25398704 +24 442282 0 1.724936 25398672 strrev 0 /var/www/html/app/Challenges/A/Sample.php 77 1 '3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333' +24 442282 1 1.724937 25398832 +23 442275 1 1.724941 25397888 +22 442274 1 1.724944 25397288 +22 442283 0 1.724946 25397288 xdebug_stop_trace 0 /var/www/html/app/Utilities/Benchmark.php 79 0 + 1.724947 25397336 +TRACE END [2023-09-17 18:08:26.148000] + diff --git a/tests/NoData/Utilities/Files/sleep.xt b/tests/NoData/Utilities/Files/sleep.xt new file mode 100644 index 0000000..91fe280 --- /dev/null +++ b/tests/NoData/Utilities/Files/sleep.xt @@ -0,0 +1,12 @@ +Version: 3.2.1 +File format: 4 +TRACE START [2023-09-17 18:29:00.168759] +22 54731 0 4.350674 25029952 App\KataRunner->App\{closure:/var/www/html/app/KataRunner.php:659-659} 1 /var/www/html/app/Utilities/Benchmark.php 100 0 +23 54732 0 4.350688 25029952 App\Challenges\A\Sample->sleep 1 /var/www/html/app/KataRunner.php 659 1 3 +24 54733 0 4.350712 25029952 sleep 0 /var/www/html/app/Challenges/A/Sample.php 11 1 3 +24 54733 1 7.352751 25029984 +23 54732 1 7.353625 25029952 +22 54731 1 7.353879 25029952 +22 54734 0 7.353963 25029952 xdebug_stop_trace 0 /var/www/html/app/Utilities/Benchmark.php 102 0 + 7.353992 25030000 +TRACE END [2023-09-17 18:29:03.172198] From 66c3c9bf0f02e6f42a135c44bd2d00f6b5f82ef6 Mon Sep 17 00:00:00 2001 From: Hendrik Prinsloo Date: Tue, 19 Sep 2023 23:24:21 +0200 Subject: [PATCH 02/11] Fixed tests --- app/Challenges/A/Sample.php | 6 ++-- app/Challenges/B/Sample.php | 6 ++-- app/KataRunner.php | 33 +++++++++++++------ app/Objects/KataChallengeResultObject.php | 15 ++++++--- app/Utilities/Benchmark.php | 6 +++- app/helpers.php | 4 +-- ..._to_human_with_data_set___0_1____0_1_.snap | 2 +- ...ytes_to_human_with_data_set___0____0_.snap | 2 +- ...a_set___100000000000____100000000000_.snap | 2 +- ...ata_set___10000000000____10000000000_.snap | 2 +- ..._data_set___1000000000____1000000000_.snap | 2 +- ...th_data_set___100000000____100000000_.snap | 2 +- ...with_data_set___10000000____10000000_.snap | 2 +- ...n_with_data_set___1000000____1000000_.snap | 2 +- ...man_with_data_set___100000____100000_.snap | 2 +- ...human_with_data_set___10000____10000_.snap | 2 +- ...o_human_with_data_set___1000____1000_.snap | 2 +- ..._to_human_with_data_set___100____100_.snap | 2 +- ...ytes_to_human_with_data_set___1____1_.snap | 2 +- ...set___9999999999999____9999999999999_.snap | 2 +- ...a_set___999999999999____999999999999_.snap | 2 +- .../Data/Challenges/ChallengesReturnTest.php | 26 ++++++++++++--- .../Commands/FakeChallenges/A/NotFound.php | 2 +- .../Commands/FakeChallenges/A/TooSlow.php | 2 +- .../Commands/FakeChallenges/A/WrongOutput.php | 2 +- .../Commands/FakeChallenges/B/TooSlow.php | 2 +- .../Commands/FakeChallenges/B/WrongOutput.php | 2 +- .../Commands/KataProfileCommandTest.php | 2 +- .../Console/Commands/KataRunCommandTest.php | 27 +++++++++------ tests/TestCaseData.php | 4 ++- 30 files changed, 108 insertions(+), 61 deletions(-) diff --git a/app/Challenges/A/Sample.php b/app/Challenges/A/Sample.php index a934a59..3f7ee24 100644 --- a/app/Challenges/A/Sample.php +++ b/app/Challenges/A/Sample.php @@ -56,13 +56,13 @@ public function fizzBuzz(int $iteration): string return $result; } - public function memoryAllocation(int $iteration): array + public function memoryAllocation(int $iteration): string { $largeArray = range(1, $iteration); $tempArray = []; foreach ($largeArray as $item) { - $tempArray[] = str_repeat($item, 100); + $tempArray[] = str_repeat($item, floor($iteration / 10) + 1); } $resultArray = []; @@ -70,6 +70,6 @@ public function memoryAllocation(int $iteration): array $resultArray[] = strrev($item); } - return $resultArray; + return md5(implode('|', $resultArray)); } } diff --git a/app/Challenges/B/Sample.php b/app/Challenges/B/Sample.php index 8eddb82..282c34b 100644 --- a/app/Challenges/B/Sample.php +++ b/app/Challenges/B/Sample.php @@ -30,15 +30,15 @@ public function fizzBuzz(int $iteration): string return $result; } - public function memoryAllocation(int $iteration): array + public function memoryAllocation(int $iteration): string { $largeArray = range(1, $iteration); $resultArray = []; foreach ($largeArray as $item) { - $resultArray[] = strrev(str_repeat($item, 100)); + $resultArray[] = strrev(str_repeat($item, floor($iteration / 10) + 1)); } - return $resultArray; + return md5(implode('|', $resultArray)); } } diff --git a/app/KataRunner.php b/app/KataRunner.php index 4244f9c..ebdfab3 100644 --- a/app/KataRunner.php +++ b/app/KataRunner.php @@ -75,8 +75,9 @@ public function __construct( $this->iterationModes = config('laravel-kata.modes'); if (app()->runningUnitTests()) { $this->iterationModes = collect(config('laravel-kata.modes')) - ->reject(fn (string $mode) => KataRunnerIterationMode::XDEBUG_PROFILE->value) - ->values(); + ->reject(fn (KataRunnerIterationMode $mode) => $mode === KataRunnerIterationMode::XDEBUG_PROFILE) + ->values() + ->toArray(); } if (! is_null($this->command) && ! config('laravel-kata.progress-bar-disabled')) { @@ -127,6 +128,16 @@ protected function printReport( $valueA = data_get($reportData, sprintf('stats.a.%s', $field)); $valueB = data_get($reportData, sprintf('stats.b.%s', $field)); + if (is_null($valueA) || is_null($valueB)) { + return [ + $title ?: $field, + $valueA, + $valueB, + 'N/A', + 'N/A', + ]; + } + $displayValueA = match ($field) { 'execution_time_avg' => time_to_human($valueA), 'execution_time_sum' => time_to_human($valueA), @@ -311,10 +322,14 @@ protected function calculateGains(array $statsA, array $statsB): array foreach ($fields as $field => $mode) { $success = false; - $value1 = $statsB[$field]; - $value2 = $statsA[$field]; + $value1 = data_get($statsB, $field); + $value2 = data_get($statsA, $field); - if (in_array($mode, ['lt', 'gt'])) { + if (is_null($value1) || is_null($value2)) { + $gains = 'N/A'; + $percDiff = 0; + $success = false; + } elseif (in_array($mode, ['lt', 'gt'])) { if ($mode === 'gt') { $value1 = $value2; $value2 = $statsB[$field]; @@ -335,9 +350,7 @@ protected function calculateGains(array $statsA, array $statsB): array } $success = $value1 <= $value2; - } - - if ($mode === 'string') { + } elseif ($mode === 'string') { $gains = 0; $percDiff = 0; $success = $value1 === $value2; @@ -529,7 +542,7 @@ protected function runChallengeMethodMaxMode( $reflectionMethod, $maxSeconds ), - KataRunnerIterationMode::XDEBUG_PROFILE => $this->runChallengeMethodProfile( + KataRunnerIterationMode::XDEBUG_PROFILE => $this->profile( $reflectionMethod, ) }; @@ -659,7 +672,7 @@ protected function runChallengeMethodMaxSeconds( ]; } - protected function runChallengeMethodProfile(ReflectionMethod $reflectionMethod): array + protected function profile(ReflectionMethod $reflectionMethod): array { $className = $reflectionMethod->class; /** @var \App\KataChallenge $instance */ diff --git a/app/Objects/KataChallengeResultObject.php b/app/Objects/KataChallengeResultObject.php index 29054fe..381ddc8 100644 --- a/app/Objects/KataChallengeResultObject.php +++ b/app/Objects/KataChallengeResultObject.php @@ -42,9 +42,19 @@ public function getReflectionMethod(): ReflectionMethod public function getStats(): array { + $extraReturn = []; + $violations = $this->getViolations(); + $profile = data_get($this->result, KataRunnerIterationMode::XDEBUG_PROFILE->value, []); + if (! empty($profile)) { + $maxIterations = data_get($profile, 'max_iterations', 1); + $extraReturn['profile_memory_usage_avg'] = data_get($profile, 'memory_usage.total', 0) / $maxIterations; + $extraReturn['profile_time_avg'] = data_get($profile, 'time.total', 0) / $maxIterations; + } + return [ + ...$extraReturn, '_result' => $this->result, // Why normalize? 'violations' => $violations, @@ -56,11 +66,6 @@ public function getStats(): array 'execution_time_avg' => $this->getStat('execution_time_avg', KataRunnerIterationMode::MAX_ITERATIONS), 'execution_time_sum' => $this->getStat('execution_time_sum', KataRunnerIterationMode::MAX_ITERATIONS), - 'profile_memory_usage_avg' => $this->result[KataRunnerIterationMode::XDEBUG_PROFILE->value]['memory_usage']['total'] / 100, - 'profile_time_avg' => $this->result[KataRunnerIterationMode::XDEBUG_PROFILE->value]['time']['total'] / 100, - // 'profile_memory_usage_avg' => $this->result['profile']['memory_usage']['total'] / 100, - // 'profile_time_avg' => $this->result['profile']['time']['total'] / 100, - 'line_count' => $this->reflectionMethod->getEndLine() - $this->reflectionMethod->getStartLine(), ]; } diff --git a/app/Utilities/Benchmark.php b/app/Utilities/Benchmark.php index 1d66f9c..6f9f84c 100644 --- a/app/Utilities/Benchmark.php +++ b/app/Utilities/Benchmark.php @@ -108,6 +108,10 @@ public static function profile( int $maxIterations = 1, int $maxTries = 3 ): array { + if (app()->runningUnitTests()) { + throw new BenchmarkProfileException('Not allowed when testing'); + } + if ($maxTries <= 0) { throw new BenchmarkProfileException('Max tries failed'); } @@ -126,7 +130,7 @@ public static function profile( ...self::profileGetStats($tempFilePath), 'max_iterations' => $maxIterations, ]; - } catch (BenchmarkProfileException $exception) { + } catch (BenchmarkProfileException $_) { return self::profile($benchmarkable, $maxIterations, $maxTries - 1); } finally { unlink($tempFilePath.'.xt'); diff --git a/app/helpers.php b/app/helpers.php index abc79fe..8cbe58d 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -45,13 +45,13 @@ function wrap_in_format(string $string, bool $success, bool $warn = false): stri if (! function_exists('bytes_to_human')) { function bytes_to_human(float $bytes): string { - $precision = 9; + $bytes = intval($bytes); $units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; $factor = floor((strlen($bytes) - 1) / 3); return sprintf( '%s %s', - number_format($bytes / (1024 ** $factor), $precision), + round($bytes / (1024 ** $factor)), $units[$factor] ); } diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0_1____0_1_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0_1____0_1_.snap index 4a8c96c..43c5de1 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0_1____0_1_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0_1____0_1_.snap @@ -1 +1 @@ -0.100000000 B \ No newline at end of file +0 B \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0____0_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0____0_.snap index c56a114..43c5de1 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0____0_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___0____0_.snap @@ -1 +1 @@ -0.000000000 B \ No newline at end of file +0 B \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000000____100000000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000000____100000000000_.snap index 332d5f9..cab7785 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000000____100000000000_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000000____100000000000_.snap @@ -1 +1 @@ -93.132257462 GB \ No newline at end of file +93 GB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000000____10000000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000000____10000000000_.snap index 8ca44e4..76b7ebc 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000000____10000000000_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000000____10000000000_.snap @@ -1 +1 @@ -9.313225746 GB \ No newline at end of file +9 GB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000000____1000000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000000____1000000000_.snap index 74fb4da..c93c427 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000000____1000000000_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000000____1000000000_.snap @@ -1 +1 @@ -0.931322575 GB \ No newline at end of file +1 GB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000____100000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000____100000000_.snap index 6112ff5..53c041b 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000____100000000_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000000____100000000_.snap @@ -1 +1 @@ -95.367431641 MB \ No newline at end of file +95 MB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000____10000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000____10000000_.snap index cb88f1d..50259b9 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000____10000000_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000000____10000000_.snap @@ -1 +1 @@ -9.536743164 MB \ No newline at end of file +10 MB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000____1000000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000____1000000_.snap index c9549ef..19b2659 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000____1000000_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000000____1000000_.snap @@ -1 +1 @@ -0.953674316 MB \ No newline at end of file +1 MB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000____100000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000____100000_.snap index 72cc351..2ef4360 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000____100000_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100000____100000_.snap @@ -1 +1 @@ -97.656250000 kB \ No newline at end of file +98 kB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000____10000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000____10000_.snap index 3297585..720dd67 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000____10000_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___10000____10000_.snap @@ -1 +1 @@ -9.765625000 kB \ No newline at end of file +10 kB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000____1000_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000____1000_.snap index 76ed606..b3a503b 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000____1000_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1000____1000_.snap @@ -1 +1 @@ -0.976562500 kB \ No newline at end of file +1 kB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100____100_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100____100_.snap index c0c625f..9e812b7 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100____100_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___100____100_.snap @@ -1 +1 @@ -100.000000000 B \ No newline at end of file +100 B \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1____1_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1____1_.snap index e834229..bff5924 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1____1_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___1____1_.snap @@ -1 +1 @@ -1.000000000 B \ No newline at end of file +1 B \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___9999999999999____9999999999999_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___9999999999999____9999999999999_.snap index a4e6526..d3eddbf 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___9999999999999____9999999999999_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___9999999999999____9999999999999_.snap @@ -1 +1 @@ -9.094947018 TB \ No newline at end of file +9 TB \ No newline at end of file diff --git a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___999999999999____999999999999_.snap b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___999999999999____999999999999_.snap index 3a0fd0e..383d9ac 100644 --- a/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___999999999999____999999999999_.snap +++ b/tests/.pest/snapshots/NoData/HelpersTest/it_can_convert_bytes_to_human_with_data_set___999999999999____999999999999_.snap @@ -1 +1 @@ -931.322574615 GB \ No newline at end of file +931 GB \ No newline at end of file diff --git a/tests/Data/Challenges/ChallengesReturnTest.php b/tests/Data/Challenges/ChallengesReturnTest.php index 59ab1a7..9c04899 100644 --- a/tests/Data/Challenges/ChallengesReturnTest.php +++ b/tests/Data/Challenges/ChallengesReturnTest.php @@ -1,7 +1,6 @@ make($challengeA); $instanceB = app()->make($challengeB); - $returnA = $instanceA->{$method}($iterations); - $returnB = $instanceB->{$method}($iterations); + $returnA = $instanceA->{$method}(1); + $returnB = $instanceB->{$method}(1); expect($returnA)->not->toBeEmpty(); expect($returnB)->not->toBeEmpty(); expect($returnA)->toEqual($returnB); -})->with([1, 3])->with('challenge-methods'); +})->with('challenge-methods'); + +it('has valid return x3', function ( + string $challengeA, + string $method +) { + $challengeB = str_replace('\\A\\', '\\B\\', $challengeA); + $instanceA = app()->make($challengeA); + $instanceB = app()->make($challengeB); + + $returnA = $instanceA->{$method}(3); + $returnB = $instanceB->{$method}(3); + + expect($returnA)->not->toBeEmpty(); + expect($returnB)->not->toBeEmpty(); + expect($returnA)->toEqual($returnB); + +})->with('challenge-methods'); diff --git a/tests/Data/Console/Commands/FakeChallenges/A/NotFound.php b/tests/Data/Console/Commands/FakeChallenges/A/NotFound.php index df62a44..776b204 100644 --- a/tests/Data/Console/Commands/FakeChallenges/A/NotFound.php +++ b/tests/Data/Console/Commands/FakeChallenges/A/NotFound.php @@ -13,6 +13,6 @@ class NotFound extends KataChallenge public function sample(): int { - return $this->return(1); + return 1; } } diff --git a/tests/Data/Console/Commands/FakeChallenges/A/TooSlow.php b/tests/Data/Console/Commands/FakeChallenges/A/TooSlow.php index 6bc9f43..7351f56 100644 --- a/tests/Data/Console/Commands/FakeChallenges/A/TooSlow.php +++ b/tests/Data/Console/Commands/FakeChallenges/A/TooSlow.php @@ -8,6 +8,6 @@ class TooSlow extends KataChallenge { public function sample(): int { - return $this->return(1); + return 1; } } diff --git a/tests/Data/Console/Commands/FakeChallenges/A/WrongOutput.php b/tests/Data/Console/Commands/FakeChallenges/A/WrongOutput.php index de5f895..57c594c 100644 --- a/tests/Data/Console/Commands/FakeChallenges/A/WrongOutput.php +++ b/tests/Data/Console/Commands/FakeChallenges/A/WrongOutput.php @@ -8,6 +8,6 @@ class WrongOutput extends KataChallenge { public function sample(): int { - return $this->return(1); + return 1; } } diff --git a/tests/Data/Console/Commands/FakeChallenges/B/TooSlow.php b/tests/Data/Console/Commands/FakeChallenges/B/TooSlow.php index 4ddf7c6..657b129 100644 --- a/tests/Data/Console/Commands/FakeChallenges/B/TooSlow.php +++ b/tests/Data/Console/Commands/FakeChallenges/B/TooSlow.php @@ -10,6 +10,6 @@ public function sample(): int { sleep(1); - return $this->return(1); + return 1; } } diff --git a/tests/Data/Console/Commands/FakeChallenges/B/WrongOutput.php b/tests/Data/Console/Commands/FakeChallenges/B/WrongOutput.php index 4054f51..37b583d 100644 --- a/tests/Data/Console/Commands/FakeChallenges/B/WrongOutput.php +++ b/tests/Data/Console/Commands/FakeChallenges/B/WrongOutput.php @@ -8,6 +8,6 @@ class WrongOutput extends AWrongOutput { public function sample(): int { - return $this->return(2); + return 2; } } diff --git a/tests/Data/Console/Commands/KataProfileCommandTest.php b/tests/Data/Console/Commands/KataProfileCommandTest.php index e161b19..6e196cd 100644 --- a/tests/Data/Console/Commands/KataProfileCommandTest.php +++ b/tests/Data/Console/Commands/KataProfileCommandTest.php @@ -16,7 +16,7 @@ Config::set('laravel-kata.show-code-snippets', true); }); -it('can run all', function () { +it('can run single', function () { $this->artisan('kata:profile Sample calculatePi') ->assertExitCode(Command::SUCCESS); }); diff --git a/tests/Data/Console/Commands/KataRunCommandTest.php b/tests/Data/Console/Commands/KataRunCommandTest.php index fb27da9..6a32df1 100644 --- a/tests/Data/Console/Commands/KataRunCommandTest.php +++ b/tests/Data/Console/Commands/KataRunCommandTest.php @@ -1,14 +1,13 @@ artisan('kata:run --all') ->assertExitCode(Command::SUCCESS); }); it('can run single', function () { + Config::set('laravel-kata.challenges', [ + Sample::class, + ]); + $this->artisan('kata:run') ->expectsQuestion('Challenges', '#0') ->expectsQuestion('Challenges (1)', 'n') @@ -37,11 +44,19 @@ }); it('can run by challenge', function () { + Config::set('laravel-kata.challenges', [ + Sample::class, + ]); + $this->artisan('kata:run --challenge=Sample') ->assertExitCode(Command::SUCCESS); }); it('can run by challenge method', function () { + Config::set('laravel-kata.challenges', [ + Sample::class, + ]); + $this->artisan('kata:run --challenge=Sample --method=calculatePi') ->assertExitCode(Command::SUCCESS); }); @@ -99,11 +114,3 @@ $this->artisan('kata:run --all'); })->throws(KataChallengeException::class); - -it('fails when not using $this->return()', function () { - Config::set('laravel-kata.challenges', [ - NotUsingReturn::class, - ]); - - $this->artisan('kata:run --all'); -})->throws(KataChallengeProfilingException::class); diff --git a/tests/TestCaseData.php b/tests/TestCaseData.php index 8d2c0fb..6d82059 100644 --- a/tests/TestCaseData.php +++ b/tests/TestCaseData.php @@ -3,11 +3,13 @@ namespace Tests; use Database\Seeders\DatabaseSeeder; +use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTruncation; abstract class TestCaseData extends TestCase { - use DatabaseTruncation; + // use DatabaseTruncation; + use DatabaseTransactions; protected function setUp(): void { From f2c44c33132dcce013d052746e81cac01828758f Mon Sep 17 00:00:00 2001 From: Hendrik Prinsloo Date: Tue, 19 Sep 2023 23:28:01 +0200 Subject: [PATCH 03/11] Fixed tests (2) --- tests/Data/Challenges/ChallengesReturnTest.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/Data/Challenges/ChallengesReturnTest.php b/tests/Data/Challenges/ChallengesReturnTest.php index 9c04899..cab995a 100644 --- a/tests/Data/Challenges/ChallengesReturnTest.php +++ b/tests/Data/Challenges/ChallengesReturnTest.php @@ -10,9 +10,6 @@ $returnA = $instanceA->{$method}(1); $returnB = $instanceB->{$method}(1); - - expect($returnA)->not->toBeEmpty(); - expect($returnB)->not->toBeEmpty(); expect($returnA)->toEqual($returnB); })->with('challenge-methods'); @@ -27,9 +24,6 @@ $returnA = $instanceA->{$method}(3); $returnB = $instanceB->{$method}(3); - - expect($returnA)->not->toBeEmpty(); - expect($returnB)->not->toBeEmpty(); expect($returnA)->toEqual($returnB); })->with('challenge-methods'); From 846b7fdab336d5c6a1fb916a880973fe4d6daa8e Mon Sep 17 00:00:00 2001 From: Hendrik Prinsloo Date: Tue, 19 Sep 2023 23:28:50 +0200 Subject: [PATCH 04/11] Fixed tests (3) --- tests/TestCaseData.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/TestCaseData.php b/tests/TestCaseData.php index 6d82059..8d2c0fb 100644 --- a/tests/TestCaseData.php +++ b/tests/TestCaseData.php @@ -3,13 +3,11 @@ namespace Tests; use Database\Seeders\DatabaseSeeder; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTruncation; abstract class TestCaseData extends TestCase { - // use DatabaseTruncation; - use DatabaseTransactions; + use DatabaseTruncation; protected function setUp(): void { From 3dced015519a35db8a8a9a26b7ba0db863e7a587 Mon Sep 17 00:00:00 2001 From: Hendrik Prinsloo Date: Tue, 19 Sep 2023 23:32:22 +0200 Subject: [PATCH 05/11] Fixed tests (4) --- app/Utilities/Benchmark.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Utilities/Benchmark.php b/app/Utilities/Benchmark.php index 6f9f84c..432da9a 100644 --- a/app/Utilities/Benchmark.php +++ b/app/Utilities/Benchmark.php @@ -133,7 +133,9 @@ public static function profile( } catch (BenchmarkProfileException $_) { return self::profile($benchmarkable, $maxIterations, $maxTries - 1); } finally { - unlink($tempFilePath.'.xt'); + if (file_exists($tempFilePath.'.xt')) { + @unlink($tempFilePath.'.xt'); + } } } } From a0db2f61e38468e9e08574a5ff6b9ee99a4d72d0 Mon Sep 17 00:00:00 2001 From: Hendrik Prinsloo Date: Tue, 19 Sep 2023 23:36:02 +0200 Subject: [PATCH 06/11] Upgraded dependencies --- composer.lock | 200 +++++------ package-lock.json | 820 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 838 insertions(+), 182 deletions(-) diff --git a/composer.lock b/composer.lock index e465025..facc230 100644 --- a/composer.lock +++ b/composer.lock @@ -1690,16 +1690,16 @@ }, { "name": "laravel/framework", - "version": "v10.23.1", + "version": "v10.24.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "dbfd495557678759153e8d71cc2f6027686ca51e" + "reference": "bcebd0a4c015d5c38aeec299d355a42451dd3726" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/dbfd495557678759153e8d71cc2f6027686ca51e", - "reference": "dbfd495557678759153e8d71cc2f6027686ca51e", + "url": "https://api.github.com/repos/laravel/framework/zipball/bcebd0a4c015d5c38aeec299d355a42451dd3726", + "reference": "bcebd0a4c015d5c38aeec299d355a42451dd3726", "shasum": "" }, "require": { @@ -1886,20 +1886,20 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2023-09-13T14:51:46+00:00" + "time": "2023-09-19T15:25:04+00:00" }, { "name": "laravel/prompts", - "version": "v0.1.7", + "version": "v0.1.8", "source": { "type": "git", "url": "https://github.com/laravel/prompts.git", - "reference": "554e7d855a22e87942753d68e23b327ad79b2070" + "reference": "68dcc65babf92e1fb43cba0b3f78fc3d8002709c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/prompts/zipball/554e7d855a22e87942753d68e23b327ad79b2070", - "reference": "554e7d855a22e87942753d68e23b327ad79b2070", + "url": "https://api.github.com/repos/laravel/prompts/zipball/68dcc65babf92e1fb43cba0b3f78fc3d8002709c", + "reference": "68dcc65babf92e1fb43cba0b3f78fc3d8002709c", "shasum": "" }, "require": { @@ -1932,9 +1932,9 @@ ], "support": { "issues": "https://github.com/laravel/prompts/issues", - "source": "https://github.com/laravel/prompts/tree/v0.1.7" + "source": "https://github.com/laravel/prompts/tree/v0.1.8" }, - "time": "2023-09-12T11:09:22+00:00" + "time": "2023-09-19T15:33:56+00:00" }, { "name": "laravel/sanctum", @@ -2796,16 +2796,16 @@ }, { "name": "nette/utils", - "version": "v4.0.1", + "version": "v4.0.2", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "9124157137da01b1f5a5a22d6486cb975f26db7e" + "reference": "cead6637226456b35e1175cc53797dd585d85545" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/9124157137da01b1f5a5a22d6486cb975f26db7e", - "reference": "9124157137da01b1f5a5a22d6486cb975f26db7e", + "url": "https://api.github.com/repos/nette/utils/zipball/cead6637226456b35e1175cc53797dd585d85545", + "reference": "cead6637226456b35e1175cc53797dd585d85545", "shasum": "" }, "require": { @@ -2827,8 +2827,7 @@ "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", "ext-json": "to use Nette\\Utils\\Json", "ext-mbstring": "to use Strings::lower() etc...", - "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()", - "ext-xml": "to use Strings::length() etc. when mbstring is not available" + "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()" }, "type": "library", "extra": { @@ -2877,9 +2876,9 @@ ], "support": { "issues": "https://github.com/nette/utils/issues", - "source": "https://github.com/nette/utils/tree/v4.0.1" + "source": "https://github.com/nette/utils/tree/v4.0.2" }, - "time": "2023-07-30T15:42:21+00:00" + "time": "2023-09-19T11:58:07+00:00" }, { "name": "nikic/php-parser", @@ -3768,16 +3767,16 @@ }, { "name": "psy/psysh", - "version": "v0.11.20", + "version": "v0.11.21", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "0fa27040553d1d280a67a4393194df5228afea5b" + "reference": "bcb22101107f3bf770523b65630c9d547f60c540" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/0fa27040553d1d280a67a4393194df5228afea5b", - "reference": "0fa27040553d1d280a67a4393194df5228afea5b", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/bcb22101107f3bf770523b65630c9d547f60c540", + "reference": "bcb22101107f3bf770523b65630c9d547f60c540", "shasum": "" }, "require": { @@ -3807,6 +3806,10 @@ "extra": { "branch-alias": { "dev-main": "0.11.x-dev" + }, + "bamarni-bin": { + "bin-links": false, + "forward-command": false } }, "autoload": { @@ -3838,9 +3841,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.11.20" + "source": "https://github.com/bobthecow/psysh/tree/v0.11.21" }, - "time": "2023-07-31T14:32:22+00:00" + "time": "2023-09-17T21:15:54+00:00" }, { "name": "ralouphie/getallheaders", @@ -6939,16 +6942,16 @@ "packages-dev": [ { "name": "brianium/paratest", - "version": "v7.2.6", + "version": "v7.2.7", "source": { "type": "git", "url": "https://github.com/paratestphp/paratest.git", - "reference": "7f372b5bb59b4271adedc67d3129df29b84c4173" + "reference": "1526eb4fd195f65075456dee394d14742ae0a66c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paratestphp/paratest/zipball/7f372b5bb59b4271adedc67d3129df29b84c4173", - "reference": "7f372b5bb59b4271adedc67d3129df29b84c4173", + "url": "https://api.github.com/repos/paratestphp/paratest/zipball/1526eb4fd195f65075456dee394d14742ae0a66c", + "reference": "1526eb4fd195f65075456dee394d14742ae0a66c", "shasum": "" }, "require": { @@ -7018,7 +7021,7 @@ ], "support": { "issues": "https://github.com/paratestphp/paratest/issues", - "source": "https://github.com/paratestphp/paratest/tree/v7.2.6" + "source": "https://github.com/paratestphp/paratest/tree/v7.2.7" }, "funding": [ { @@ -7030,7 +7033,7 @@ "type": "paypal" } ], - "time": "2023-08-29T07:47:39+00:00" + "time": "2023-09-14T14:10:09+00:00" }, { "name": "fakerphp/faker", @@ -7473,16 +7476,16 @@ }, { "name": "laravel/pint", - "version": "v1.13.1", + "version": "v1.13.2", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "22f204242d68095b3ba7dab5d3ef0240454a4652" + "reference": "bbb13460d7f8c5c0cd9a58109beedd79cd7331ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/22f204242d68095b3ba7dab5d3ef0240454a4652", - "reference": "22f204242d68095b3ba7dab5d3ef0240454a4652", + "url": "https://api.github.com/repos/laravel/pint/zipball/bbb13460d7f8c5c0cd9a58109beedd79cd7331ff", + "reference": "bbb13460d7f8c5c0cd9a58109beedd79cd7331ff", "shasum": "" }, "require": { @@ -7493,13 +7496,13 @@ "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.21.1", - "illuminate/view": "^10.5.1", + "friendsofphp/php-cs-fixer": "^3.26.1", + "illuminate/view": "^10.23.1", "laravel-zero/framework": "^10.1.2", - "mockery/mockery": "^1.5.1", - "nunomaduro/larastan": "^2.5.1", + "mockery/mockery": "^1.6.6", + "nunomaduro/larastan": "^2.6.4", "nunomaduro/termwind": "^1.15.1", - "pestphp/pest": "^2.4.0" + "pestphp/pest": "^2.18.2" }, "bin": [ "builds/pint" @@ -7535,7 +7538,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2023-09-06T11:03:34+00:00" + "time": "2023-09-19T15:55:02+00:00" }, { "name": "laravel/sail", @@ -7797,37 +7800,37 @@ }, { "name": "nunomaduro/collision", - "version": "v7.8.1", + "version": "v7.9.0", "source": { "type": "git", "url": "https://github.com/nunomaduro/collision.git", - "reference": "61553ad3260845d7e3e49121b7074619233d361b" + "reference": "296d0cf9fe462837ac0da8a568b56fc026b132da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nunomaduro/collision/zipball/61553ad3260845d7e3e49121b7074619233d361b", - "reference": "61553ad3260845d7e3e49121b7074619233d361b", + "url": "https://api.github.com/repos/nunomaduro/collision/zipball/296d0cf9fe462837ac0da8a568b56fc026b132da", + "reference": "296d0cf9fe462837ac0da8a568b56fc026b132da", "shasum": "" }, "require": { "filp/whoops": "^2.15.3", "nunomaduro/termwind": "^1.15.1", "php": "^8.1.0", - "symfony/console": "^6.3.2" + "symfony/console": "^6.3.4" }, "require-dev": { - "brianium/paratest": "^7.2.4", - "laravel/framework": "^10.17.1", - "laravel/pint": "^1.10.5", - "laravel/sail": "^1.23.1", - "laravel/sanctum": "^3.2.5", - "laravel/tinker": "^2.8.1", + "brianium/paratest": "^7.2.7", + "laravel/framework": "^10.23.1", + "laravel/pint": "^1.13.1", + "laravel/sail": "^1.25.0", + "laravel/sanctum": "^3.3.1", + "laravel/tinker": "^2.8.2", "nunomaduro/larastan": "^2.6.4", - "orchestra/testbench-core": "^8.5.9", - "pestphp/pest": "^2.12.1", - "phpunit/phpunit": "^10.3.1", + "orchestra/testbench-core": "^8.11.0", + "pestphp/pest": "^2.19.1", + "phpunit/phpunit": "^10.3.5", "sebastian/environment": "^6.0.1", - "spatie/laravel-ignition": "^2.2.0" + "spatie/laravel-ignition": "^2.3.0" }, "type": "library", "extra": { @@ -7886,33 +7889,34 @@ "type": "patreon" } ], - "time": "2023-08-07T08:03:21+00:00" + "time": "2023-09-19T10:45:09+00:00" }, { "name": "pestphp/pest", - "version": "v2.18.1", + "version": "v2.19.2", "source": { "type": "git", "url": "https://github.com/pestphp/pest.git", - "reference": "74df53c72b0d77a1f66d365ccfe0df704b73aa66" + "reference": "6bc9da3fe1154d75a65262618b4a7032f267c04f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pestphp/pest/zipball/74df53c72b0d77a1f66d365ccfe0df704b73aa66", - "reference": "74df53c72b0d77a1f66d365ccfe0df704b73aa66", + "url": "https://api.github.com/repos/pestphp/pest/zipball/6bc9da3fe1154d75a65262618b4a7032f267c04f", + "reference": "6bc9da3fe1154d75a65262618b4a7032f267c04f", "shasum": "" }, "require": { - "brianium/paratest": "^7.2.6", - "nunomaduro/collision": "^7.8.1", + "brianium/paratest": "^7.2.7", + "nunomaduro/collision": "^7.9.0", "nunomaduro/termwind": "^1.15.1", "pestphp/pest-plugin": "^2.1.1", "pestphp/pest-plugin-arch": "^2.3.3", "php": "^8.1.0", - "phpunit/phpunit": "^10.3.3" + "phpunit/phpunit": "^10.3.5" }, "conflict": { - "phpunit/phpunit": ">10.3.3", + "phpunit/phpunit": ">10.3.5", + "sebastian/exporter": "<5.1.0", "webmozart/assert": "<1.11.0" }, "require-dev": { @@ -7976,7 +7980,7 @@ ], "support": { "issues": "https://github.com/pestphp/pest/issues", - "source": "https://github.com/pestphp/pest/tree/v2.18.1" + "source": "https://github.com/pestphp/pest/tree/v2.19.2" }, "funding": [ { @@ -7988,7 +7992,7 @@ "type": "github" } ], - "time": "2023-09-11T10:38:47+00:00" + "time": "2023-09-19T10:48:16+00:00" }, { "name": "pestphp/pest-plugin", @@ -8488,16 +8492,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.0", + "version": "1.24.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6" + "reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6", - "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01", + "reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01", "shasum": "" }, "require": { @@ -8529,22 +8533,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.1" }, - "time": "2023-09-07T20:46:32+00:00" + "time": "2023-09-18T12:18:02+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "10.1.5", + "version": "10.1.6", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "1df504e42a88044c27a90136910f0b3fe9e91939" + "reference": "56f33548fe522c8d82da7ff3824b42829d324364" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/1df504e42a88044c27a90136910f0b3fe9e91939", - "reference": "1df504e42a88044c27a90136910f0b3fe9e91939", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/56f33548fe522c8d82da7ff3824b42829d324364", + "reference": "56f33548fe522c8d82da7ff3824b42829d324364", "shasum": "" }, "require": { @@ -8601,7 +8605,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.5" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.6" }, "funding": [ { @@ -8609,7 +8613,7 @@ "type": "github" } ], - "time": "2023-09-12T14:37:22+00:00" + "time": "2023-09-19T04:59:03+00:00" }, { "name": "phpunit/php-file-iterator", @@ -8918,16 +8922,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.3.3", + "version": "10.3.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "241ed4dd0db1c096984e62d414c4e1ac8d5dbff4" + "reference": "747c3b2038f1139e3dcd9886a3f5a948648b7503" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/241ed4dd0db1c096984e62d414c4e1ac8d5dbff4", - "reference": "241ed4dd0db1c096984e62d414c4e1ac8d5dbff4", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/747c3b2038f1139e3dcd9886a3f5a948648b7503", + "reference": "747c3b2038f1139e3dcd9886a3f5a948648b7503", "shasum": "" }, "require": { @@ -8941,7 +8945,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=8.1", - "phpunit/php-code-coverage": "^10.1.1", + "phpunit/php-code-coverage": "^10.1.5", "phpunit/php-file-iterator": "^4.0", "phpunit/php-invoker": "^4.0", "phpunit/php-text-template": "^3.0", @@ -8951,7 +8955,7 @@ "sebastian/comparator": "^5.0", "sebastian/diff": "^5.0", "sebastian/environment": "^6.0", - "sebastian/exporter": "^5.0", + "sebastian/exporter": "^5.1", "sebastian/global-state": "^6.0.1", "sebastian/object-enumerator": "^5.0", "sebastian/recursion-context": "^5.0", @@ -8999,7 +9003,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.3.3" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.3.5" }, "funding": [ { @@ -9015,7 +9019,7 @@ "type": "tidelift" } ], - "time": "2023-09-05T04:34:51+00:00" + "time": "2023-09-19T05:42:37+00:00" }, { "name": "sebastian/cli-parser", @@ -9452,16 +9456,16 @@ }, { "name": "sebastian/exporter", - "version": "5.0.1", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "32ff03d078fed1279c4ec9a407d08c5e9febb480" + "reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/32ff03d078fed1279c4ec9a407d08c5e9febb480", - "reference": "32ff03d078fed1279c4ec9a407d08c5e9febb480", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c3fa8483f9539b190f7cd4bfc4a07631dd1df344", + "reference": "c3fa8483f9539b190f7cd4bfc4a07631dd1df344", "shasum": "" }, "require": { @@ -9518,7 +9522,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", "security": "https://github.com/sebastianbergmann/exporter/security/policy", - "source": "https://github.com/sebastianbergmann/exporter/tree/5.0.1" + "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.0" }, "funding": [ { @@ -9526,7 +9530,7 @@ "type": "github" } ], - "time": "2023-09-08T04:46:58+00:00" + "time": "2023-09-18T07:15:37+00:00" }, { "name": "sebastian/global-state", @@ -10066,16 +10070,16 @@ }, { "name": "spatie/ignition", - "version": "1.10.1", + "version": "1.11.2", "source": { "type": "git", "url": "https://github.com/spatie/ignition.git", - "reference": "d92b9a081e99261179b63a858c7a4b01541e7dd1" + "reference": "48b23411ca4bfbc75c75dfc638b6b36159c375aa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/ignition/zipball/d92b9a081e99261179b63a858c7a4b01541e7dd1", - "reference": "d92b9a081e99261179b63a858c7a4b01541e7dd1", + "url": "https://api.github.com/repos/spatie/ignition/zipball/48b23411ca4bfbc75c75dfc638b6b36159c375aa", + "reference": "48b23411ca4bfbc75c75dfc638b6b36159c375aa", "shasum": "" }, "require": { @@ -10145,7 +10149,7 @@ "type": "github" } ], - "time": "2023-08-21T15:06:37+00:00" + "time": "2023-09-19T15:29:52+00:00" }, { "name": "spatie/laravel-ignition", diff --git a/package-lock.json b/package-lock.json index 9858d8f..e128141 100644 --- a/package-lock.json +++ b/package-lock.json @@ -204,28 +204,28 @@ } }, "node_modules/@babel/compat-data": { - "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.9.tgz", - "integrity": "sha512-5UamI7xkUcJ3i9qVDS+KFDEK8/7oJ55/sJMB1Ge7IEapr7KfdfV/HErR+koZwOfd+SgtFKOKRhRakdg++DcJpQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.22.20.tgz", + "integrity": "sha512-BQYjKbpXjoXwFW5jGqiizJQQT/aC7pFm9Ok1OWssonuguICi264lbgMzRp2ZMmRSlfkX6DsWDDcsrctK8Rwfiw==", "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/core": { - "version": "7.22.17", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.17.tgz", - "integrity": "sha512-2EENLmhpwplDux5PSsZnSbnSkB3tZ6QTksgO25xwEL7pIDcNOMhF5v/s6RzwjMZzZzw9Ofc30gHv5ChCC8pifQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.22.20.tgz", + "integrity": "sha512-Y6jd1ahLubuYweD/zJH+vvOY141v4f9igNQAQ+MBgq9JlHS2iTsZKn1aMsb3vGccZsXI16VzTBw52Xx0DWmtnA==", "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.22.13", "@babel/generator": "^7.22.15", "@babel/helper-compilation-targets": "^7.22.15", - "@babel/helper-module-transforms": "^7.22.17", + "@babel/helper-module-transforms": "^7.22.20", "@babel/helpers": "^7.22.15", "@babel/parser": "^7.22.16", "@babel/template": "^7.22.15", - "@babel/traverse": "^7.22.17", - "@babel/types": "^7.22.17", + "@babel/traverse": "^7.22.20", + "@babel/types": "^7.22.19", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", @@ -303,9 +303,9 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", - "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "engines": { "node": ">=6.9.0" } @@ -356,15 +356,15 @@ } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.22.17", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.17.tgz", - "integrity": "sha512-XouDDhQESrLHTpnBtCKExJdyY4gJCdrvH2Pyv8r8kovX2U8G0dRUOT45T9XlbLtuu9CLXP15eusnkprhoPV5iQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.22.20.tgz", + "integrity": "sha512-dLT7JVWIUUxKOs1UnJUBR3S70YK+pKX6AbJgB2vMIvEkZkrfJDbYDJesnPshtKV4LhDOR3Oc5YULeDizRek+5A==", "dependencies": { - "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.20", "@babel/helper-module-imports": "^7.22.15", "@babel/helper-simple-access": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/helper-validator-identifier": "^7.22.15" + "@babel/helper-validator-identifier": "^7.22.20" }, "engines": { "node": ">=6.9.0" @@ -393,12 +393,12 @@ } }, "node_modules/@babel/helper-replace-supers": { - "version": "7.22.9", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.22.9.tgz", - "integrity": "sha512-LJIKvvpgPOPUThdYqcX6IXRuIcTkcAub0IaDRGCZH0p5GPUp7PhRU9QVgFcDDd51BaPkk77ZjqFwh6DZTAEmGg==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.22.20.tgz", + "integrity": "sha512-qsW0In3dbwQUbK8kejJ4R7IHVGwHJlV6lpG6UA7a9hSa2YEiAib+N1T2kr6PEeUT+Fl7najmSOS6SmAwCHK6Tw==", "dependencies": { - "@babel/helper-environment-visitor": "^7.22.5", - "@babel/helper-member-expression-to-functions": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-member-expression-to-functions": "^7.22.15", "@babel/helper-optimise-call-expression": "^7.22.5" }, "engines": { @@ -450,9 +450,9 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.15.tgz", - "integrity": "sha512-4E/F9IIEi8WR94324mbDUMo074YTheJmd7eZF5vITTeYchqAi6sYXRLHUVsmkdmY4QjfKTcB2jB7dVP3NaBElQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "engines": { "node": ">=6.9.0" } @@ -479,11 +479,11 @@ } }, "node_modules/@babel/highlight": { - "version": "7.22.13", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.13.tgz", - "integrity": "sha512-C/BaXcnnvBCmHTpz/VGZ8jgtE2aYlW4hxDhseJAWZb7gqGM/qtCK6iZUb0TyKFf7BOUsBH7Q7fkRsDRhg1XklQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.22.20.tgz", + "integrity": "sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==", "dependencies": { - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "chalk": "^2.4.2", "js-tokens": "^4.0.0" }, @@ -579,18 +579,18 @@ } }, "node_modules/@babel/traverse": { - "version": "7.22.17", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.17.tgz", - "integrity": "sha512-xK4Uwm0JnAMvxYZxOVecss85WxTEIbTa7bnGyf/+EgCL5Zt3U7htUpEOWv9detPlamGKuRzCqw74xVglDWpPdg==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.20.tgz", + "integrity": "sha512-eU260mPZbU7mZ0N+X10pxXhQFMGTeLb9eFS0mxehS8HZp9o1uSnFeWQuG1UPrlxgA7QoUzFhOnilHDp0AXCyHw==", "dependencies": { "@babel/code-frame": "^7.22.13", "@babel/generator": "^7.22.15", - "@babel/helper-environment-visitor": "^7.22.5", + "@babel/helper-environment-visitor": "^7.22.20", "@babel/helper-function-name": "^7.22.5", "@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", "@babel/parser": "^7.22.16", - "@babel/types": "^7.22.17", + "@babel/types": "^7.22.19", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -599,12 +599,12 @@ } }, "node_modules/@babel/types": { - "version": "7.22.17", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.17.tgz", - "integrity": "sha512-YSQPHLFtQNE5xN9tHuZnzu8vPr61wVTBZdfv1meex1NBosa4iT05k/Jw06ddJugi4bk7The/oSwQGFcksmEJQg==", + "version": "7.22.19", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.19.tgz", + "integrity": "sha512-P7LAw/LbojPzkgp5oznjE6tQEIWbp4PkkfrZDINTro9zgBRtI324/EYsiSI7lhPbpIQ+DCeR2NNmMWANGGfZsg==", "dependencies": { "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.15", + "@babel/helper-validator-identifier": "^7.22.19", "to-fast-properties": "^2.0.0" }, "engines": { @@ -632,6 +632,51 @@ "resolved": "https://registry.npmjs.org/@emmetio/scanner/-/scanner-1.0.4.tgz", "integrity": "sha512-IqRuJtQff7YHHBk4G8YZ45uB9BaAGcwQeVzgj/zj8/UdOhtQpEIupUhSk8dys6spFIWVZVeK20CzGEnqR5SbqA==" }, + "node_modules/@esbuild/android-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", + "integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz", + "integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz", + "integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/@esbuild/darwin-arm64": { "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", @@ -647,6 +692,276 @@ "node": ">=12" } }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz", + "integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz", + "integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz", + "integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz", + "integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", + "integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz", + "integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz", + "integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==", + "cpu": [ + "loong64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz", + "integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz", + "integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz", + "integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz", + "integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", + "integrity": "sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz", + "integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", + "integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz", + "integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", + "integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz", + "integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.17.19", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", + "integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", @@ -742,15 +1057,15 @@ } }, "node_modules/@sveltejs/vite-plugin-svelte": { - "version": "2.4.5", - "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.4.5.tgz", - "integrity": "sha512-UJKsFNwhzCVuiZd06jM/psscyNJNDwjQC+qIeb7GBJK9iWeQCcIyfcPWDvbCudfcJggY9jtxJeeaZH7uny93FQ==", + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-2.4.6.tgz", + "integrity": "sha512-zO79p0+DZnXPnF0ltIigWDx/ux7Ni+HRaFOw720Qeivc1azFUrJxTl0OryXVibYNx1hCboGia1NRV3x8RNv4cA==", "dependencies": { - "@sveltejs/vite-plugin-svelte-inspector": "^1.0.3", + "@sveltejs/vite-plugin-svelte-inspector": "^1.0.4", "debug": "^4.3.4", "deepmerge": "^4.3.1", "kleur": "^4.1.5", - "magic-string": "^0.30.2", + "magic-string": "^0.30.3", "svelte-hmr": "^0.15.3", "vitefu": "^0.2.4" }, @@ -779,9 +1094,9 @@ } }, "node_modules/@types/babel__core": { - "version": "7.20.1", - "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.1.tgz", - "integrity": "sha512-aACu/U/omhdk15O4Nfb+fHgH/z3QsfQzpnvRZhYhThms83ZnAOZz7zZAWO7mn2yyNQaA4xTO8GLK3uqFU4bYYw==", + "version": "7.20.2", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.2.tgz", + "integrity": "sha512-pNpr1T1xLUc2l3xJKuPtsEky3ybxN3m4fJkknfIpTCTfIZCDW57oAg+EfCgIIp2rvCe0Wn++/FfodDS4YXxBwA==", "dependencies": { "@babel/parser": "^7.20.7", "@babel/types": "^7.20.7", @@ -791,26 +1106,26 @@ } }, "node_modules/@types/babel__generator": { - "version": "7.6.4", - "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.4.tgz", - "integrity": "sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==", + "version": "7.6.5", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.5.tgz", + "integrity": "sha512-h9yIuWbJKdOPLJTbmSpPzkF67e659PbQDba7ifWm5BJ8xTv+sDmS7rFmywkWOvXedGTivCdeGSIIX8WLcRTz8w==", "dependencies": { "@babel/types": "^7.0.0" } }, "node_modules/@types/babel__template": { - "version": "7.4.1", - "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.1.tgz", - "integrity": "sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==", + "version": "7.4.2", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.2.tgz", + "integrity": "sha512-/AVzPICMhMOMYoSx9MoKpGDKdBRsIXMNByh1PXSZoa+v6ZoLa8xxtsT/uLQ/NJm0XVAWl/BvId4MlDeXJaeIZQ==", "dependencies": { "@babel/parser": "^7.1.0", "@babel/types": "^7.0.0" } }, "node_modules/@types/babel__traverse": { - "version": "7.20.1", - "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.1.tgz", - "integrity": "sha512-MitHFXnhtgwsGZWtT68URpOvLN4EREih1u3QtQiN4VdAxWKRVvGCSvw/Qth0M0Qq3pJpnGOu5JaM/ydK7OGbqg==", + "version": "7.20.2", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.20.2.tgz", + "integrity": "sha512-ojlGK1Hsfce93J0+kn3H5R73elidKUaZonirN33GSmgTUMpzI/MIFfSpF3haANe3G1bEBS9/9/QEqwTzwqFsKw==", "dependencies": { "@babel/types": "^7.20.7" } @@ -834,9 +1149,9 @@ "integrity": "sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==" }, "node_modules/@types/hast": { - "version": "2.3.5", - "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.5.tgz", - "integrity": "sha512-SvQi0L/lNpThgPoleH53cdjB3y9zpLlVjRbqB3rH8hx1jiRSBGAhyjV3H+URFjNVRqt2EdYNrbZE5IsGlNfpRg==", + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.6.tgz", + "integrity": "sha512-47rJE80oqPmFdVDCD7IheXBrVdwuBgsYwoczFvKmwfo2Mzsnt+V9OONsYauFmICb6lQPpCuXYJWejBNs4pDJRg==", "dependencies": { "@types/unist": "^2" } @@ -1659,9 +1974,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001534", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001534.tgz", - "integrity": "sha512-vlPVrhsCS7XaSh2VvWluIQEzVhefrUQcEsQWSS5A5V+dM07uv1qHeQzAOTGIMy9i3e9bH15+muvI/UHojVgS/Q==", + "version": "1.0.30001538", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz", + "integrity": "sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw==", "funding": [ { "type": "opencollective", @@ -2128,9 +2443,9 @@ "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==" }, "node_modules/electron-to-chromium": { - "version": "1.4.520", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.520.tgz", - "integrity": "sha512-Frfus2VpYADsrh1lB3v/ft/WVFlVzOIm+Q0p7U7VqHI6qr7NWHYKe+Wif3W50n7JAFoBsWVsoU0+qDks6WQ60g==" + "version": "1.4.524", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.524.tgz", + "integrity": "sha512-iTmhuiGXYo29QoFXwwXbxhAKiDRZQzme6wYVaZNoitg9h1iRaMGu3vNvDyk+gqu5ETK1D6ug9PC5GVS7kSURuw==" }, "node_modules/emmet": { "version": "2.4.6", @@ -4511,9 +4826,9 @@ } }, "node_modules/postcss": { - "version": "8.4.29", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.29.tgz", - "integrity": "sha512-cbI+jaqIeu/VGqXEarWkRCCffhjgXc0qjBtXpqJhTBohMUjUQnbBr0xqX3vEKudc4iviTewcJo5ajcec5+wdJw==", + "version": "8.4.30", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.30.tgz", + "integrity": "sha512-7ZEao1g4kd68l97aWG/etQKPKq07us0ieSZ2TnFDk11i0ZfDW2AwKHYU8qv4MZKqN2fdBfg+7q0ES06UA73C1g==", "funding": [ { "type": "opencollective", @@ -4893,9 +5208,9 @@ } }, "node_modules/resolve": { - "version": "1.22.4", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.4.tgz", - "integrity": "sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==", + "version": "1.22.6", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.6.tgz", + "integrity": "sha512-njhxM7mV12JfufShqGy3Rz8j11RPdLy4xi15UurGJeoHLfJpVXKdh3ueuOqbYUcDZnffr6X739JBo5LzyahEsw==", "dependencies": { "is-core-module": "^2.13.0", "path-parse": "^1.0.7", @@ -5020,9 +5335,9 @@ "dev": true }, "node_modules/rollup": { - "version": "3.29.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.1.tgz", - "integrity": "sha512-c+ebvQz0VIH4KhhCpDsI+Bik0eT8ZFEVZEYw0cGMVqIP8zc+gnwl7iXCamTw7vzv2MeuZFZfdx5JJIq+ehzDlg==", + "version": "3.29.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.2.tgz", + "integrity": "sha512-CJouHoZ27v6siztc21eEQGo0kIcE5D1gVPA571ez0mMYb25LGYGKnVNXpEj5MGlepmDWGXNjDB5q7uNiPHC11A==", "bin": { "rollup": "dist/bin/rollup" }, @@ -5526,9 +5841,9 @@ } }, "node_modules/svelte2tsx": { - "version": "0.6.21", - "resolved": "https://registry.npmjs.org/svelte2tsx/-/svelte2tsx-0.6.21.tgz", - "integrity": "sha512-v+vvbiy6WDmEQdIkJpvHYxJYG/obALfH0P6CTreYO350q/9+QmFTNCOJvx0O1o59Zpzx1Bqe+qlDxP/KtJSZEA==", + "version": "0.6.22", + "resolved": "https://registry.npmjs.org/svelte2tsx/-/svelte2tsx-0.6.22.tgz", + "integrity": "sha512-eFCfz0juaWeanbwGeQV21kPMwH3LKhfrUYRy1PqRmlieuHvJs8VeK7CaoHJdpBZWCXba2cltHVdywJmwOGhbww==", "dependencies": { "dedent-js": "^1.0.1", "pascal-case": "^3.1.1" @@ -6034,6 +6349,51 @@ "vite": "^2 || ^3 || ^4" } }, + "node_modules/vite/node_modules/@esbuild/android-arm": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.20.tgz", + "integrity": "sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/android-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.18.20.tgz", + "integrity": "sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/android-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.18.20.tgz", + "integrity": "sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/vite/node_modules/@esbuild/darwin-arm64": { "version": "0.18.20", "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.18.20.tgz", @@ -6049,6 +6409,276 @@ "node": ">=12" } }, + "node_modules/vite/node_modules/@esbuild/darwin-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.18.20.tgz", + "integrity": "sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/freebsd-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.20.tgz", + "integrity": "sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/freebsd-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.18.20.tgz", + "integrity": "sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-arm": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.18.20.tgz", + "integrity": "sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.18.20.tgz", + "integrity": "sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-ia32": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.18.20.tgz", + "integrity": "sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-loong64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.18.20.tgz", + "integrity": "sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==", + "cpu": [ + "loong64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-mips64el": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.18.20.tgz", + "integrity": "sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-ppc64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.18.20.tgz", + "integrity": "sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-riscv64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.18.20.tgz", + "integrity": "sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-s390x": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.18.20.tgz", + "integrity": "sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/linux-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.18.20.tgz", + "integrity": "sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/netbsd-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.18.20.tgz", + "integrity": "sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/openbsd-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.18.20.tgz", + "integrity": "sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/sunos-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.18.20.tgz", + "integrity": "sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/win32-arm64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.18.20.tgz", + "integrity": "sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/win32-ia32": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.18.20.tgz", + "integrity": "sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/vite/node_modules/@esbuild/win32-x64": { + "version": "0.18.20", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.18.20.tgz", + "integrity": "sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/vite/node_modules/esbuild": { "version": "0.18.20", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.18.20.tgz", @@ -6121,9 +6751,9 @@ } }, "node_modules/vscode-jsonrpc": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0.tgz", - "integrity": "sha512-6TDy/abTQk+zDGYazgbIPc+4JoXdwC8NHU9Pbn4UJP1fehUyZmM4RHp5IthX7A6L5KS30PRui+j+tbbMMMafdw==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.2.0.tgz", + "integrity": "sha512-C+r0eKJUIfiDIfwJhria30+TYWPtuHJXHtI7J0YlOmKAo7ogxP20T0zxB7HZQIFhIyvoBPwWskjxrvAtfjyZfA==", "engines": { "node": ">=14.0.0" } @@ -6140,12 +6770,12 @@ } }, "node_modules/vscode-languageserver-protocol": { - "version": "3.17.3", - "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3.tgz", - "integrity": "sha512-924/h0AqsMtA5yK22GgMtCYiMdCOtWTSGgUOkgEDX+wk2b0x4sAfLiO4NxBxqbiVtz7K7/1/RgVrVI0NClZwqA==", + "version": "3.17.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.4.tgz", + "integrity": "sha512-IpaHLPft+UBWf4dOIH15YEgydTbXGz52EMU2h16SfFpYu/yOQt3pY14049mtpJu+4CBHn+hq7S67e7O0AwpRqQ==", "dependencies": { - "vscode-jsonrpc": "8.1.0", - "vscode-languageserver-types": "3.17.3" + "vscode-jsonrpc": "8.2.0", + "vscode-languageserver-types": "3.17.4" } }, "node_modules/vscode-languageserver-textdocument": { @@ -6154,6 +6784,28 @@ "integrity": "sha512-1bonkGqQs5/fxGT5UchTgjGVnfysL0O8v1AYMBjqTbWQTFn721zaPGDYFkOKtfDgFiSgXM3KwaG3FMGfW4Ed9Q==" }, "node_modules/vscode-languageserver-types": { + "version": "3.17.4", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.4.tgz", + "integrity": "sha512-9YXi5pA3XF2V+NUQg6g+lulNS0ncRCKASYdK3Cs7kiH9sVFXWq27prjkC/B8M/xJLRPPRSPCHVMuBTgRNFh2sQ==" + }, + "node_modules/vscode-languageserver/node_modules/vscode-jsonrpc": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-8.1.0.tgz", + "integrity": "sha512-6TDy/abTQk+zDGYazgbIPc+4JoXdwC8NHU9Pbn4UJP1fehUyZmM4RHp5IthX7A6L5KS30PRui+j+tbbMMMafdw==", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/vscode-languageserver/node_modules/vscode-languageserver-protocol": { + "version": "3.17.3", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.17.3.tgz", + "integrity": "sha512-924/h0AqsMtA5yK22GgMtCYiMdCOtWTSGgUOkgEDX+wk2b0x4sAfLiO4NxBxqbiVtz7K7/1/RgVrVI0NClZwqA==", + "dependencies": { + "vscode-jsonrpc": "8.1.0", + "vscode-languageserver-types": "3.17.3" + } + }, + "node_modules/vscode-languageserver/node_modules/vscode-languageserver-types": { "version": "3.17.3", "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.3.tgz", "integrity": "sha512-SYU4z1dL0PyIMd4Vj8YOqFvHu7Hz/enbWtpfnVbJHU4Nd1YNYx8u0ennumc6h48GQNeOLxmwySmnADouT/AuZA==" From 603426fef211b8c8f1341bab1c9311f640cdc711 Mon Sep 17 00:00:00 2001 From: Hendrik Prinsloo Date: Tue, 19 Sep 2023 23:40:16 +0200 Subject: [PATCH 07/11] Fixed tests (4) --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index aadf780..a205c9c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -63,7 +63,7 @@ commands: - run: name: Installing PHP modules command: | - yes 'no' | sudo pecl install -f redis || true + yes 'no' | sudo pecl install -f redis xdebug || true - run: name: Installing PHP pcov command: | From a01f73c85e09bd5657ac0622d3185ad6718c09ba Mon Sep 17 00:00:00 2001 From: Hendrik Prinsloo Date: Tue, 19 Sep 2023 23:45:54 +0200 Subject: [PATCH 08/11] Fixed tests (5) --- .env.circleci | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.circleci b/.env.circleci index d70725e..82c6e94 100644 --- a/.env.circleci +++ b/.env.circleci @@ -2,3 +2,4 @@ DB_HOST_OVERRIDE=127.0.0.1 LK_PROGRESS_BAR_DISABLED=true LK_DD_MAX_USERS=1000 LK_DD_MAX_USER_BLOGS=10 +XDEBUG_MODE=profile From 5d66df6e0186fcac9b98ba78017f4dd84e4182a4 Mon Sep 17 00:00:00 2001 From: Hendrik Prinsloo Date: Tue, 19 Sep 2023 23:49:19 +0200 Subject: [PATCH 09/11] Fixed tests (6) --- .circleci/config.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a205c9c..67f9ead 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -61,9 +61,13 @@ commands: setup-php: steps: - run: - name: Installing PHP modules + name: Installing PHP redis command: | - yes 'no' | sudo pecl install -f redis xdebug || true + yes 'no' | sudo pecl install -f redis || true + - run: + name: Installing PHP pcov + command: | + sudo pecl install xdebug - run: name: Installing PHP pcov command: | From d1d7f97761e082587e4ce44d47ac4476d520ae1d Mon Sep 17 00:00:00 2001 From: Hendrik Prinsloo Date: Wed, 20 Sep 2023 19:45:32 +0200 Subject: [PATCH 10/11] Fixed tests (7) --- .circleci/config.yml | 2 +- bin/benchmark.sh | 2 +- bin/restart.sh | 11 ----------- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 67f9ead..a73f397 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -65,7 +65,7 @@ commands: command: | yes 'no' | sudo pecl install -f redis || true - run: - name: Installing PHP pcov + name: Installing PHP xdebug command: | sudo pecl install xdebug - run: diff --git a/bin/benchmark.sh b/bin/benchmark.sh index 35aa0e2..5416026 100755 --- a/bin/benchmark.sh +++ b/bin/benchmark.sh @@ -6,7 +6,7 @@ source $PATH_TO_REPO/.env if [ "${CI_MODE}" == "circleci" ]; then echo "LK_RUN_MODE=benchmark" >> "$PATH_TO_REPO/.env" - php artisan kata:run --all + php -d xdebug.mode=profile artisan kata:run --all else ./vendor/bin/sail artisan kata:run --all fi diff --git a/bin/restart.sh b/bin/restart.sh index 7d4f998..d0b3c55 100755 --- a/bin/restart.sh +++ b/bin/restart.sh @@ -26,17 +26,6 @@ fi source $PATH_TO_REPO/.env -# Append the railway env -if [ "${CI_MODE}" == "railway" ]; then - echo "Running in Railway" - echo $'\n# Railway\n' >> $PATH_TO_REPO/.env - cat $PATH_TO_REPO/.env.railway >> $PATH_TO_REPO/.env - source $PATH_TO_REPO/.env - - php artisan migrate --seed --no-interaction --force - exit 0 -fi - if [ "${CI_MODE}" == "circleci" ]; then echo "Running in CircliCI" echo $'\n# CircleCI\n' >> $PATH_TO_REPO/.env From e6c3db16494cfdba6fb1efb7ab80b97a04b7083b Mon Sep 17 00:00:00 2001 From: Hendrik Prinsloo Date: Wed, 20 Sep 2023 21:04:11 +0200 Subject: [PATCH 11/11] Fixed tests (8) --- .env.circleci | 3 ++- .env.example | 2 +- app/Utilities/Benchmark.php | 22 ++++++++++++++-------- docker/8.2/php.ini | 3 +++ 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.env.circleci b/.env.circleci index 82c6e94..2f2f99d 100644 --- a/.env.circleci +++ b/.env.circleci @@ -2,4 +2,5 @@ DB_HOST_OVERRIDE=127.0.0.1 LK_PROGRESS_BAR_DISABLED=true LK_DD_MAX_USERS=1000 LK_DD_MAX_USER_BLOGS=10 -XDEBUG_MODE=profile +XDEBUG_MODE=profile,trace +SAIL_XDEBUG_MODE=profile,trace diff --git a/.env.example b/.env.example index d4e8cb1..1c2d273 100644 --- a/.env.example +++ b/.env.example @@ -13,7 +13,7 @@ LOG_LEVEL=debug # LK_RUN_MODE=debug # Xdebug -SAIL_XDEBUG_MODE=profile +SAIL_XDEBUG_MODE=profile,trace SAIL_XDEBUG_CONFIG="client_host=host.docker.internal output_dir=/var/www/html/storage/logs/xdebug" # Database / Main diff --git a/app/Utilities/Benchmark.php b/app/Utilities/Benchmark.php index 432da9a..f831af2 100644 --- a/app/Utilities/Benchmark.php +++ b/app/Utilities/Benchmark.php @@ -4,6 +4,7 @@ use App\Exceptions\BenchmarkProfileException; use Closure; +use ErrorException; use Illuminate\Support\Benchmark as SupportBenchmark; class Benchmark extends SupportBenchmark @@ -34,8 +35,6 @@ protected static function getTraceLineValue(array $lineParts, string $key): mixe public static function profileGetStats(string $filepath): array { - $filepath = trim($filepath, '.xt').'.xt'; - if (! file_exists($filepath)) { throw new BenchmarkProfileException(sprintf( 'Expected profile stats file not found at: %s', @@ -78,6 +77,8 @@ public static function profileGetStats(string $filepath): array } + fclose($handle); + if (is_null($start)) { throw new BenchmarkProfileException('No start found'); } @@ -117,12 +118,11 @@ public static function profile( } // Might want to save the static file for debugging... + $tempFilePath = sys_get_temp_dir().'/'.uniqid('xdt-', true); // copy($tempFilePath.'.xt', sprintf('/var/www/html/sample-memory-%s.xt', now()->format('ymd_His'))); try { - $tempFile = tmpfile(); - $tempFilePath = stream_get_meta_data($tempFile)['uri']; - xdebug_start_trace($tempFilePath, XDEBUG_TRACE_COMPUTERIZED); + xdebug_start_trace($tempFilePath, XDEBUG_TRACE_COMPUTERIZED | XDEBUG_TRACE_NAKED_FILENAME); $benchmarkable(); xdebug_stop_trace(); @@ -130,11 +130,17 @@ public static function profile( ...self::profileGetStats($tempFilePath), 'max_iterations' => $maxIterations, ]; - } catch (BenchmarkProfileException $_) { + } catch (BenchmarkProfileException $exception) { return self::profile($benchmarkable, $maxIterations, $maxTries - 1); + } catch (ErrorException $exception) { + if ($exception->getMessage() === 'Functionality is not enabled') { + return []; + } + + throw new BenchmarkProfileException($exception->getMessage()); } finally { - if (file_exists($tempFilePath.'.xt')) { - @unlink($tempFilePath.'.xt'); + if (file_exists($tempFilePath)) { + @unlink($tempFilePath); } } } diff --git a/docker/8.2/php.ini b/docker/8.2/php.ini index 73d58d9..47d16e8 100644 --- a/docker/8.2/php.ini +++ b/docker/8.2/php.ini @@ -3,3 +3,6 @@ post_max_size = 100M upload_max_filesize = 100M variables_order = EGPCS memory_limit = 4G + +xdebug.mode=profile,trace +xdebug.start_with_request=trigger