Remaster platform support with a common corelib ruby implementation and small platform drivers and more ...#2746
Conversation
opal/corelib/kernel.rb
Outdated
| end | ||
|
|
||
| def __dir__ | ||
| File.realpath(File.dirname(__FILE__)) |
There was a problem hiding this comment.
__FILE__ here is opal/corelib/kernel.rb, so __dir__ is always opal/corelib
There was a problem hiding this comment.
This dir FILE thing probably needs some further discussion/work. I add it to the TODO list above.
opal/corelib/kernel.rb
Outdated
| self | ||
| end | ||
|
|
||
| def fork |
|
We've read with @elia the patch until the platform code itself. In general, we agreed this kind of abstraction is a great idea, but some parts can be ideally split into smaller patches. |
|
This adds a tiny Virtual File System for browsers, which is required so that specs can run without exiting in between. The spec suite as run by node, deno, bun, etc. executes specs that during setup require IO. When these specs run without IO the whole suite exits with "example has not been reset". As we don't have a conditional spec file exclusion and as the drivers make it easily possible, i added a VFS, used by browsers, available via 'opal/full'. Its very simple, create, write, read, delete File or Dir works, even File.stat. Most IO/File/Dir specs still fail at this point, but specs overall run. |
c67f6aa to
c5232b2
Compare
c5232b2 to
3dcf042
Compare
|
rebase |
affc39c to
a3faccc
Compare
|
fileutils, tmpdir, pathname may seem out of scope of this PR, as it says "fully functional corelib", but corelib specs are not complete and implementing these helped fix some bugs and tests for some ambiguities in corelib. Also fileutils, tmpdir and pathname are very, very useful :-) |
1a8254a to
7faa70e
Compare
|
9f3ff8f changes the driver interface a bit, which only works with node and breaks all other platforms. Working on it ... |
|
Ooops, the process.rb part is still missing, working on it too ..., so specs may not run at all at this stage |
51cd7ff to
d1ffb43
Compare
|
@hmdne @elia Part 5 is ready, it runs specs for node only, as i changed driver interface a bit and need to update other drivers, and specs for node do not even run clean, 4 issues in spec setups. Part 5 contains important changes:
and fixes from @takaram This contains kinda working process spawning methods, but they are still in progress, specifically the args checking needs to be common, coming next. This should have been the "minispecs working part", but well, thats maybe for part 6 or 7. |
| c | ||
| end | ||
|
|
||
| def gets(sep = $/, limit = nil, chomp: false) |
There was a problem hiding this comment.
Ruby StringIO has IO::generic_readable and IO::generic_writable as ancestors - which seem like to be an internal thing.
Still we may want to simulate it somewhat, so that certain functions are not duplicated.
| @@ -8,7 +8,18 @@ | |||
| class ::String < `String` | |||
There was a problem hiding this comment.
Can the changes on String/Encoding be separated to another PR?
There was a problem hiding this comment.
I added another section to the top comment here "Desired Extractions", please add everything you want in a separate PR there or mention in a comment and i will add and i will then attend to them once everything is working.
|
Some rspec actions where apperaring green although they should have been red, so i missed them. As they now appear red i removed the "ready to merge" label and handle the failing spec. |
1192fc1 to
3f0d06e
Compare
|
Alright, DONE |
Currently, some codes output warnings like the following. ``` warning: Backtick operator usage interpreted as intent to embed JavaScript; this code will break in Opal 2.0; add a magic comment: `# backtick_javascript: true` -- ./try_ruby.rb: ``` https://github.com/ruby/TryRuby/actions/runs/17408494030/job/49419277575#step:4:8 In Opal 2, `backtick_javascript` defaults to false, because `Kernel#backtick` is implemented. Files using inline JavaScript must add the `# backtick_javascript: true` magic comment. Ref: opal/opal#2746
d69e408 to
c142f38
Compare
a39153d to
5fb706e
Compare
|
rebase to master |
…nd small platform drivers; Make corelib work on all platforms as perfect as possible; Implement #format, #fnmatch, #glob, #expand_path, #absolute_path, #dirname; Implement platform driver for node; New #exit code based on SystemExit; Implement IO.copy_stream, Kernel.singleton_methods, FileUitls, Pathname, tmpdir, FileTest, Etc, ARGF, ARGV, ENV; Kernel and Process process spawning methods; Set backtick default to false; Always raise NotImplementedError for missing features; Document String and Encoding, Srting improvements
26d9b99 to
c8f0eac
Compare
|
Rebased. Somehow something in Node 25 creates a different byte stream for some encodings for #syswrite or #write, also affecting some other tests. I simply filtered the specs/tests. Those specs/tests work in Node 22/24 without problem. Don't know what is causing trouble in Node 25. rspec-windows with ruby 4.0 as default exits with 1, even though specs pass. |
Goals of this PR
Goodies
bundle exec rake mspec_ruby_nodeImplementation
Before Opal had custom implementations of everything platform dependent for each platform, which required a lot of code and left most platforms badly and partially supported. This PR improves the situation by providing a common corelib implementation of methods, that depend on platform dependent code, that works across all platforms and requires therefore only small platform drivers to implement the final system calls or provide a emulation or raise a error, depending on platform capabilities.
Notes for Review
There are still a few todos and see platform footnotes below.
Platform Status
strikemeans unable to run specs reliably or at allServers
Browsers
Others
000000545, 2f0000000000Still to do
(no specific order)
__dir__and__FILE__Desired Extractions
*as much as possible
*1 numbers not updated
*4 graalnodejs is 10 times too slow, not running tests, but in terms of correctness its very, very close to nodejs results
*5 gjs and cjs suffer from a totally unstable API in terms of IO, not practical for any real use, specific runner and driver removed
*6 mini_racer just exits, best i can get is: in 'MiniRacer::Context#eval': unsupported type b (MiniRacer::InternalError)
*7 no specific driver for osascript anymore, works mostly but specs don't finish, mspec_opal and minitest work but statstics not visible, runner removed
*8 quickjs, as a platform with a runner but no driver, serves as example for a 'unknown' platform