androidx_incremental.sh passing timeout into diff-filterer.py

So that we know how long it can run even in the case of a difficult task to solve

Bug: 187822154
Change-Id: Ic18a1ddfbbba3be7f93f6b18cd482f4ab0c9f7bb
diff --git a/development/diagnose-build-failure/diagnose-build-failure.sh b/development/diagnose-build-failure/diagnose-build-failure.sh
index a6d2279..e0b1f88 100755
--- a/development/diagnose-build-failure/diagnose-build-failure.sh
+++ b/development/diagnose-build-failure/diagnose-build-failure.sh
@@ -8,7 +8,7 @@
   echo "  diagnose-build-failure.sh"
   echo
   echo "SYNOPSIS"
-  echo "  ./development/diagnose-build-failure/diagnose-build-failure.sh [--message <message>] '<tasks>'"
+  echo "  ./development/diagnose-build-failure/diagnose-build-failure.sh [--message <message>] [--timeout <seconds> ] '<tasks>'"
   echo
   echo "DESCRIPTION"
   echo "  Attempts to identify why "'`'"./gradlew <tasks>"'`'" fails"
@@ -34,6 +34,7 @@
 }
 
 expectedMessage=""
+timeoutSeconds=""
 while true; do
   if [ "$#" -lt 1 ]; then
     usage
@@ -45,12 +46,23 @@
     shift
     continue
   fi
+  if [ "$arg" == "--timeout" ]; then
+    timeoutSeconds="$1"
+    shift
+    continue
+  fi
+
   gradleArgs="$arg"
   break
 done
 if [ "$gradleArgs" == "" ]; then
   usage
 fi
+if [ "$timeoutSeconds" == "" ]; then
+  timeoutArg=""
+else
+  timeoutArg="--timeout $timeoutSeconds"
+fi
 # split Gradle arguments into options and tasks
 gradleOptions=""
 gradleTasks=""
@@ -307,7 +319,7 @@
   # command for moving state, running build, and moving state back
   fullFiltererCommand="$(getTestStateCommand --invert $buildCommand)"
 
-  if $supportRoot/development/file-utils/diff-filterer.py --work-path "$tempDir" "$requiredTasksWork" "$tempDir/prev"  "$fullFiltererCommand"; then
+  if $supportRoot/development/file-utils/diff-filterer.py $timeoutArg --work-path "$tempDir" "$requiredTasksWork" "$tempDir/prev"  "$fullFiltererCommand"; then
     echo diff-filterer successfully identified a minimal set of required tasks. Saving into $requiredTasksDir
     cp -r "$tempDir/bestResults/tasks" "$requiredTasksDir"
   else
@@ -331,7 +343,7 @@
 # command for moving state, running build, and moving state back
 fullFiltererCommand="$(getTestStateCommand $buildCommand)"
 
-if $supportRoot/development/file-utils/diff-filterer.py --assume-input-states-are-correct --work-path $tempDir $successState $tempDir/prev "$fullFiltererCommand"; then
+if $supportRoot/development/file-utils/diff-filterer.py $timeoutArg --assume-input-states-are-correct --work-path $tempDir $successState $tempDir/prev "$fullFiltererCommand"; then
   echo
   echo "There should be something wrong with the above file state"
   echo "Hopefully the output from diff-filterer.py above is enough information for you to figure out what is wrong"