Skip to content

Commit

Permalink
cmd/go/internal/mvs: test a downgrade where the target explicitly req…
Browse files Browse the repository at this point in the history
…uires itself

Also clean up the test assertions, and add a check for assertions
missing function invocations (there was one).

For #37438

Change-Id: Iafbfeae2c25217eac894181e01480b25b7cffbd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/266859
Trust: Bryan C. Mills <[email protected]>
Run-TryBot: Bryan C. Mills <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Michael Matloob <[email protected]>
  • Loading branch information
Bryan C. Mills committed Nov 5, 2020
1 parent 0c86172 commit 4a33392
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/cmd/go/internal/mvs/mvs.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ func Upgrade(target module.Version, reqs Reqs, upgrade ...module.Version) ([]mod
}

// Downgrade returns a build list for the target module
// in which the given additional modules are downgraded.
// in which the given additional modules are downgraded,
// potentially overriding the requirements of the target.
//
// The versions to be downgraded may be unreachable from reqs.Latest and
// reqs.Previous, but the methods of reqs must otherwise handle such versions
Expand Down
36 changes: 21 additions & 15 deletions src/cmd/go/internal/mvs/mvs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ build A: A B C D2 E2
name: cross1V
A: B2 C D2 E1
B1:
B1:
B2: D1
C: D2
D1: E2
Expand All @@ -63,7 +63,7 @@ build A: A B2 C D2 E2
name: cross1U
A: B1 C
B1:
B1:
B2: D1
C: D2
D1: E2
Expand All @@ -72,7 +72,7 @@ build A: A B1 C D2 E1
upgrade A B2: A B2 C D2 E2
name: cross1R
A: B C
A: B C
B: D2
C: D1
D1: E2
Expand Down Expand Up @@ -165,7 +165,7 @@ M: A1 B1
A1: X1
B1: X2
X1: I1
X2:
X2:
build M: M A1 B1 I1 X2
# Upgrade from B1 to B2 should not drop the transitive dep on D.
Expand Down Expand Up @@ -229,28 +229,31 @@ E1:
F1:
downgrade A F1: A B1 E1
name: down3
A:
name: downcycle
A: A B2
B2: A
B1:
downgrade A B1: A B1
# golang.org/issue/25542.
name: noprev1
A: B4 C2
B2.hidden:
C2:
B2.hidden:
C2:
downgrade A B2.hidden: A B2.hidden C2
name: noprev2
A: B4 C2
B2.hidden:
B1:
C2:
B2.hidden:
B1:
C2:
downgrade A B2.hidden: A B2.hidden C2
name: noprev3
A: B4 C2
B3:
B2.hidden:
C2:
B3:
B2.hidden:
C2:
downgrade A B2.hidden: A B2.hidden C2
# Cycles involving the target.
Expand Down Expand Up @@ -315,7 +318,7 @@ M: A1 B1
A1: X1
B1: X2
X1: I1
X2:
X2:
req M: A1 B1
name: reqnone
Expand All @@ -338,6 +341,9 @@ func Test(t *testing.T) {
for _, fn := range fns {
fn(t)
}
if len(fns) == 0 {
t.Errorf("no functions tested")
}
})
}
}
Expand Down

0 comments on commit 4a33392

Please sign in to comment.