calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject [3/6] calcite git commit: [CALCITE-2070] Git test fails when run from source distro
Date Wed, 06 Dec 2017 06:03:33 GMT
[CALCITE-2070] Git test fails when run from source distro


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/d1166490
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/d1166490
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/d1166490

Branch: refs/heads/branch-1.15
Commit: d11664905f8b6875196aa6ab25d6b3b314492cbf
Parents: 3763abf
Author: Julian Hyde <jhyde@apache.org>
Authored: Fri Dec 1 18:03:30 2017 -0800
Committer: Julian Hyde <jhyde@apache.org>
Committed: Fri Dec 1 18:05:17 2017 -0800

----------------------------------------------------------------------
 .../apache/calcite/adapter/os/Processes.java    |  2 +-
 .../calcite/adapter/os/OsAdapterTest.java       | 27 ++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/d1166490/plus/src/main/java/org/apache/calcite/adapter/os/Processes.java
----------------------------------------------------------------------
diff --git a/plus/src/main/java/org/apache/calcite/adapter/os/Processes.java b/plus/src/main/java/org/apache/calcite/adapter/os/Processes.java
index 6742195..8caa7c3 100644
--- a/plus/src/main/java/org/apache/calcite/adapter/os/Processes.java
+++ b/plus/src/main/java/org/apache/calcite/adapter/os/Processes.java
@@ -34,7 +34,7 @@ import java.util.Arrays;
  * Utilities regarding operating system processes.
  *
  * <p>WARNING: Spawning processes is not secure.
- * Use this class caution.
+ * Use this class with caution.
  * This class is in the "plus" module because "plus" is not used by default.
  * Do not move this class to the "core" module.
  */

http://git-wip-us.apache.org/repos/asf/calcite/blob/d1166490/plus/src/test/java/org/apache/calcite/adapter/os/OsAdapterTest.java
----------------------------------------------------------------------
diff --git a/plus/src/test/java/org/apache/calcite/adapter/os/OsAdapterTest.java b/plus/src/test/java/org/apache/calcite/adapter/os/OsAdapterTest.java
index c1cd78e..c82d470 100644
--- a/plus/src/test/java/org/apache/calcite/adapter/os/OsAdapterTest.java
+++ b/plus/src/test/java/org/apache/calcite/adapter/os/OsAdapterTest.java
@@ -31,6 +31,8 @@ import org.junit.Assume;
 import org.junit.Test;
 
 import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FilenameFilter;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
@@ -64,6 +66,29 @@ public class OsAdapterTest {
     return System.getProperty("os.name").startsWith("Windows");
   }
 
+  /** Returns whether there is a ".git" directory in this directory or in a
+   * directory between this directory and root. */
+  private static boolean hasGit() {
+    final String path = OsAdapterTest.class.getResource("/").getPath();
+    File f = new File(path);
+    for (;;) {
+      if (f == null || !f.exists()) {
+        return false; // abandon hope
+      }
+      File[] files =
+          f.listFiles(
+              new FilenameFilter() {
+                public boolean accept(File dir, String name) {
+                  return name.equals(".git");
+                }
+              });
+      if (files != null && files.length == 1) {
+        return true; // there is a ".git" subdirectory
+      }
+      f = f.getParentFile();
+    }
+  }
+
   @Test public void testDu() {
     sql("select * from du")
         .returns(
@@ -155,6 +180,7 @@ public class OsAdapterTest {
   }
 
   @Test public void testGitCommits() {
+    Assume.assumeTrue("no git", hasGit());
     sql("select count(*) from git_commits")
         .returns(
             new Function<ResultSet, Void>() {
@@ -172,6 +198,7 @@ public class OsAdapterTest {
   }
 
   @Test public void testGitCommitsTop() {
+    Assume.assumeTrue("no git", hasGit());
     final String q = "select author from git_commits\n"
         + "group by 1 order by count(*) desc limit 1";
     sql(q).returnsUnordered("author=Julian Hyde <julianhyde@gmail.com>");


Mime
View raw message