Skip to content

Dir#glob does not return files with proper cases #2150

@headius

Description

@headius

This appears to be a test for case-insensitive, case-preserving filesystems like HFS (non-case-sensitive mode), FAT32, NTFS and so on. We do not return the files with the proper case. This may be a simple fix, like absolutizing the filenames before we return them or something similar.

  def test_glob_cases
    feature5994 = "[ruby-core:42469] [Feature #5994]"
    feature5994 << "\nDir.glob should return the filename with actual cases on the filesystem"
    Dir.chdir(File.join(@root, "a")) do
      open("FileWithCases", "w") {}
      return unless File.exist?("filewithcases")
      assert_equal(%w"FileWithCases", Dir.glob("filewithcases"), feature5994)
    end
    Dir.chdir(File.join(@root, "c")) do
      open("FileWithCases", "w") {}
      mode = File.stat(".").mode
      begin
        File.chmod(mode & ~0444, ".")
        return if mode == File.stat(".").mode
        assert_equal(%w"filewithcases", Dir.glob("filewithcases"), feature5994)
      ensure
        File.chmod(mode, ".")
      end
    end
  end

Failure:

TestDir#test_glob_cases [/Users/headius/projects/jruby/test/mri/ruby/test_dir.rb:238]:
[ruby-core:42469] [Feature #5994]
Dir.glob should return the filename with actual cases on the filesystem.
<["FileWithCases"]> expected but was
<["filewithcases"]>.

Test can be run with jruby test/mri/runner.rb ruby/test_dir.rb -n test_glob_cases

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions