Skip to content

Commit

Permalink
Add full string to version
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jan 5, 2017
1 parent 26e4368 commit 6990b32
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
/**
* Cmake functionality bound to a particular Cmake install path.
*/
public class CmakeX {
public class Cmake {
final private static String CMAKE_VERSION_LINE_PREFIX = "cmake version ";
final private File cmakeInstallPath;
final private Map<String, String> cmakeProcessEnvironment;

public CmakeX(File cmakeInstallPath) {
public Cmake(File cmakeInstallPath) {
this.cmakeInstallPath = cmakeInstallPath;
this.cmakeProcessEnvironment = new ProcessBuilder().environment();
}
Expand Down Expand Up @@ -98,13 +98,13 @@ public String getVersionString() throws IOException {
/**
* Get the current Cmake version as a structure
*/
public CmakeVersionX getVersion() throws IOException {
public CmakeVersion getVersion() throws IOException {
String string = getVersionString();
String[] parts = string.split("\\.");
if (parts[2].contains("-")) {
// There is a tag, as in 3.6.0-rc2
String[] subparts = parts[2].split("-");
return new CmakeVersionX(
return new CmakeVersion(
string,
Integer.parseInt(parts[0]),
Integer.parseInt(parts[1]),
Expand All @@ -113,7 +113,7 @@ public CmakeVersionX getVersion() throws IOException {
}

// There's no tag
return new CmakeVersionX(
return new CmakeVersion(
string,
Integer.parseInt(parts[0]),
Integer.parseInt(parts[1]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
/**
* A Cmake release version
*/
public class CmakeVersionX {
public class CmakeVersion {
final public String full;
final public int major;
final public int minor;
final public int point;
final public String tag;

CmakeVersionX(String full, int major, int minor, int point, String tag) {
CmakeVersion(String full, int major, int minor, int point, String tag) {
this.full = full;
this.major = major;
this.minor = minor;
Expand Down
22 changes: 11 additions & 11 deletions src/test/java/com/jomofisher/tests/cmake/TestCMakeServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import com.google.common.base.Charsets;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.jomofisher.cmake.CmakeVersionX;
import com.jomofisher.cmake.CmakeX;
import com.jomofisher.cmake.Cmake;
import com.jomofisher.cmake.CmakeVersion;
import com.jomofisher.cmake.database.Compilation;
import com.jomofisher.cmake.serverv1.*;
import com.jomofisher.literatehash.LiterateHash;
Expand Down Expand Up @@ -125,8 +125,8 @@ private File getNinjaInstallFolder() {
}
}

private CmakeX getCMake() {
return new CmakeX(getCMakeInstallFolder());
private Cmake getCMake() {
return new Cmake(getCMakeInstallFolder());
}

private ServerConnectionBuilder getConnectionBuilder() {
Expand All @@ -146,7 +146,7 @@ private void setUpCmakeEnvironment(Map<String, String> environment) {
}
}

private ServerConnectionBuilder getConnectionBuilder(CmakeX cmake) {
private ServerConnectionBuilder getConnectionBuilder(Cmake cmake) {
setUpCmakeEnvironment(cmake.environment());

return cmake.newServerBuilder()
Expand Down Expand Up @@ -251,7 +251,7 @@ public void testConfigure() throws Exception {

@Test
public void testCompilationDatabase() throws Exception {
CmakeX cmake = new CmakeX(getCMakeInstallFolder());
Cmake cmake = new Cmake(getCMakeInstallFolder());
ServerConnection connection = getConnectionBuilder(cmake).create();
HandshakeRequest handshake = getHelloWorldHandshake();
connection.handshake(handshake);
Expand Down Expand Up @@ -377,10 +377,10 @@ public void testAndroidStudioCMakeVersion() throws Exception {
if ("1".equals(System.getenv().get("NO_ANDROID_STUDIO_CMAKE_ON_THIS_OS"))) {
return;
}
CmakeX cmake = new CmakeX(getAndroidStudioCMakeExecutable().getParentFile());
Cmake cmake = new Cmake(getAndroidStudioCMakeExecutable().getParentFile());
String version = cmake.getVersionString();
assertThat(version).isEqualTo("3.6.0-rc2");
CmakeVersionX cmakeVersion = cmake.getVersion();
CmakeVersion cmakeVersion = cmake.getVersion();
assertThat(cmakeVersion.full).isEqualTo("3.6.0-rc2");
assertThat(cmakeVersion.major).isEqualTo(3);
assertThat(cmakeVersion.minor).isEqualTo(6);
Expand All @@ -390,8 +390,8 @@ public void testAndroidStudioCMakeVersion() throws Exception {

@Test
public void testCMakeVersion() throws Exception {
CmakeX cmake = new CmakeX(getCMakeInstallFolder());
CmakeVersionX cmakeVersion = cmake.getVersion();
Cmake cmake = new Cmake(getCMakeInstallFolder());
CmakeVersion cmakeVersion = cmake.getVersion();
assertThat(cmakeVersion.major).isEqualTo(3);
}

Expand Down Expand Up @@ -573,7 +573,7 @@ public void testExample() throws Exception {
//noinspection ConstantConditions
if (false) { // Just make sure it compiles
// Usage example
ServerConnection connection = new CmakeX(getCMakeInstallFolder())
ServerConnection connection = new Cmake(getCMakeInstallFolder())
.newServerBuilder()
.create();
HandshakeRequest message = new HandshakeRequest();
Expand Down

0 comments on commit 6990b32

Please sign in to comment.