Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  specify next release
  fix tests
  CS
  use blackbox 5
  • Loading branch information
Baptouuuu committed Jul 9, 2023
2 parents ab2af16 + a1cca66 commit 8101027
Show file tree
Hide file tree
Showing 58 changed files with 1,101 additions and 895 deletions.
59 changes: 55 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.1', '8.2']
php-version: ['8.2']
dependencies: ['lowest', 'highest']
name: 'PHPUnit'
steps:
Expand All @@ -29,12 +29,63 @@ jobs:
env:
BLACKBOX_SET_SIZE: 20
BLACKBOX_DETAILED_PROPERTIES: 1
blackbox:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.2']
dependency-versions: ['lowest', 'highest']
name: 'BlackBox'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: none
- name: Composer
uses: "ramsey/composer-install@v2"
with:
dependency-versions: ${{ matrix.dependencies }}
- name: BlackBox
run: php blackbox.php
blackbox_coverage:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.2']
dependency-versions: ['lowest', 'highest']
name: 'BlackBox Coverage'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: xdebug
- name: Composer
uses: "ramsey/composer-install@v2"
with:
dependency-versions: ${{ matrix.dependencies }}
- name: BlackBox
run: php blackbox.php
env:
ENABLE_COVERAGE: 'true'
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
coverage:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
php-version: ['8.1', '8.2']
php-version: ['8.2']
name: 'Coverage'
steps:
- name: Checkout
Expand All @@ -58,7 +109,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1', '8.2']
php-version: ['8.2']
dependencies: ['lowest', 'highest']
name: 'Psalm'
steps:
Expand All @@ -79,7 +130,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.1']
php-version: ['8.2']
name: 'CS'
steps:
- name: Checkout
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 6.5.0 - 2023-07-09

### Changed

- Require `innmind/black-box` `5`

### Removed

- Support for PHP `8.1`

## 6.4.0 - 2023-05-18

### Added
Expand Down
30 changes: 30 additions & 0 deletions blackbox.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
declare(strict_types = 1);

require 'vendor/autoload.php';

use Innmind\BlackBox\{
Application,
Runner\Load,
Runner\CodeCoverage,
};

// because the generated trees can be quite large
\ini_set('memory_limit', '-1');

Application::new($argv)
->codeCoverage(
CodeCoverage::of(
__DIR__.'/src/',
__DIR__.'/proofs/',
__DIR__.'/fixtures/',
)
->dumpTo('coverage.clover')
->enableWhen(\getenv('ENABLE_COVERAGE') !== false),
)
->scenariiPerProof(match (\getenv('ENABLE_COVERAGE')) {
false => 20,
default => 1,
})
->tryToProve(Load::everythingIn(__DIR__.'/proofs/'))
->exit();
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"issues": "http://github.com/Innmind/filesystem/issues"
},
"require": {
"php": "~8.1",
"innmind/immutable": "~4.13",
"php": "~8.2",
"innmind/immutable": "~4.15",
"symfony/filesystem": "~6.0",
"innmind/stream": "~4.0",
"innmind/media-type": "~2.0",
"innmind/url": "~4.0",
"innmind/stream": "~4.1",
"innmind/media-type": "~2.1",
"innmind/url": "~4.2",
"psr/log": "~3.0"
},
"autoload": {
Expand All @@ -36,19 +36,19 @@
}
},
"require-dev": {
"phpunit/phpunit": "~9.0",
"vimeo/psalm": "~4.30",
"innmind/black-box": "^4.17",
"phpunit/phpunit": "~10.2",
"vimeo/psalm": "~5.13",
"innmind/black-box": "~5.0",
"innmind/coding-standard": "~2.0",
"ramsey/uuid": "^4.6"
},
"conflict": {
"innmind/black-box": "<4.7|~5.0"
"innmind/black-box": "<5.0|~6.0"
},
"suggest": {
"innmind/black-box": "For property based testing"
},
"provide": {
"innmind/black-box-sets": "4.7.0"
"innmind/black-box-sets": "5.0"
}
}
36 changes: 15 additions & 21 deletions fixtures/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
use Properties\Innmind\Filesystem\Directory as Properties;
use Innmind\BlackBox\{
Set as DataSet,
Properties as Ensure,
Runner\Assert,
Runner\Stats,
};
use Fixtures\Innmind\Immutable\Set;

