From eb24c1e0b18e1e813e3c34d9941b8823f8f0bdb2 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 29 Jun 2017 13:26:24 -0600 Subject: [PATCH] find-relative-path: correct contract in docs Also, avoid a test on Windows that can't work there. --- pkgs/racket-doc/scribblings/reference/paths.scrbl | 6 ++++-- pkgs/racket-test-core/tests/racket/pathlib.rktl | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/racket-doc/scribblings/reference/paths.scrbl b/pkgs/racket-doc/scribblings/reference/paths.scrbl index f3d3f9c70e..1c409aa6fd 100644 --- a/pkgs/racket-doc/scribblings/reference/paths.scrbl +++ b/pkgs/racket-doc/scribblings/reference/paths.scrbl @@ -696,7 +696,7 @@ no extension, @racket[#f] is returned.} [path (or/c path-string? path-for-some-system?)] [#:more-than-root? more-than-root? any/c #f] [#:normalize-case? normalize-case? any/c #t]) - path-for-some-system?]{ + (or/c path-for-some-system? path-string?)]{ Finds a relative pathname with respect to @racket[base] that names the same file or directory as @racket[path]. Both @racket[base] and @@ -707,7 +707,9 @@ common with @racket[base], @racket[path] is returned. If @racket[more-than-root?] is true, if @racket[base] and @racket[path] share only a Unix root in common, and if neither @racket[base] nor @racket[path] is just a root path, then -@racket[path] is returned. +@racket[path] is returned. The case when @racket[path] is returned +and is a string is the only case when @racket[find-relative-path] +returns a string result. If @racket[normalize-case?] is true (the default), then pairs of path elements to be compared are first converted via diff --git a/pkgs/racket-test-core/tests/racket/pathlib.rktl b/pkgs/racket-test-core/tests/racket/pathlib.rktl index daf95fdf76..021dfee2ed 100644 --- a/pkgs/racket-test-core/tests/racket/pathlib.rktl +++ b/pkgs/racket-test-core/tests/racket/pathlib.rktl @@ -86,7 +86,10 @@ #:more-than-root? #t)) (test (bytes->path #"../.." 'unix) 'find-relative-path (find-relative-path (bytes->path #"/r/c" 'unix) (bytes->path #"/" 'unix) #:more-than-root? #t)) -(test "/" 'find-relative-path (find-relative-path "/" "/" #:more-than-root? #t)) + +(when (eq? 'unix (system-path-convention-type)) + (test "/" 'find-relative-path (find-relative-path "/" "/" #:more-than-root? #t)) + (test "/b" 'find-relative-path (find-relative-path "/a" "/b" #:more-than-root? #t))) (test (bytes->path #"..\\b\\a" 'windows) find-relative-path (bytes->path #"C:/r/c" 'windows) (bytes->path #"c:/R/b/a" 'windows)) (test (bytes->path #"..\\b\\a" 'windows) find-relative-path (bytes->path #"C:/r/c" 'windows) (bytes->path #"c:/r/b/a" 'windows))