Peach: Local-first video metadata scraper and media manager.
fix(test): 结果历史只逐条写失败与 5 秒以上的通过,验证用例按补测范围断言
longmeidaoc5d04f05be62
diff --git a/docs/TESTING.md b/docs/TESTING.mdindex 83ed94323..04cd212ec 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -259,6 +259,6 @@ PowerShell 里解析到 `Git\cmd\git.exe`、在 Git Bash 里解析到 `Git\mingw之后逐条写 `type` 为 `test` 的行:`run`、`id`、`outcome`(`pass`、`fail`、`error`、`skip`)与 `seconds`,失败与报错另有 `message`,取最后一行异常,遮掉 `token=`、`password=` 一类的值,截断到 200 字。Python 用例名为 `模块.类.方法`,vitest 为 `vitest:文件 > 分组 > 标题`,浏览器用例为 `e2e:文件 > 分组 > 标题`。-为控制体积,只逐条写非通过的用例与耗时不少于 1 秒的通过用例。某条用例跑了几次,用运行头的 `files` 推算:文件在场、没被记成 `skip` 的用例都跑过。+为控制体积,只逐条写非通过的用例与耗时不少于 5 秒的通过用例。一次全量约一万条结果,全部逐条写约 2.4 MB;按这个口径约 250 行、75 KB。某条用例跑了几次,用运行头的 `files` 推算:文件在场、没被记成 `skip` 的用例都跑过;逐文件耗时另见 `test-timings.json`。写历史失败只打印一行告警,不改变测试判定。历史不经环境变量传递,也不在被快照的工作树里,测试记录的环境指纹与有效期不受影响。用例里调用运行器的那些测试不写真实历史,也不取走外层运行收集中的 vitest 与浏览器结果。diff --git a/scripts/test_history.py b/scripts/test_history.pyindex 99d0c037d..2f4b5a2e6 100644--- a/scripts/test_history.py+++ b/scripts/test_history.py@@ -22,7 +22,7 @@ from pathlib import Pathfrom filelock import FileLock, Timeout-SLOW_SECONDS = 1.0+SLOW_SECONDS = 5.0SUMMARY_CHARS = 200OUTCOMES = frozenset({"pass", "fail", "error", "skip"})diff --git a/tests/test_test_evidence.py b/tests/test_test_evidence.pyindex 285b12f13..687ee4c3a 100644--- a/tests/test_test_evidence.py+++ b/tests/test_test_evidence.py@@ -599,7 +599,8 @@ class VerificationTests(unittest.TestCase):mock.patch.object(runner, "resolve_auto_scope", return_value=(("full",), "fixture")), \mock.patch.object(runner, "run_local_suite", return_value=(True, 1, [])) as run:self.assertEqual(runner.main(["--scope", "auto"]), 0)- run.assert_called_once_with(("full",), 1)+ run.assert_called_once()+ self.assertEqual(run.call_args.args[:2], (("full",), 1))def test_baseline_does_not_expand_a_small_requested_scope(self):self.certify(self.repo, ("full",))@@ -682,7 +683,8 @@ class VerificationTests(unittest.TestCase):mock.patch.object(runner, "environment_preflight"), \mock.patch.object(runner, "run_local_suite", return_value=(True, 1, [])) as run:self.assertEqual(runner.main(["--scope", "auto"]), 0)- run.assert_called_once_with(("checks",), 1)+ run.assert_called_once()+ self.assertEqual(run.call_args.args[:2], (("checks",), 1))record = evidence.read(self.repo, current)self.assertTrue(evidence.covers(record, ("full",)))self.assertEqual(record["validated"]["full"], stamp)@@ -739,7 +741,8 @@ class VerificationTests(unittest.TestCase):mock.patch.object(runner, "resolve_auto_scope", return_value=(("catalog", "metadata", "web"), "fixture")), \mock.patch.object(runner, "run_local_suite", return_value=(True, 1, [])) as run:self.assertEqual(runner.main(["--scope", "auto"]), 0)- run.assert_called_once_with(("web",), 1)+ run.assert_called_once()+ self.assertEqual(run.call_args.args[:2], (("web",), 1))record = evidence.read(self.repo, evidence.key(self.repo))self.assertTrue(evidence.covers(record, ("catalog", "metadata", "web")))self.assertNotIn("full", record["validated"])@@ -756,7 +759,8 @@ class VerificationTests(unittest.TestCase):mock.patch.object(runner, "resolve_auto_scope", return_value=(("full",), "fixture")), \mock.patch.object(runner, "run_local_suite", return_value=(True, 1, [])) as run:self.assertEqual(runner.main(["--scope", "auto"]), 0)- run.assert_called_once_with(("full",), 1)+ run.assert_called_once()+ self.assertEqual(run.call_args.args[:2], (("full",), 1))def test_same_state_only_runs_missing_scopes_and_failed_state_runs_all(self):self.certify(self.repo, ("catalog",))@@ -765,11 +769,13 @@ class VerificationTests(unittest.TestCase):mock.patch.object(runner, "resolve_auto_scope", return_value=(("catalog", "web"), "fixture")), \mock.patch.object(runner, "run_local_suite", return_value=(True, 1, [])) as run:self.assertEqual(runner.main(["--scope", "auto"]), 0)- run.assert_called_once_with(("web",), 1)+ run.assert_called_once()+ self.assertEqual(run.call_args.args[:2], (("web",), 1))run.reset_mock()self.certify(self.repo, ("full",), success=False)self.assertEqual(runner.main(["--scope", "auto"]), 0)- run.assert_called_once_with(("catalog", "web"), 1)+ run.assert_called_once()+ self.assertEqual(run.call_args.args[:2], (("catalog", "web"), 1))def test_partial_baseline_requires_live_timestamps_and_matching_environment(self):original = self.certify(self.repo, ("catalog",))@@ -792,7 +798,8 @@ class VerificationTests(unittest.TestCase):mock.patch.object(runner, "resolve_auto_scope", return_value=(("catalog", "metadata", "web"), "fixture")), \mock.patch.object(runner, "run_local_suite", return_value=(True, 1, [])) as run:self.assertEqual(runner.main(["--scope", "auto"]), 0)- run.assert_called_once_with(("web",), 1)+ run.assert_called_once()+ self.assertEqual(run.call_args.args[:2], (("web",), 1))self.assertEqual(evidence.read(self.repo, state)["validated"]["catalog"], stamps["catalog"])def test_success_of_another_domain_cannot_restore_a_failed_domain_from_an_older_baseline(self):@@ -808,7 +815,8 @@ class VerificationTests(unittest.TestCase):mock.patch.object(runner, "resolve_auto_scope", return_value=(("checks", "catalog", "web"), "fixture")), \mock.patch.object(runner, "run_local_suite", return_value=(True, 1, [])) as run:self.assertEqual(runner.main(["--scope", "auto"]), 0)- run.assert_called_once_with(("web",), 1)+ run.assert_called_once()+ self.assertEqual(run.call_args.args[:2], (("web",), 1))def test_focus_never_publishes_evidence_and_formal_run_rejects_focus_environment(self):selector = self.repo / "tests/test_focus_sample.py"