Expand Down Expand Up @@ -38,15 +39,15 @@ private static function atDepth(int $depth, int $maxDepth): DataSet
{
if ($depth === $maxDepth) {
$files = Set::of(
new DataSet\Randomize(
DataSet\Randomize::of(
File::any(),
),
DataSet\Integers::between(0, 5),
);
} else {
$files = Set::of(
new DataSet\Either(
new DataSet\Randomize(
DataSet\Either::any(
DataSet\Randomize::of(
File::any(),
),
self::atDepth($depth + 1, $maxDepth),
Expand Down Expand Up @@ -74,26 +75,19 @@ private static function atDepth(int $depth, int $maxDepth): DataSet
);

$modified = DataSet\Composite::immutable(
static fn($directory, $properties): Model => $properties->ensureHeldBy($directory),
$directory,
DataSet\Decorate::immutable(
static fn(array $properties): Ensure => new Ensure(...$properties),
DataSet\Sequence::of(
new DataSet\Either(
DataSet\Property::of(
Properties\RemoveFile::class,
),
DataSet\Property::of(
Properties\AddFile::class,
File::any(),
),
),
DataSet\Integers::between(1, 10),
),
static fn($directory, $properties): Model => $properties->ensureHeldBy(
// not ideal but no other simple way for now
Assert::of(Stats::new()),
$directory,
),
$directory,
DataSet\Properties::any(
Properties\RemoveFile::any(),
Properties\AddFile::any(),
)->atMost(10),
);

return new DataSet\Either(
return DataSet\Either::any(
$directory,
$modified,
);
Expand Down
27 changes: 10 additions & 17 deletions fixtures/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,15 @@ public static function any(): Set
*/
public static function strings(): Set
{
return Set\Decorate::immutable(
static fn(array $chrs): string => \implode('', $chrs),
Set\Sequence::of(
Set\Decorate::immutable(
static fn(int $chr): string => \chr($chr),
new Set\Either(
Set\Integers::between(1, 46),
Set\Integers::between(48, 127),
),
),
Set\Integers::between(1, 255),
),
)->filter(
static fn(string $name): bool => $name !== '.' &&
$name !== '..' &&
!\preg_match('~\s+~', $name),
);
return Set\Strings::madeOf(
Set\Integers::between(1, 46)->map(\chr(...)),
Set\Integers::between(48, 127)->map(\chr(...)),
)
->between(1, 255)
->filter(
static fn(string $name): bool => $name !== '.' &&
$name !== '..' &&
!\preg_match('~\s+~', $name),
);
}
}
27 changes: 16 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" printerClass="Innmind\BlackBox\PHPUnit\ResultPrinterV9" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory>.</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd">
<extensions>
<bootstrap class="Innmind\BlackBox\PHPUnit\Extension">
</bootstrap>
</extensions>
<coverage/>
<php>
<env name="BLACKBOX_SET_SIZE" value="1"/>
<ini name="memory_limit" value="-1" />
<ini name="memory_limit" value="-1"/>
</php>
<testsuites>
<testsuite name="Filesystem test suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>.</directory>
</include>
<exclude>
<directory>./tests</directory>
<directory>./vendor</directory>
</exclude>
</source>
</phpunit>
70 changes: 70 additions & 0 deletions proofs/adapter/filesystem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);

use Innmind\Filesystem\{
Adapter\Filesystem,
Directory\Directory,
File\File,
File\Content\None,
CaseSensitivity,
};
use Innmind\Url\Path;
use Properties\Innmind\Filesystem\Adapter;
use Innmind\BlackBox\Set;
use Symfony\Component\Filesystem\Filesystem as FS;

return static function() {
yield proof(
'Filesystem properties',
given(Adapter::properties()),
function($assert, $properties) {
$path = \sys_get_temp_dir().'/innmind/filesystem/';
(new FS)->remove($path);

$properties->ensureHeldBy($assert, Filesystem::mount(Path::of($path)));

(new FS)->remove($path);
},
);

foreach (Adapter::list() as $property) {
yield proof(
'Filesystem property',
given($property),
function($assert, $property) {
$path = \sys_get_temp_dir().'/innmind/filesystem/';
(new FS)->remove($path);
$filesystem = Filesystem::mount(Path::of($path));

if ($property->applicableTo($filesystem)) {
$property->ensureHeldBy($assert, $filesystem);
}

(new FS)->remove($path);
},
);
}

yield test(
'Regression adding file in directory due to case sensitivity',
function($assert) {
$property = new Adapter\AddRemoveAddModificationsStillAddTheFile(
Directory::named('0')
->add($file = File::named('L', None::of()))
->remove($file->name()),
File::named('l', None::of()),
);

$path = \sys_get_temp_dir().'/innmind/filesystem/';
(new FS)->remove($path);
$adapter = Filesystem::mount(Path::of($path))->withCaseSensitivity(match (\PHP_OS) {
'Darwin' => CaseSensitivity::insensitive,
default => CaseSensitivity::sensitive,
});

$property->ensureHeldBy($assert, $adapter);

(new FS)->remove($path);
}
);
};
Loading

0 comments on commit 8101027

Please sign in to comment.