From dac23bd75c46969cc4df38514fa40c2fe5799d0f Mon Sep 17 00:00:00 2001 From: Oreofe Date: Sun, 30 Aug 2026 15:36:29 +0100 Subject: [PATCH] test(e2e): assert on rendered values, not bare numbers, in the floql tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `ts floql` renders each point as `: `, and these tests write with wall-clock timestamps, so a bare-number substring assertion is matching against a 13-digit number as well as the value. try testing.expect(result.contains("10")); try testing.expect(!result.contains("30")); Both directions are unsound. Sampling epoch-ms across 48h: the timestamp contains "30" about 4.2% of the time, which makes the negative assertion fail a run that is behaving correctly; it contains "10" about 9.6% of the time, which makes the positive assertion pass even when the value is wrong. The worst case was `contains("2")` in the modulo test — a single digit appears in a 13-digit timestamp roughly three quarters of the time, so that assertion was mostly measuring nothing. Values always render with four decimals and timestamps never contain a '.', so matching the rendered form cannot collide. `floql glob tag filter =~` already did this with "20.0000"; the rest now match. Verified the new assertions actually bite: mutating an expected value makes the test fail. The whole `e2e/ts` suite passes, as does test-unit. Whether this is the cause of the intermittent failure in #61 is not proven — 16 local runs of the old assertion did not reproduce it, though consecutive local runs share nearly all timestamp digits so that is weak evidence, and 4.2% predicts roughly zero failures in 16. The assertion is unsound regardless. --- tests/e2e/ts_test.zig | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/e2e/ts_test.zig b/tests/e2e/ts_test.zig index 201927c..82ef307 100644 --- a/tests/e2e/ts_test.zig +++ b/tests/e2e/ts_test.zig @@ -1125,7 +1125,7 @@ test "e2e/ts: floql math subtract" { try stdx.testing.assertSucceeded(result); // 50-10=40 - try testing.expect(result.contains("40")); + try testing.expect(result.contains("40.0000")); } test "e2e/ts: floql math modulo" { @@ -1141,7 +1141,7 @@ test "e2e/ts: floql math modulo" { try stdx.testing.assertSucceeded(result); // 17 % 5 = 2 - try testing.expect(result.contains("2")); + try testing.expect(result.contains("2.0000")); } test "e2e/ts: floql math chained with aggregation" { @@ -1175,7 +1175,7 @@ test "e2e/ts: floql math shorthand (no 'value' keyword)" { try stdx.testing.assertSucceeded(result); // 10*2=20 - try testing.expect(result.contains("20")); + try testing.expect(result.contains("20.0000")); } // ============================================================================= @@ -1195,7 +1195,7 @@ test "e2e/ts: floql round to integer" { try stdx.testing.assertSucceeded(result); // 72.567 rounded to 0 decimals → 73 - try testing.expect(result.contains("73")); + try testing.expect(result.contains("73.0000")); } test "e2e/ts: floql round to 2 decimals" { @@ -1211,7 +1211,7 @@ test "e2e/ts: floql round to 2 decimals" { try stdx.testing.assertSucceeded(result); // 72.5678 rounded to 2 decimals → 72.57 - try testing.expect(result.contains("72.57")); + try testing.expect(result.contains("72.5700")); } test "e2e/ts: floql round default (no args)" { @@ -1227,7 +1227,7 @@ test "e2e/ts: floql round default (no args)" { try stdx.testing.assertSucceeded(result); // Default round → nearest integer → 43 - try testing.expect(result.contains("43")); + try testing.expect(result.contains("43.0000")); } test "e2e/ts: floql math then round" { @@ -1244,7 +1244,7 @@ test "e2e/ts: floql math then round" { try stdx.testing.assertSucceeded(result); // Should contain 33.3 - try testing.expect(result.contains("33.3")); + try testing.expect(result.contains("33.3000")); } // ============================================================================= @@ -1268,7 +1268,7 @@ test "e2e/ts: floql glob tag filter =~" { defer result.deinit(); try stdx.testing.assertSucceeded(result); - try testing.expect(result.contains("15")); + try testing.expect(result.contains("15.0000")); try testing.expect(!result.contains("20.0000")); } @@ -1287,9 +1287,14 @@ test "e2e/ts: floql negate glob tag filter !~" { }); defer result.deinit(); + // Match the rendered value, not a bare number: output lines are + // `: ` and these points carry wall-clock timestamps, so a + // bare "30" matches a digit pair inside the timestamp and fails a passing + // run. Values always render with four decimals and timestamps never contain + // a '.', so the decimal form cannot collide. try stdx.testing.assertSucceeded(result); - try testing.expect(result.contains("10")); - try testing.expect(!result.contains("30")); + try testing.expect(result.contains("10.0000")); + try testing.expect(!result.contains("30.0000")); } test "e2e/ts: floql neq tag filter with !=" {