unnoisy the tests
This commit is contained in:
parent
896347692c
commit
1ab6fd8353
4 changed files with 25 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
|||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const zfin = @import("../root.zig");
|
||||
const srf = @import("srf");
|
||||
const history = @import("../history.zig");
|
||||
|
|
@ -109,6 +110,10 @@ pub fn printGainLoss(
|
|||
// ── Stderr helpers ───────────────────────────────────────────
|
||||
|
||||
pub fn stderrPrint(msg: []const u8) !void {
|
||||
// Under `zig build test` these messages are just noise — tests
|
||||
// that exercise error paths emit the same usage/hint strings on
|
||||
// every run. Real CLI users always reach the real stderr.
|
||||
if (builtin.is_test) return;
|
||||
var buf: [1024]u8 = undefined;
|
||||
var writer = std.fs.File.stderr().writer(&buf);
|
||||
const out = &writer.interface;
|
||||
|
|
@ -118,6 +123,7 @@ pub fn stderrPrint(msg: []const u8) !void {
|
|||
|
||||
/// Print progress line to stderr: " [N/M] SYMBOL (status)"
|
||||
pub fn stderrProgress(symbol: []const u8, status: []const u8, current: usize, total: usize, color: bool) !void {
|
||||
if (builtin.is_test) return;
|
||||
var buf: [256]u8 = undefined;
|
||||
var writer = std.fs.File.stderr().writer(&buf);
|
||||
const out = &writer.interface;
|
||||
|
|
@ -133,6 +139,7 @@ pub fn stderrProgress(symbol: []const u8, status: []const u8, current: usize, to
|
|||
|
||||
/// Print rate-limit wait message to stderr
|
||||
pub fn stderrRateLimitWait(wait_seconds: u64, color: bool) !void {
|
||||
if (builtin.is_test) return;
|
||||
var buf: [256]u8 = undefined;
|
||||
var writer = std.fs.File.stderr().writer(&buf);
|
||||
const out = &writer.interface;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
//! all go through here). The command module stays a thin CLI wrapper.
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const srf = @import("srf");
|
||||
const snapshot = @import("models/snapshot.zig");
|
||||
const Date = @import("models/date.zig").Date;
|
||||
|
|
@ -202,7 +203,12 @@ pub fn loadHistoryDir(
|
|||
// `bytes` is freed either by LoadedHistory.deinit on success or
|
||||
// by the branch below on parse failure — no defer-free here.
|
||||
const snap = parseSnapshotBytes(allocator, bytes) catch |err| {
|
||||
std.log.warn("history: failed to parse {s}: {s}", .{ full_path, @errorName(err) });
|
||||
// Tests intentionally feed malformed snapshots to exercise
|
||||
// the error path — suppress the warn under `zig build test`
|
||||
// so real parse failures stay visible in production runs.
|
||||
if (!builtin.is_test) {
|
||||
std.log.warn("history: failed to parse {s}: {s}", .{ full_path, @errorName(err) });
|
||||
}
|
||||
allocator.free(bytes);
|
||||
continue;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
//! `src/commands/contributions.zig` for the classifier integration.
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const srf = @import("srf");
|
||||
const Date = @import("date.zig").Date;
|
||||
|
||||
|
|
@ -239,7 +240,11 @@ pub fn parseTransactionLogFile(
|
|||
|
||||
while (try it.next()) |fields| {
|
||||
const parsed = fields.to(TransferRecord) catch |err| {
|
||||
logger.warn("skipping malformed transfer record: {s}", .{@errorName(err)});
|
||||
// Tests intentionally feed malformed records to exercise the
|
||||
// skip path; real parse failures stay visible outside tests.
|
||||
if (!builtin.is_test) {
|
||||
logger.warn("skipping malformed transfer record: {s}", .{@errorName(err)});
|
||||
}
|
||||
continue;
|
||||
};
|
||||
// String fields on `parsed` point into the iterator's internal
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
//! based on available API keys. Callers never need to know which provider was used.
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const log = std.log.scoped(.service);
|
||||
|
||||
const Date = @import("models/date.zig").Date;
|
||||
|
|
@ -171,7 +172,10 @@ pub const DataService = struct {
|
|||
.thread_safe = .{ .child_allocator = base_allocator },
|
||||
.config = config,
|
||||
};
|
||||
self.logMissingKeys();
|
||||
// Missing-key warnings are noise under `zig build test` where
|
||||
// every test that spins up a DataService re-emits the whole
|
||||
// block. Real users always see them at CLI/TUI startup.
|
||||
if (!builtin.is_test) self.logMissingKeys();
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue