gnodet-bot commented on code in PR #13152:
URL: https://github.com/apache/maven/pull/13152#discussion_r4021727948
##########
impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/OperatingSystemProfileActivatorTest.java:
##########
@@ -145,4 +145,16 @@ void testCapitalOsName() {
assertActivation(false, profile, newContext(null,
newProperties("windows", "99", "amd64")));
assertActivation(true, profile, newContext(null, newProperties("Mac OS
X", "14.5", "aarch64")));
}
+
+ @Test
+ void testCapitalFamily() {
+ Profile winnt = newProfile(ActivationOS.newBuilder().family("WinNT"));
+
+ assertActivation(true, winnt, newContext(null, newProperties("windows
11", "10.0", "amd64")));
+ assertActivation(false, winnt, newContext(null, newProperties("linux",
"6.5.0-1014-aws", "amd64")));
+
+ Profile mac = newProfile(ActivationOS.newBuilder().family("Mac"));
+
Review Comment:
**Missing negation test for capitalised family.**
The negation path (`!WinNT`) is untested. Before this fix,
`determineFamilyMatch("!WinNT", ...)` would check `"!WinNT".startsWith("!")` →
true, strip to `"WinNT"`, then call `Os.isFamily("WinNT", ...)` → hits the
`default` branch (substring test on lowercased form) rather than the `case
FAMILY_NT` switch arm — so the *result* was wrong, and the negation then
inverts the wrong result. The fix resolves this, but there is no test to pin it.
Suggest extending `testCapitalFamily` with a negated assertion:
```suggestion
assertActivation(true, winnt, newContext(null,
newProperties("windows 11", "10.0", "amd64")));
assertActivation(false, winnt, newContext(null,
newProperties("linux", "6.5.0-1014-aws", "amd64")));
Profile notWinnt =
newProfile(ActivationOS.newBuilder().family("!WinNT"));
assertActivation(false, notWinnt, newContext(null,
newProperties("windows 11", "10.0", "amd64")));
assertActivation(true, notWinnt, newContext(null,
newProperties("linux", "6.5.0-1014-aws", "amd64")));
Profile mac = newProfile(ActivationOS.newBuilder().family("Mac"));
assertActivation(true, mac, newContext(null, newProperties("darwin",
"24.6.0", "aarch64")));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]