| ... | @@ -1257,30 +1257,6 @@ fn runCommand( | ... | @@ -1257,30 +1257,6 @@ fn runCommand( |
| 1257 | }; | 1257 | }; |
| 1258 | defer env_map.deinit(); | 1258 | defer env_map.deinit(); |
| 1259 | | 1259 | |
| 1260 | color: switch (run.color) { | | |
| 1261 | .manual => {}, | | |
| 1262 | .enable => { | | |
| 1263 | try env_map.put("CLICOLOR_FORCE", "1"); | | |
| 1264 | env_map.remove("NO_COLOR"); | | |
| 1265 | }, | | |
| 1266 | .disable => { | | |
| 1267 | try env_map.put("NO_COLOR", "1"); | | |
| 1268 | env_map.remove("CLICOLOR_FORCE"); | | |
| 1269 | }, | | |
| 1270 | .inherit => {}, | | |
| 1271 | .auto => { | | |
| 1272 | const capture_stderr = run.captured_stderr != null or switch (run.stdio) { | | |
| 1273 | .check => |checks| checksContainStderr(checks.items), | | |
| 1274 | .infer_from_args, .inherit, .zig_test => false, | | |
| 1275 | }; | | |
| 1276 | if (capture_stderr) { | | |
| 1277 | continue :color .disable; | | |
| 1278 | } else { | | |
| 1279 | continue :color .inherit; | | |
| 1280 | } | | |
| 1281 | }, | | |
| 1282 | } | | |
| 1283 | | | |
| 1284 | const opt_generic_result = spawnChildAndCollect(run, argv, &env_map, has_side_effects, options, fuzz_context) catch |err| term: { | 1260 | const opt_generic_result = spawnChildAndCollect(run, argv, &env_map, has_side_effects, options, fuzz_context) catch |err| term: { |
| 1285 | // InvalidExe: cpu arch mismatch | 1261 | // InvalidExe: cpu arch mismatch |
| 1286 | // FileNotFound: can happen with a wrong dynamic linker path | 1262 | // FileNotFound: can happen with a wrong dynamic linker path |
| ... | @@ -1648,7 +1624,10 @@ fn spawnChildAndCollect( | ... | @@ -1648,7 +1624,10 @@ fn spawnChildAndCollect( |
| 1648 | if (!run.disable_zig_progress and !inherit) { | 1624 | if (!run.disable_zig_progress and !inherit) { |
| 1649 | child.progress_node = options.progress_node; | 1625 | child.progress_node = options.progress_node; |
| 1650 | } | 1626 | } |
| 1651 | if (inherit) _ = std.debug.lockStderrWriter(&.{}); | 1627 | if (inherit) { |
| | 1628 | const stderr = std.debug.lockStderrWriter(&.{}); |
| | 1629 | try setColorEnvironmentVariables(run, env_map, stderr.mode); |
| | 1630 | } |
| 1652 | defer if (inherit) std.debug.unlockStderrWriter(); | 1631 | defer if (inherit) std.debug.unlockStderrWriter(); |
| 1653 | var timer = try std.time.Timer.start(); | 1632 | var timer = try std.time.Timer.start(); |
| 1654 | const res = try evalGeneric(run, &child); | 1633 | const res = try evalGeneric(run, &child); |
| ... | @@ -1657,6 +1636,35 @@ fn spawnChildAndCollect( | ... | @@ -1657,6 +1636,35 @@ fn spawnChildAndCollect( |
| 1657 | } | 1636 | } |
| 1658 | } | 1637 | } |
| 1659 | | 1638 | |
| | 1639 | fn setColorEnvironmentVariables(run: *Run, env_map: *EnvMap, fwm: Io.File.Writer.Mode) !void { |
| | 1640 | color: switch (run.color) { |
| | 1641 | .manual => {}, |
| | 1642 | .enable => { |
| | 1643 | try env_map.put("CLICOLOR_FORCE", "1"); |
| | 1644 | env_map.remove("NO_COLOR"); |
| | 1645 | }, |
| | 1646 | .disable => { |
| | 1647 | try env_map.put("NO_COLOR", "1"); |
| | 1648 | env_map.remove("CLICOLOR_FORCE"); |
| | 1649 | }, |
| | 1650 | .inherit => switch (fwm) { |
| | 1651 | .terminal_escaped => continue :color .enable, |
| | 1652 | else => continue :color .disable, |
| | 1653 | }, |
| | 1654 | .auto => { |
| | 1655 | const capture_stderr = run.captured_stderr != null or switch (run.stdio) { |
| | 1656 | .check => |checks| checksContainStderr(checks.items), |
| | 1657 | .infer_from_args, .inherit, .zig_test => false, |
| | 1658 | }; |
| | 1659 | if (capture_stderr) { |
| | 1660 | continue :color .disable; |
| | 1661 | } else { |
| | 1662 | continue :color .inherit; |
| | 1663 | } |
| | 1664 | }, |
| | 1665 | } |
| | 1666 | } |
| | 1667 | |
| 1660 | const StdioPollEnum = enum { stdout, stderr }; | 1668 | const StdioPollEnum = enum { stdout, stderr }; |
| 1661 | | 1669 | |
| 1662 | fn evalZigTest( | 1670 | fn evalZigTest( |