@@ -126,6 +126,41 @@ pub fn main() !u8 {
126
126
dumpExecResult (result );
127
127
try testing .expect (std .mem .eql (u8 , result .stdout , "0.7.0\n " ));
128
128
}
129
+
130
+ // verify we print a nice error message if we can't update the symlink
131
+ // because it's a directory
132
+ {
133
+ const zig_exe_link = comptime "scratch" ++ sep ++ "bin" ++ sep ++ "zig" ++ builtin .target .exeFileExt ();
134
+
135
+ if (std .fs .cwd ().access (zig_exe_link , .{})) {
136
+ try std .fs .cwd ().deleteFile (zig_exe_link );
137
+ } else | err | switch (err ) {
138
+ error .FileNotFound = > {},
139
+ else = > | e | return e ,
140
+ }
141
+ try std .fs .cwd ().makeDir (zig_exe_link );
142
+
143
+ const result = try runCaptureOuts (allocator , zigup_args ++ &[_ ][]const u8 { "default" , "0.7.0" });
144
+ defer {
145
+ allocator .free (result .stdout );
146
+ allocator .free (result .stderr );
147
+ }
148
+ dumpExecResult (result );
149
+ switch (result .term ) {
150
+ .Exited = > | code | try testing .expectEqual (@as (u8 , 1 ), code ),
151
+ else = > | term | std .debug .panic ("unexpected exit {}" , .{term }),
152
+ }
153
+ if (builtin .os .tag == .windows ) {
154
+ try testing .expect (std .mem .containsAtLeast (u8 , result .stderr , 1 , "unable to create the exe link, the path '" ));
155
+ try testing .expect (std .mem .containsAtLeast (u8 , result .stderr , 1 , "' is a directory" ));
156
+ } else {
157
+ try testing .expect (std .mem .containsAtLeast (u8 , result .stderr , 1 , "unable to update/overwrite the 'zig' PATH symlink, the file '" ));
158
+ try testing .expect (std .mem .containsAtLeast (u8 , result .stderr , 1 , "' already exists and is not a symlink" ));
159
+ }
160
+
161
+ try std .fs .cwd ().deleteDir (zig_exe_link );
162
+ }
163
+
129
164
{
130
165
const result = try runCaptureOuts (allocator , zigup_args ++ &[_ ][]const u8 { "fetch" , "0.7.0" });
131
166
defer {
0 commit comments