uros-b commented on code in PR #55817:
URL: https://github.com/apache/spark/pull/55817#discussion_r3492818995


##########
python/pyspark/tests/test_util.py:
##########
@@ -89,6 +91,26 @@ def test_find_spark_home(self):
         finally:
             os.environ["SPARK_HOME"] = origin
 
+    @unittest.skipIf(sys.platform == "win32", "find-spark-home is a bash 
script")
+    def test_find_spark_home_script_sourceable(self):
+        # SPARK-54434: bin/find-spark-home is documented to be sourced.
+        # When `SPARK_HOME` is already set, the script short-circuits.
+        # The short-circuit must use `return 0` rather than `exit 0`, otherwise
+        # sourcing the script terminates the caller's shell session.
+        script_path = os.path.join(os.environ["SPARK_HOME"], "bin", 
"find-spark-home")
+        # Source the script twice and print a marker afterwards. If the script
+        # calls `exit 0` while sourced, the outer shell terminates and the
+        # marker is never emitted.
+        cmd = (
+            f"export SPARK_HOME=/some/value && "
+            f"source {script_path} && "

Review Comment:
   script_path is interpolated unquoted into the bash -c string (source 
{script_path} ...); a SPARK_HOME containing a space would break source. CI 
paths are spaceless, so this is a nit; shlex.quote would harden it.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to