| ... | ... | @@ -450,6 +450,36 @@ pub fn buildExe(zigexec: []const u8, zigfile: []const u8, binfile: []const u8) ! |
| 450 | 450 | try expectEqual(ret_val, .{ .Exited = 0 }); |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | /// Spawns a zig build runner process 'zigexec build subcmd' and |
| 454 | /// expects success |
| 455 | /// If specified, runs zig build in the cwd path |
| 456 | /// If specified, uses the specified lib_dir for zig standard library |
| 457 | /// instead of compiler's default library directory |
| 458 | pub fn runZigBuild(zigexec: []const u8, options: struct { |
| 459 | subcmd: ?[]const u8 = null, |
| 460 | cwd: ?[]const u8 = null, |
| 461 | lib_dir: ?[]const u8 = null, |
| 462 | }) !std.ChildProcess.ExecResult { |
| 463 | var args = std.ArrayList([]const u8).init(allocator); |
| 464 | defer args.deinit(); |
| 465 | |
| 466 | try args.appendSlice(&.{ zigexec, "build" }); |
| 467 | if (options.subcmd) |subcmd| try args.append(subcmd); |
| 468 | if (options.lib_dir) |lib_dir| try args.append(lib_dir); |
| 469 | |
| 470 | var result = try std.ChildProcess.exec(.{ |
| 471 | .allocator = allocator, |
| 472 | .argv = args.items, |
| 473 | .cwd = if (options.cwd) |c| c else null, |
| 474 | }); |
| 475 | errdefer { |
| 476 | allocator.free(result.stdout); |
| 477 | allocator.free(result.stderr); |
| 478 | } |
| 479 | |
| 480 | return result; |
| 481 | } |
| 482 | |
| 453 | 483 | test "expectEqual nested array" { |
| 454 | 484 | const a = [2][2]f32{ |
| 455 | 485 | [_]f32{ 1.0, 0.0 }, |