Skip to content

conformance shim: SPEC_TMP_BASE is /tmp, a symlink on darwin — 11 realpath/realdirpath examples compare a resolved path with an unresolved one #630

Open

Description

@tannevaled

scripts/conformance/rubyspec/spec_helper.rb sets

SPEC_TMP_BASE = "/tmp/rbgo_spec_tmp"

On darwin /tmp is a symlink to /private/tmp. Every example of the form

File.realpath(@link).should == @file

therefore compares /private/tmp/... (what any correct realpath returns) with /tmp/... (what tmp() handed the spec), and fails on a path that is right.

MRI 4.0.5 fails them the same way. Witness:

require "fileutils"
base = "/tmp/probe"; FileUtils.mkdir_p File.join(base, "real")
File.symlink File.join(base,"real"), File.join(base,"link")
File.write File.join(base,"real","file"), ""
File.symlink File.join(base,"real","file"), File.join(base,"link","link")
p File.realpath(File.join(base,"link","link"))  #=> "/private/tmp/probe/real/file"
p File.join(base,"real","file")                 #=> "/tmp/probe/real/file"

Real mspec roots tmp() at the spec repo's own tmp/ directory, not at /tmp, so it never meets this.

Cost measured against the pinned corpus: 5 of 5 remaining failures in core/file/realpath_spec.rb and 6 of 7 in core/file/realdirpath_spec.rb. (The seventh, "raises Errno::ENOENT if the symlink points to an absent directory", was a genuine VM defect and is fixed in #629.)

Fix: point SPEC_TMP_BASE at a directory that is not reached through a symlink — e.g. resolve it once at load time with File.realpath, or root it under the corpus checkout.

Two other shim gaps cost examples in the same area and could go in the same change:

  • tmp("") returns a uniquified non-existent path (/tmp/rbgo_spec_tmp/file-1-...) where mspec returns the tmp directory. core/file/stat/blockdev_spec.rb, chardev_spec.rb and the shared open_directory examples in core/file/{open,new}_spec.rb all call tmp("") and get Errno::ENOENT.
  • as_real_superuser and with_block_device are undefined, so the collection blocks that use them fail to load in core/filetest/{executable,readable,writable}_real_spec.rb and core/file/{writable,readable,executable}_real_spec.rb and core/file/stat/ftype_spec.rb.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions