Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check conformity of all interfaces provided by fakefs to Ruby Matz distribution #430

Open
anryoshi opened this issue Mar 11, 2019 · 6 comments

Comments

@anryoshi
Copy link
Contributor

Greetings
FileTest module looks a little too thin to handle what Pathname wants from him.

FakeFS.with_fresh do
      source = Pathname.new("a.txt")
      FileUtils.touch(source)
      target = Pathname.new("b.txt")
      target.make_symlink(source)
      p File.symlink?(target) # Good
      p target.symlink? # Fails with NoMethodError:  undefined method `symlink?' for FakeFS::FileTest:Module
end

Don't get the purpose of FileTest file at all, it just passes all responsibility to File module

@grosser
Copy link
Collaborator

grosser commented Mar 11, 2019

idk why FileTest exists ... ask the initial author or go spelunking through git history 🤷‍♂️
PR welcome if you figure out how to fix this

@anryoshi
Copy link
Contributor Author

idk why FileTest exists ... ask the initial author or go spelunking through git history 🤷‍♂️
PR welcome if you figure out how to fix this

Looks like it was done to conform ruby standard library https://ruby-doc.org/core-2.6.1/FileTest.html
So the good solution probably will be add missing methods and create test to check that set of methods is the same like in actual FileTest module

@grosser
Copy link
Collaborator

grosser commented Mar 12, 2019 via email

@anryoshi
Copy link
Contributor Author

@grosser I've created pull request for this #431

@anryoshi anryoshi changed the title Pathname call functions in FileTest that doesn't exist Check conformity of all interfaces provided by fakefs to Ruby Matz distribution Mar 15, 2019
@anryoshi
Copy link
Contributor Author

Have renamed to represent more common goal. It will be nice to have tests that check equality the sets of methods provided by fakefs and Ruby distribution in module/classes - File, File::Stat, FileUtils, FileTests, Pathname and etc

@aried3r
Copy link
Contributor

aried3r commented Jan 7, 2020

Adding to this, Ruby 2.7 does include some changes to File. I discovered this while ]working on memfs](simonc/memfs#30 (comment)). That's at least one of the changes I discovered.

To summarize:
In Ruby 2.7 File::extname returns . on non-Windows platforms.

https://docs.ruby-lang.org/en/2.7.0/File.html#method-c-extname
https://docs.ruby-lang.org/en/2.7.0/NEWS.html
https://rubyreferences.github.io/rubychanges/2.7.html#fileextname-returns-a--string-at-a-name-ending-with-a-dot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants