Skip to content

Commit 3330545

Browse files
committed
style(comments): state present-tense fixture and test requirements
A 16 000-declaration file took seconds where git diff --numstat takes none; 16x declarations must cost ~16x time, not 256x. The quadratic sibling rescan measured well above 30x; the linear walk sits below it. A staged pure rename and an added empty file must not render as "mode 644->644" or "?->644".
1 parent 0e3b486 commit 3330545

4 files changed

Lines changed: 13 additions & 20 deletions

File tree

‎internal/diff/attribute_test.go‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,10 @@ func TestNarrowMultiDeclarator(t *testing.T) {
148148
}
149149

150150
// TestAttributeSymbols_ScalesLinearlyInDeclarations guards the shape of the
151-
// containment work, not an absolute duration: exclusiveText and the
152-
// nested-region test both used to rescan every sibling region for every
153-
// region, which is quadratic in declaration count. A generated file of
154-
// 16 000 declarations took seconds where `git diff --numstat` takes none.
155-
// Region nesting is now resolved once (buildRegionTree), so 16x the
156-
// declarations costs about 16x the time rather than 256x.
157-
//
158-
// The bound is deliberately loose -- a ratio, with the minimum of several
159-
// runs, so a loaded machine inflating both measurements cancels out. The old
160-
// quadratic code measured well above 30x here; the linear walk comfortably
161-
// below it.
151+
// containment work, not an absolute duration: a per-region sibling rescan
152+
// is quadratic in declaration count, so region nesting is resolved once
153+
// (buildRegionTree). The bound is a ratio, taking the minimum of several
154+
// runs, so a loaded machine inflating both measurements cancels out.
162155
func TestAttributeSymbols_ScalesLinearlyInDeclarations(t *testing.T) {
163156
t.Parallel()
164157
lang, ok := resolve.ForExtension(".go")

‎internal/diff/run_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,10 +1143,10 @@ func TestRun_StagedRenameAcrossDirectoryDepth(t *testing.T) {
11431143

11441144
// TestRun_ZeroCountChangeIsNotAModeRow pins the classification of a change
11451145
// git reports with 0 added / 0 deleted that is not a mode edit: a staged pure
1146-
// rename and an added empty file both used to render as "mode 644->644" (and
1147-
// "?->644" for the empty addition), with no row naming the move at all. Only
1148-
// a genuine mode disagreement is a MODE row; everything else keeps a row of
1149-
// its own at the path git lists it under.
1146+
// rename and an added empty file keep a named row, never "mode 644->644"
1147+
// (or "?->644" for the empty addition). Only a genuine mode disagreement is a
1148+
// MODE row; everything else keeps a row of its own at the path git lists it
1149+
// under.
11501150
func TestRun_ZeroCountChangeIsNotAModeRow(t *testing.T) {
11511151
t.Parallel()
11521152

‎internal/gittest/gittest.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var (
4141
)
4242

4343
// fixtureTemplate is a git template directory carrying the two things every
44-
// fixture repository needs, which used to cost four `git config`
44+
// fixture repository needs, so New does not pay four `git config`
4545
// subprocesses per repository:
4646
//
4747
// - user.name/user.email, so a repository created off it can commit

‎internal/gittest/gittest_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ func readCount(t *testing.T, countFile string) int64 {
4141
}
4242

4343
// TestNewCostsOneGitProcess pins the fixture's own cost: a repository built
44-
// by New must come from the template in a single `git init`, not from the
45-
// four `git config` invocations it used to take to write the same settings
46-
// afterwards. Those four were the largest single block of subprocesses in
47-
// the unit lane, so a regression here is a slow suite, not a failing one.
44+
// by New must come from the template in a single `git init`, not from four
45+
// `git config` invocations afterwards. Those four would be the largest
46+
// single block of subprocesses in the unit lane, so a regression here is a
47+
// slow suite, not a failing one.
4848
func TestNewCostsOneGitProcess(t *testing.T) {
4949
bin, countFile := countingGit(t)
5050
t.Setenv("PATH", bin)

0 commit comments

Comments
 (0)