Allow lit test timeout value to be configurable

Patch by Omar Habra!

Differential Revision: https://reviews.llvm.org/D85173
diff --git a/test/jenkins/test_monorepo_build.py b/test/jenkins/test_monorepo_build.py
index b14367a..3fb7d8e 100644
--- a/test/jenkins/test_monorepo_build.py
+++ b/test/jenkins/test_monorepo_build.py
@@ -137,3 +137,13 @@
 # Test long should always do check-all, since that is what many bots expect.
 # RUN: python %{src_root}/zorg/jenkins/monorepo_build.py cmake testlong  | FileCheck --check-prefix CHECK-TTARGETS2 %s
 # CHECK-TTARGETS2: '/usr/local/bin/ninja' '-v' '-k' '0' 'check-all'
+
+# Test to check if timeout flag is actually being set.
+# RUN: python %{src_root}/zorg/jenkins/monorepo_build.py cmake all --timeout=900 > %t-timeout.log
+# RUN: FileCheck --check-prefix CHECK-TIMEOUT < %t-timeout.log %s
+# CHECK-TIMEOUT: --timeout=900
+
+# Test to check if default timeout is being set to 600.
+# RUN: python %{src_root}/zorg/jenkins/monorepo_build.py cmake all > %t-timeout-default.log
+# RUN: FileCheck --check-prefix CHECK-TIMEOUT-DEFAULT < %t-timeout-default.log %s
+# CHECK-TIMEOUT-DEFAULT: --timeout=600
\ No newline at end of file
diff --git a/zorg/jenkins/monorepo_build.py b/zorg/jenkins/monorepo_build.py
index 6b2b390..a9efe8a 100644
--- a/zorg/jenkins/monorepo_build.py
+++ b/zorg/jenkins/monorepo_build.py
@@ -28,7 +28,6 @@
 import dep  # noqa
 
 
-
 def readme_name(repo):
     """Given a repo, return the name of the readme file."""
     if repo == "libcxx":
@@ -308,7 +307,8 @@
         cmake_cmd += ['-DCMAKE_C_COMPILER_LAUNCHER=' + conf.sccache_path]
         cmake_cmd += ['-DCMAKE_CXX_COMPILER_LAUNCHER=' + conf.sccache_path]
 
-    lit_flags = ['--xunit-xml-output=testresults.xunit.xml', '-v', '-vv', '--timeout=600']
+    timeout_flag = '--timeout=' + str(conf.timeout)
+    lit_flags = ['--xunit-xml-output=testresults.xunit.xml', '-v', '-vv', timeout_flag]
     if conf.max_parallel_tests:
         lit_flags += ['-j', conf.max_parallel_tests]
     cmake_cmd += ['-DLLVM_LIT_ARGS={}'.format(' '.join(lit_flags))]
@@ -448,7 +448,9 @@
                 cmake_command.extend(['-DCMAKE_C_COMPILER=' + conf.CC(),
                                       '-DCMAKE_CXX_COMPILER=' + conf.CC() + "++"])
 
-            lit_flags = ['--xunit-xml-output=testresults.xunit.xml', '-v', '-vv', '--timeout=600']
+            timeout_flag = '--timeout=' + str(conf.timeout)
+            lit_flags = ['--xunit-xml-output=testresults.xunit.xml', '-v', '-vv', timeout_flag]
+
             if conf.max_parallel_tests:
                 lit_flags += ['-j', conf.max_parallel_tests]
             cmake_command.extend(
@@ -591,7 +593,6 @@
             '-DCMAKE_CXX_COMPILER=' + conf.CC() + "++"
         ])
 
-
     header("Clean")
     delete_module_caches(conf.workspace)
     footer()
@@ -1038,7 +1039,8 @@
     parser.add_argument('--projects', dest='llvm_enable_projects',
                         default="clang;clang-tools-extra;compiler-rt;libcxx",
                         help="Semicolon seperated list of projects to build.")
-
+    parser.add_argument('--timeout', dest='timeout', type=int, default='600',
+                        help='Individual test timeout in seconds.')
     args = parser.parse_args()
     if args.thinlto:
         args.lto = True