From 004629a0422910c579fe8a3269bbb56b49eb5999 Mon Sep 17 00:00:00 2001 From: Yuichi Ishikawa Date: Sun, 17 Mar 2024 22:06:31 +0900 Subject: [PATCH] fix no ffi ext --- .github/workflows/tests.yml | 4 ++-- src/BufferFactory.php | 2 +- .../Math/Matrix/Buffer/FFI/ReleaseTest.php | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 tests/RindowTest/Math/Matrix/Buffer/FFI/ReleaseTest.php diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8c72c5e..dc041fc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,7 +3,7 @@ name: tests on: [push] jobs: - tests: + no_ext_tests: runs-on: ubuntu-22.04 strategy: @@ -27,5 +27,5 @@ jobs: configuration: tests/phpunit.xml version: 10.5 php_version: ${{ matrix.php }} - php_extensions: ffi + args: --filter ReleaseTest diff --git a/src/BufferFactory.php b/src/BufferFactory.php index 762471f..891167b 100644 --- a/src/BufferFactory.php +++ b/src/BufferFactory.php @@ -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 diff --git a/tests/RindowTest/Math/Matrix/Buffer/FFI/ReleaseTest.php b/tests/RindowTest/Math/Matrix/Buffer/FFI/ReleaseTest.php new file mode 100644 index 0000000..1e6cebe --- /dev/null +++ b/tests/RindowTest/Math/Matrix/Buffer/FFI/ReleaseTest.php @@ -0,0 +1,22 @@ +Buffer(1,NDArray::float32); + $this->assertInstanceof(Buffer::class,$buffer); + } else { + $this->assertFalse($factory->isAvailable()); + } + } +} \ No newline at end of file