Skip to content

Commit

Permalink
Fix problem
Browse files Browse the repository at this point in the history
  • Loading branch information
m3m0r7 committed Dec 25, 2023
1 parent ec08043 commit c335afb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/VM/Core/Runtime/RubyVM.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function __construct(public readonly Option $option)
{
// Register default kernels
$this->register(
rubyVersion: RubyVersion::VERSION_3_2,
kernelClass: \RubyVM\VM\Core\Runtime\Kernel\Ruby3_2\Kernel::class,
rubyVersion: RubyVersion::VERSION_3_3,
kernelClass: \RubyVM\VM\Core\Runtime\Kernel\Ruby3_3\Kernel::class,
);

$this->register(
rubyVersion: RubyVersion::VERSION_3_3,
kernelClass: \RubyVM\VM\Core\Runtime\Kernel\Ruby3_3\Kernel::class,
rubyVersion: RubyVersion::VERSION_3_2,
kernelClass: \RubyVM\VM\Core\Runtime\Kernel\Ruby3_2\Kernel::class,
);
}

Expand Down
15 changes: 13 additions & 2 deletions tests/Helper/TestApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,25 @@
*/
class TestApplication extends TestCase
{
protected int $major = -1;
protected int $minor = -1;
protected int $patch = -1;

protected function createRubyVMFromCode(string $code, string $extraData = '', string $binaryPath = 'ruby'): RubyVMManager
{
$handle = tmpfile();
if ($handle === false) {
throw new \RuntimeException('tmpfile did not created');
}

[$major, $minor, $patch] = sscanf(exec("{$binaryPath} -v"), 'ruby %d.%d.%d');
if ($this->major !== -1) {
$version = sscanf(exec("{$binaryPath} -v") ?: 'ruby 3.2.0', 'ruby %d.%d.%d');
if (!is_array($version)) {
throw new \RuntimeException('The version is incorrect6');
}

[$this->major, $this->minor, $this->patch] = $version;

Check failure on line 35 in tests/Helper/TestApplication.php

View workflow job for this annotation

GitHub Actions / lint (3.2)

Property Tests\RubyVM\Helper\TestApplication::$major (int) does not accept int|null.

Check failure on line 35 in tests/Helper/TestApplication.php

View workflow job for this annotation

GitHub Actions / lint (3.2)

Property Tests\RubyVM\Helper\TestApplication::$minor (int) does not accept int|null.

Check failure on line 35 in tests/Helper/TestApplication.php

View workflow job for this annotation

GitHub Actions / lint (3.2)

Property Tests\RubyVM\Helper\TestApplication::$patch (int) does not accept int|null.

Check failure on line 35 in tests/Helper/TestApplication.php

View workflow job for this annotation

GitHub Actions / lint (3.3.0-rc1)

Property Tests\RubyVM\Helper\TestApplication::$major (int) does not accept int|null.

Check failure on line 35 in tests/Helper/TestApplication.php

View workflow job for this annotation

GitHub Actions / lint (3.3.0-rc1)

Property Tests\RubyVM\Helper\TestApplication::$minor (int) does not accept int|null.

Check failure on line 35 in tests/Helper/TestApplication.php

View workflow job for this annotation

GitHub Actions / lint (3.3.0-rc1)

Property Tests\RubyVM\Helper\TestApplication::$patch (int) does not accept int|null.
}

fwrite($handle, $code);
$uri = stream_get_meta_data($handle)['uri'];
Expand Down Expand Up @@ -62,7 +73,7 @@ protected function createRubyVMFromCode(string $code, string $extraData = '', st
);

$rubyVM->setDefaultVersion(
RubyVersion::from("{$major}.{$minor}"),
RubyVersion::from("{$this->major}.{$this->minor}"),
);

return new RubyVMManager(
Expand Down
2 changes: 1 addition & 1 deletion tests/Version/RubyVM/YARB/YARBStructureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testHeader(): void
_,
);
$rubyVMManager->rubyVM->runtime()->setup();
$this->assertSame('3.2', $rubyVMManager->rubyVM->runtime()->rubyVersion());
$this->assertSame("{$this->major}.{$this->minor}", $rubyVMManager->rubyVM->runtime()->rubyVersion());
if ($this->isCI()) {
$this->assertSame('x86_64-linux', $rubyVMManager->rubyVM->runtime()->rubyPlatform());
} else {
Expand Down

0 comments on commit c335afb

Please sign in to comment.