From 200fbe9b959563c78f1e6af3197ade6b3181d8fc Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 29 Nov 2016 07:20:12 -0700 Subject: [PATCH] fix `rename-file-or-directory` for raising `exn:failsystem:fail:exists` Broken by 0133954c84, which avoided a made-up `EEXIST` but left in place a no-loner-appropriate test for raising `exn:failsystem:fail:exists`. --- pkgs/racket-test-core/tests/racket/path.rktl | 7 ++++--- racket/src/racket/src/file.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/racket-test-core/tests/racket/path.rktl b/pkgs/racket-test-core/tests/racket/path.rktl index e639bbe47f..3e1d74c544 100644 --- a/pkgs/racket-test-core/tests/racket/path.rktl +++ b/pkgs/racket-test-core/tests/racket/path.rktl @@ -64,6 +64,7 @@ (define delete-file/tf (lambda (x) ((make-/tf delete-file exn:fail:filesystem?) x))) (define delete-directory/tf (lambda (x) ((make-/tf delete-directory exn:fail:filesystem?) x))) (define rename-file-or-directory/tf (lambda (x y) ((make-/tf rename-file-or-directory exn:fail:filesystem?) x y))) +(define rename-file-or-directory/exists/tf (lambda (x y) ((make-/tf rename-file-or-directory exn:fail:filesystem:exists?) x y))) (define make-directory/tf (lambda (x) ((make-/tf make-directory exn:fail:filesystem?) x))) (define copy-file/tf (lambda (x y) ((make-/tf copy-file exn:fail:filesystem?) x y))) @@ -191,8 +192,8 @@ (close-output-port (open-output-file "tmp5")) (test #t file-exists? "tmp5") (test #t file-exists? "tmp5x") -(test #f rename-file-or-directory/tf "tmp5" "tmp5x") -(test #f rename-file-or-directory/tf "tmp5" "down") +(test #f rename-file-or-directory/exists/tf "tmp5" "tmp5x") +(test #f rename-file-or-directory/exists/tf "tmp5" "down") (delete-file "tmp5") (test #f file-exists? "tmp5") (test #t rename-file-or-directory/tf (build-path "down" "tmp8") (build-path "down" "tmp8x")) @@ -201,7 +202,7 @@ (test #f rename-file-or-directory/tf (build-path deepdir "tmp7") (build-path deepdir "tmp7x")) (test #t make-directory/tf "downx") -(test #f rename-file-or-directory/tf "down" "downx") +(test #f rename-file-or-directory/exists/tf "down" "downx") (test #t delete-directory/tf "downx") (test #t rename-file-or-directory/tf "down" "downx") diff --git a/racket/src/racket/src/file.c b/racket/src/racket/src/file.c index 26ba776b1e..90c0c6154e 100644 --- a/racket/src/racket/src/file.c +++ b/racket/src/racket/src/file.c @@ -4300,7 +4300,7 @@ static Scheme_Object *rename_file(int argc, Scheme_Object **argv) /* We use a specialized error message here, because it's not a system error (e.g., setting `errno` to `EEXIST` would be a lie). */ - scheme_raise_exn((exists_ok < 0) ? MZEXN_FAIL_FILESYSTEM_EXISTS : MZEXN_FAIL_FILESYSTEM, + scheme_raise_exn(MZEXN_FAIL_FILESYSTEM_EXISTS, "rename-file-or-directory: cannot rename file or directory;\n" " the destination path already exists\n" " source path: %q\n"