the ci has always had a 'mvn test' step, but there was nothing to test. add junit 6 and pin surefire 3.6.0, extract the os detection into a testable fromOsName method, and cover the movement step math - including the axis-aligned cases that used to produce infinite steps and never converge.
31 lines
893 B
Java
31 lines
893 B
Java
package wtf.beatrice.autosqueal.util;
|
|
|
|
import java.util.Locale;
|
|
|
|
public class SystemUtil
|
|
{
|
|
|
|
public static OperatingSystem getHostSystem() {
|
|
return fromOsName(System.getProperty("os.name"));
|
|
}
|
|
|
|
public static OperatingSystem fromOsName(String osName) {
|
|
String normalizedOsName = osName.toLowerCase(Locale.ENGLISH);
|
|
if (normalizedOsName.contains("win")) {
|
|
return OperatingSystem.WINDOWS;
|
|
} else if (normalizedOsName.contains("nix") ||
|
|
normalizedOsName.contains("nux") ||
|
|
normalizedOsName.contains("aix")) {
|
|
return OperatingSystem.LINUX;
|
|
} else if (normalizedOsName.contains("mac")) {
|
|
return OperatingSystem.MAC_OS;
|
|
} else {
|
|
return OperatingSystem.UNKNOWN;
|
|
}
|
|
}
|
|
|
|
public enum OperatingSystem {
|
|
WINDOWS, LINUX, MAC_OS, UNKNOWN;
|
|
}
|
|
}
|