Skip to content

Commit

Permalink
fix no ffi ext
Browse files Browse the repository at this point in the history
  • Loading branch information
yuichiis committed Mar 17, 2024
1 parent 630783b commit 004629a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: tests
on: [push]

jobs:
tests:
no_ext_tests:
runs-on: ubuntu-22.04

strategy:
Expand All @@ -27,5 +27,5 @@ jobs:
configuration: tests/phpunit.xml
version: 10.5
php_version: ${{ matrix.php }}
php_extensions: ffi
args: --filter ReleaseTest

2 changes: 1 addition & 1 deletion src/BufferFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class BufferFactory
{
public function isAvailable() : bool
{
return extension_loaded('ffi');
return class_exists(FFI::class);
}

public function Buffer(int $size, int $dtype) : Buffer
Expand Down
22 changes: 22 additions & 0 deletions tests/RindowTest/Math/Matrix/Buffer/FFI/ReleaseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
namespace RindowTest\Math\Buffer\FFI\ReleaseTest;

use PHPUnit\Framework\TestCase;
use Rindow\Math\Buffer\FFI\BufferFactory;
use Rindow\Math\Buffer\FFI\Buffer;
use Interop\Polite\Math\Matrix\NDArray;
use FFI;

class ReleaseTest extends TestCase
{
public function testFFINotLoaded()
{
$factory = new BufferFactory();
if(extension_loaded('ffi')) {
$buffer = $factory->Buffer(1,NDArray::float32);
$this->assertInstanceof(Buffer::class,$buffer);
} else {
$this->assertFalse($factory->isAvailable());
}
}
}

0 comments on commit 004629a

Please sign in to comment.