@@ -107,45 +107,52 @@ fake_repl() do stdin_write, stdout_read, repl
107107 # Test cd feature in shell mode.
108108 origpwd = pwd ()
109109 mktempdir () do tmpdir
110- # Test `cd`'ing to an absolute path
111- write (stdin_write, " ;" )
112- readuntil (stdout_read, " shell> " )
113- write (stdin_write, " cd $(escape_string (tmpdir)) \n " )
114- readuntil (stdout_read, " cd $(escape_string (tmpdir)) " )
115- readuntil (stdout_read, realpath (tmpdir))
116- readuntil (stdout_read, " \n " )
117- readuntil (stdout_read, " \n " )
118- @test pwd () == realpath (tmpdir)
119-
120- # Test using `cd` to move to the home directory
121- write (stdin_write, " ;" )
122- readuntil (stdout_read, " shell> " )
123- write (stdin_write, " cd\n " )
124- readuntil (stdout_read, realpath (homedir ()))
125- readuntil (stdout_read, " \n " )
126- readuntil (stdout_read, " \n " )
127- @test pwd () == realpath (homedir ())
110+ try
111+ samefile = Base. Filesystem. samefile
112+ tmpdir_pwd = cd (pwd, tmpdir)
113+ homedir_pwd = cd (pwd, homedir ())
128114
129- # Test using `-` to jump backward to tmpdir
130- write (stdin_write, " ;" )
131- readuntil (stdout_read, " shell> " )
132- write (stdin_write, " cd -\n " )
133- readuntil (stdout_read, tmpdir)
134- readuntil (stdout_read, " \n " )
135- readuntil (stdout_read, " \n " )
136- @test pwd () == realpath (tmpdir)
137-
138- # Test using `~` in `cd` commands
139- if ! Sys. iswindows ()
115+ # Test `cd`'ing to an absolute path
140116 write (stdin_write, " ;" )
141117 readuntil (stdout_read, " shell> " )
142- write (stdin_write, " cd ~\n " )
143- readuntil (stdout_read, realpath (homedir ()))
118+ write (stdin_write, " cd $(escape_string (tmpdir)) \n " )
119+ readuntil (stdout_read, " cd $(escape_string (tmpdir)) " )
120+ readuntil (stdout_read, tmpdir_pwd)
121+ readuntil (stdout_read, " \n " )
144122 readuntil (stdout_read, " \n " )
123+ @test samefile (" ." , tmpdir)
124+
125+ # Test using `cd` to move to the home directory
126+ write (stdin_write, " ;" )
127+ readuntil (stdout_read, " shell> " )
128+ write (stdin_write, " cd\n " )
129+ readuntil (stdout_read, homedir_pwd)
145130 readuntil (stdout_read, " \n " )
146- @test pwd () == realpath (homedir ())
131+ readuntil (stdout_read, " \n " )
132+ @test samefile (" ." , homedir_pwd)
133+
134+ # Test using `-` to jump backward to tmpdir
135+ write (stdin_write, " ;" )
136+ readuntil (stdout_read, " shell> " )
137+ write (stdin_write, " cd -\n " )
138+ readuntil (stdout_read, tmpdir_pwd)
139+ readuntil (stdout_read, " \n " )
140+ readuntil (stdout_read, " \n " )
141+ @test samefile (" ." , tmpdir)
142+
143+ # Test using `~` (Base.expanduser) in `cd` commands
144+ if ! Sys. iswindows ()
145+ write (stdin_write, " ;" )
146+ readuntil (stdout_read, " shell> " )
147+ write (stdin_write, " cd ~\n " )
148+ readuntil (stdout_read, homedir_pwd)
149+ readuntil (stdout_read, " \n " )
150+ readuntil (stdout_read, " \n " )
151+ @test samefile (" ." , homedir_pwd)
152+ end
153+ finally
154+ cd (origpwd)
147155 end
148- cd (origpwd)
149156 end
150157
151158 # issue #20482
0 commit comments