@@ -89,7 +89,18 @@ pub fn main() !void {
89
89
const out = bw .writer ();
90
90
91
91
try printSourceBlock (arena , out , source , fs .path .basename (input_path ));
92
- try printOutput (arena , out , code , input_path , zig_path , opt_zig_lib_dir , tmp_dir_path );
92
+ try printOutput (
93
+ arena ,
94
+ out ,
95
+ code ,
96
+ tmp_dir_path ,
97
+ try std .fs .path .relative (arena , tmp_dir_path , zig_path ),
98
+ try std .fs .path .relative (arena , tmp_dir_path , input_path ),
99
+ if (opt_zig_lib_dir ) | zig_lib_dir |
100
+ try std .fs .path .relative (arena , tmp_dir_path , zig_lib_dir )
101
+ else
102
+ null ,
103
+ );
93
104
94
105
try bw .flush ();
95
106
}
@@ -98,10 +109,14 @@ fn printOutput(
98
109
arena : Allocator ,
99
110
out : anytype ,
100
111
code : Code ,
101
- input_path : []const u8 ,
112
+ /// Relative to this process' cwd.
113
+ tmp_dir_path : []const u8 ,
114
+ /// Relative to `tmp_dir_path`.
102
115
zig_exe : []const u8 ,
116
+ /// Relative to `tmp_dir_path`.
117
+ input_path : []const u8 ,
118
+ /// Relative to `tmp_dir_path`.
103
119
opt_zig_lib_dir : ? []const u8 ,
104
- tmp_dir_path : []const u8 ,
105
120
) ! void {
106
121
var env_map = try process .getEnvMap (arena );
107
122
try env_map .put ("CLICOLOR_FORCE" , "1" );
@@ -304,7 +319,7 @@ fn printOutput(
304
319
},
305
320
}
306
321
}
307
- const result = run (arena , & env_map , null , test_args .items ) catch
322
+ const result = run (arena , & env_map , tmp_dir_path , test_args .items ) catch
308
323
fatal ("test failed" , .{});
309
324
const escaped_stderr = try escapeHtml (arena , result .stderr );
310
325
const escaped_stdout = try escapeHtml (arena , result .stdout );
@@ -339,6 +354,7 @@ fn printOutput(
339
354
.allocator = arena ,
340
355
.argv = test_args .items ,
341
356
.env_map = & env_map ,
357
+ .cwd = tmp_dir_path ,
342
358
.max_output_bytes = max_doc_file_size ,
343
359
});
344
360
switch (result .term ) {
@@ -395,6 +411,7 @@ fn printOutput(
395
411
.allocator = arena ,
396
412
.argv = test_args .items ,
397
413
.env_map = & env_map ,
414
+ .cwd = tmp_dir_path ,
398
415
.max_output_bytes = max_doc_file_size ,
399
416
});
400
417
switch (result .term ) {
@@ -432,10 +449,7 @@ fn printOutput(
432
449
zig_exe , "build-obj" ,
433
450
"--color" , "on" ,
434
451
"--name" , code_name ,
435
- input_path ,
436
- try std .fmt .allocPrint (arena , "-femit-bin={s}{c}{s}" , .{
437
- tmp_dir_path , fs .path .sep , name_plus_obj_ext ,
438
- }),
452
+ input_path , try std .fmt .allocPrint (arena , "-femit-bin={s}" , .{name_plus_obj_ext }),
439
453
});
440
454
if (opt_zig_lib_dir ) | zig_lib_dir | {
441
455
try build_args .appendSlice (&.{ "--zig-lib-dir" , zig_lib_dir });
@@ -465,6 +479,7 @@ fn printOutput(
465
479
.allocator = arena ,
466
480
.argv = build_args .items ,
467
481
.env_map = & env_map ,
482
+ .cwd = tmp_dir_path ,
468
483
.max_output_bytes = max_doc_file_size ,
469
484
});
470
485
switch (result .term ) {
@@ -489,7 +504,7 @@ fn printOutput(
489
504
const colored_stderr = try termColor (arena , escaped_stderr );
490
505
try shell_out .print ("\n {s} " , .{colored_stderr });
491
506
} else {
492
- _ = run (arena , & env_map , null , build_args .items ) catch fatal ("example failed to compile" , .{});
507
+ _ = run (arena , & env_map , tmp_dir_path , build_args .items ) catch fatal ("example failed to compile" , .{});
493
508
}
494
509
try shell_out .writeAll ("\n " );
495
510
},
@@ -505,10 +520,7 @@ fn printOutput(
505
520
506
521
try test_args .appendSlice (&[_ ][]const u8 {
507
522
zig_exe , "build-lib" ,
508
- input_path ,
509
- try std .fmt .allocPrint (arena , "-femit-bin={s}{s}{s}" , .{
510
- tmp_dir_path , fs .path .sep_str , bin_basename ,
511
- }),
523
+ input_path , try std .fmt .allocPrint (arena , "-femit-bin={s}" , .{bin_basename }),
512
524
});
513
525
if (opt_zig_lib_dir ) | zig_lib_dir | {
514
526
try test_args .appendSlice (&.{ "--zig-lib-dir" , zig_lib_dir });
@@ -542,7 +554,7 @@ fn printOutput(
542
554
try test_args .append (option );
543
555
try shell_out .print ("{s} " , .{option });
544
556
}
545
- const result = run (arena , & env_map , null , test_args .items ) catch fatal ("test failed" , .{});
557
+ const result = run (arena , & env_map , tmp_dir_path , test_args .items ) catch fatal ("test failed" , .{});
546
558
const escaped_stderr = try escapeHtml (arena , result .stderr );
547
559
const escaped_stdout = try escapeHtml (arena , result .stdout );
548
560
try shell_out .print ("\n {s}{s}\n " , .{ escaped_stderr , escaped_stdout });
@@ -1076,7 +1088,7 @@ fn in(slice: []const u8, number: u8) bool {
1076
1088
fn run (
1077
1089
allocator : Allocator ,
1078
1090
env_map : * process.EnvMap ,
1079
- cwd : ? []const u8 ,
1091
+ cwd : []const u8 ,
1080
1092
args : []const []const u8 ,
1081
1093
) ! process.Child.RunResult {
1082
1094
const result = try process .Child .run (.{
0 commit comments