Split metric-bench's main into run_scores and measured, find the checkout from the history, drop an ambiguous shortened path, write places from the repository root, and give item 85 the history's reader
This commit is contained in:
@@ -10,9 +10,9 @@ import unittest
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
||||
|
||||
from metric_bench.bench import auc, bench, co_changed
|
||||
from metric_bench.places import Place, resolved, scoring_runs
|
||||
from metric_bench.python_units import cognitive, python_units, Unit
|
||||
from metric_bench.python_units import cognitive, measured, python_units, Unit
|
||||
from test_loop_claude_black_box import host_env
|
||||
from metric_bench.places import Place, resolved, scoring_runs
|
||||
|
||||
TOOL = pathlib.Path(__file__).resolve().parent / "metric-bench"
|
||||
|
||||
@@ -85,6 +85,9 @@ class Units(unittest.TestCase):
|
||||
"""))
|
||||
self.assertEqual(units, [Unit("a.py", "bump", 0, 3, 1), Unit("a.py", "__init__", 0, 2, 1), Unit("a.py", "grow", 0, 3, 1)])
|
||||
|
||||
def test_measures_python_files_outside_the_tests(self):
|
||||
self.assertEqual([path for path in ["a.py", "bin/test_a.py", "a_test.py", "tests/b.py", "e2e-tests/c.py", "README.md"] if measured(path)], ["a.py", "e2e-tests/c.py"])
|
||||
|
||||
def test_a_source_that_does_not_parse_has_no_units(self):
|
||||
self.assertEqual(python_units("a.py", "def ("), [])
|
||||
|
||||
@@ -121,6 +124,9 @@ class Places(unittest.TestCase):
|
||||
places = [Place("bin/tool/cycle/states.py", "transition"), Place("cycle/run.py", "step"), Place("gone.py", "x")]
|
||||
self.assertEqual(resolved(places, tracked), [Place("bin/tool/cycle/states.py", "transition"), Place("bin/tool/cycle/run.py", "step")])
|
||||
|
||||
def test_drops_a_shortened_path_two_files_match_with_no_place_before_it(self):
|
||||
self.assertEqual(resolved([Place("cycle/run.py", "step")], ["bin/tool/cycle/run.py", "bin/other/cycle/run.py"]), [])
|
||||
|
||||
|
||||
class Bench(unittest.TestCase):
|
||||
def test_auc_is_one_for_a_perfect_ranking_and_counts_a_tie_half(self):
|
||||
@@ -178,5 +184,10 @@ class BlackBox(unittest.TestCase):
|
||||
|
||||
def test_exits_1_naming_a_history_it_cannot_read_and_unknown_arguments(self):
|
||||
top = self.project("")
|
||||
self.assertIn("could not read", self.run_tool(top, "missing.md").stderr)
|
||||
self.assertIn("could not read", self.run_tool(top, str(pathlib.Path(top, "missing.md"))).stderr)
|
||||
self.assertEqual(self.run_tool(top, "--x").returncode, 1)
|
||||
|
||||
def test_reads_the_checkout_that_holds_a_history_named_from_elsewhere(self):
|
||||
top = self.project("# Comprehension history\n\n## 2026-10-08T12:50:49Z, PR #1 at COMMIT\n\nJunior A, hardest first:\n\n- `a.py:1` `hard`\n")
|
||||
ran = self.run_tool(tempfile.gettempdir(), str(pathlib.Path(top, "docs", "comprehension-history.md")))
|
||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||
|
||||
Reference in New Issue
Block a user