Issue #95 - Updated ReporterResourcesTest
authorJeanderson Candido <jeandersonbc@gmail.com>
Thu, 5 Jul 2018 19:59:03 +0000 (16:59 -0300)
committerJeanderson Candido <jeandersonbc@gmail.com>
Thu, 5 Jul 2018 19:59:16 +0000 (16:59 -0300)
build.gradle
src/tests/ReporterResourcesTest.java

index 93714b1d3aefa749a81147a28cc944a55e70ea2c..d105247dc45c3c9f873ae6c64755b118acf44523 100644 (file)
@@ -85,13 +85,9 @@ task generateBuildInfo {
     description = "Generates the build.properties file."
     doLast {
 
-        // Must fail if there are uncommitted changes
-        def status  = "git status --short".execute().text.trim()
-        if (!status.isEmpty()) {
-            throw new GradleException("There are uncomitted changes:\n " + status)
-        }
         Properties info = new Properties()
 
+        def status  = "git status --short".execute().text.trim()
         def revision = "git rev-parse --short HEAD".execute().text.trim()
         def userName = ["git", "log", "-1", "--format=%an <%ae>"].execute().text.trim()
         def date = "git log -1 --format=%ci".execute().text.trim()
index 0e5d3f7ccf240583d1cfd7606767349fea834899..b3662ffcfa33216ac57bbfb85ff4d03034c0cb02 100644 (file)
@@ -34,23 +34,9 @@ public class ReporterResourcesTest extends TestJPF {
   }
 
   @Test
-  public void hashMustMatch() {
+  public void hashMustExist() {
     InputStream stream = jpf.getClass().getResourceAsStream(".version");
-    assertEquals("Should have the same hash", fetchCurrentRevisionFromVCS().trim(), readContentFrom(stream).trim());
-  }
-
-  private String fetchCurrentRevisionFromVCS() {
-    String currentRevision = "";
-    try {
-      Process process = Runtime.getRuntime().exec("git rev-parse HEAD");
-      process.waitFor();
-      InputStream output = process.getInputStream();
-      currentRevision = readContentFrom(output);
-
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-    return currentRevision;
+    assertTrue(".version file should be non-empty", !readContentFrom(stream).trim().isEmpty());
   }
 
   private String readContentFrom(InputStream stream) {