You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/01/24 15:05:16 UTC

[GitHub] [arrow-cookbook] amol- commented on a change in pull request #131: [Java]: WIP - Java cookbook for create arrow object

amol- commented on a change in pull request #131:
URL: https://github.com/apache/arrow-cookbook/pull/131#discussion_r790832656



##########
File path: java/ext/javadoctest.py
##########
@@ -0,0 +1,92 @@
+import os
+import pathlib
+import subprocess
+
+from sphinx.ext.doctest import (Any, Dict, DocTestBuilder, TestcodeDirective,
+                                TestoutputDirective, doctest, sphinx)
+from sphinx.locale import __
+
+
+class JavaDocTestBuilder(DocTestBuilder):
+    """
+    Runs java test snippets in the documentation.
+    """
+
+    name = "javadoctest"
+    epilog = __(
+        "Java testing of doctests in the sources finished, look at the "
+        "results in %(outdir)s/output.txt."
+    )
+
+    def compile(
+        self, code: str, name: str, type: str, flags: Any, dont_inherit: bool
+    ) -> Any:
+        # go to project that contains all your arrow maven dependencies
+        path_arrow_project = os.path.join(pathlib.Path.cwd(), "source", "demo")
+
+        # create list of all arrow jar dependencies
+        subprocess.check_call(
+            [
+                "mvn",
+                "-q",
+                "dependency:build-classpath",
+                "-DincludeTypes=jar",
+                "-Dmdep.outputFile=.cp.tmp",
+            ],
+            cwd=path_arrow_project,
+            text=True,
+        )
+        if not os.path.exists(path_arrow_project + "/.cp.tmp"):
+            raise RuntimeError(
+                __("invalid process to create jshell dependencies library")
+            )
+
+        # get list of all arrow jar dependencies
+        with open(os.path.join(path_arrow_project, ".cp.tmp")) as f:
+            stdout_dependency = f.read()
+        if not stdout_dependency:
+            raise RuntimeError(
+                __("invalid process to list jshell dependencies library")
+            )
+
+        # execute java testing code thru jshell and read output
+        proc_jshell_process = subprocess.Popen(
+            ["jshell", "--class-path", stdout_dependency, "-"],

Review comment:
       Should we start `jshell` with `-s` so that messages don't get in the way of the output we want to test?




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org