Remove stderr pollution in tests
This commit is contained in:
parent
cd86e774d5
commit
d3703aa23d
1 changed files with 8 additions and 3 deletions
|
|
@ -249,6 +249,11 @@ fn initFromParsed(comptime T: type, allocator: Allocator, flags: []Arg) !T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (builtin.is_test) {
|
||||||
|
// early return to not pollute the stderr
|
||||||
|
return error.NoValueForFlag;
|
||||||
|
}
|
||||||
|
|
||||||
if (inDebugMode) {
|
if (inDebugMode) {
|
||||||
log.warn("flag `{s}` expected a value, but none was provided", .{f.name});
|
log.warn("flag `{s}` expected a value, but none was provided", .{f.name});
|
||||||
log.warn("expected type: {s}", .{niceTypeName(@TypeOf(fie.*.value))});
|
log.warn("expected type: {s}", .{niceTypeName(@TypeOf(fie.*.value))});
|
||||||
|
|
@ -325,11 +330,11 @@ fn initFromParsed(comptime T: type, allocator: Allocator, flags: []Arg) !T {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (builtin.is_test) {
|
if (builtin.is_test) {
|
||||||
log.warn("could not find positional argument for `{s}`", .{field.name});
|
// early return to not pollute the stderr
|
||||||
} else {
|
return error.NoArgumentFound;
|
||||||
log.err("could not find positional argument for `{s}`", .{field.name});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.err("could not find positional argument for `{s}`", .{field.name});
|
||||||
log.warn("hint: expected type: {s}", .{niceTypeName(@TypeOf(fie.*.value))});
|
log.warn("hint: expected type: {s}", .{niceTypeName(@TypeOf(fie.*.value))});
|
||||||
log.warn("hint: try `<value>`", .{});
|
log.warn("hint: try `<value>`", .{});
|
||||||
return error.NoArgumentFound;
|
return error.NoArgumentFound;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue