diff --git a/dev/run-tests.py b/dev/run-tests.py
index c78a66f6aa54e9f34d8a3d5782207f6a7290df01..6febbf108900d15f88cdd4ec943000c5d2350928 100755
--- a/dev/run-tests.py
+++ b/dev/run-tests.py
@@ -104,6 +104,8 @@ def determine_modules_to_test(changed_modules):
 
     >>> [x.name for x in determine_modules_to_test([modules.root])]
     ['root']
+    >>> [x.name for x in determine_modules_to_test([modules.build])]
+    ['root']
     >>> [x.name for x in determine_modules_to_test([modules.graphx])]
     ['graphx', 'examples']
     >>> x = [x.name for x in determine_modules_to_test([modules.sql])]
@@ -111,15 +113,13 @@ def determine_modules_to_test(changed_modules):
     ['sql', 'hive', 'mllib', 'examples', 'hive-thriftserver', 'pyspark-sql', 'sparkr',
      'pyspark-mllib', 'pyspark-ml']
     """
-    # If we're going to have to run all of the tests, then we can just short-circuit
-    # and return 'root'. No module depends on root, so if it appears then it will be
-    # in changed_modules.
-    if modules.root in changed_modules:
-        return [modules.root]
     modules_to_test = set()
     for module in changed_modules:
         modules_to_test = modules_to_test.union(determine_modules_to_test(module.dependent_modules))
     modules_to_test = modules_to_test.union(set(changed_modules))
+    # If we need to run all of the tests, then we should short-circuit and return 'root'
+    if modules.root in modules_to_test:
+        return [modules.root]
     return toposort_flatten(
         {m: set(m.dependencies).intersection(modules_to_test) for m in modules_to_test}, sort=True)