diff --git a/dev/run-tests.py b/dev/run-tests.py
index 9db728d7990227c41e46c80ee6d08cd42bc459d0..8726889cbc777479ad4236715ca99739d7be3cf5 100755
--- a/dev/run-tests.py
+++ b/dev/run-tests.py
@@ -419,8 +419,8 @@ def run_python_tests(test_modules, parallelism):
 
 
 def run_build_tests():
-    # set_title_and_block("Running build tests", "BLOCK_BUILD_TESTS")
-    # run_cmd([os.path.join(SPARK_HOME, "dev", "test-dependencies.sh")])
+    set_title_and_block("Running build tests", "BLOCK_BUILD_TESTS")
+    run_cmd([os.path.join(SPARK_HOME, "dev", "test-dependencies.sh")])
     pass
 
 
diff --git a/dev/test-dependencies.sh b/dev/test-dependencies.sh
index d6a32717f588fff0d46cf98a9f765739b17255d2..424ce6ad7663ce1826d157d18e0db97d8b83941d 100755
--- a/dev/test-dependencies.sh
+++ b/dev/test-dependencies.sh
@@ -42,9 +42,19 @@ HADOOP_PROFILES=(
 # the old version. We need to do this because the `dependency:build-classpath` task needs to
 # resolve Spark's internal submodule dependencies.
 
-# See http://stackoverflow.com/a/3545363 for an explanation of this one-liner:
-OLD_VERSION=$($MVN help:evaluate -Dexpression=project.version|grep -Ev '(^\[|Download\w+:)')
-TEMP_VERSION="spark-$(date +%s | tail -c6)"
+# From http://stackoverflow.com/a/26514030
+set +e
+OLD_VERSION=$($MVN -q \
+    -Dexec.executable="echo" \
+    -Dexec.args='${project.version}' \
+    --non-recursive \
+    org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)
+if [ $? != 0 ]; then
+    echo -e "Error while getting version string from Maven:\n$OLD_VERSION"
+    exit 1
+fi
+set -e
+TEMP_VERSION="spark-$(python -S -c "import random; print(random.randrange(100000, 999999))")"
 
 function reset_version {
   # Delete the temporary POMs that we wrote to the local Maven repo: