build-and-test: Add required --repos-dir flag

This is necessary so we can add subprojects to our source config. It
assumes that each subproject has a repo directly under the repos-dir.

Since we now have a path to *all* the repos, we can use that to get the
test-suite and LNT repos as well, instead of specifying each of them
manually. This simplifies the interface a bit (we get rid of the
parameters for passing the paths to the test-suite and LNT repo, and
instead add a single parameter for enabling the test-suite).

Change-Id: I818952969aa9335720965af7273fa8273223a64e
diff --git a/scripts/llvm.py b/scripts/llvm.py
index b8362ec..6184bca 100644
--- a/scripts/llvm.py
+++ b/scripts/llvm.py
@@ -173,13 +173,14 @@
     proj = Proj()
 
     dryRun = args.dry
+    llvmRepos = args.repos
     llvmWorktreeRoot = args.sources
 
     stage1BuildDir = args.stage1
     stage2BuildDir = args.stage2
-    testSuiteDir = args.test_suite
+
+    enableTestSuite = args.enableTestSuite
     sandboxDir = args.sandbox
-    lntDir = args.lnt
 
     if dryRun:
         consumer = CommandPrinter()
@@ -214,7 +215,10 @@
             buildConfig2.build()
             testedBuildDir = stage2BuildDir
 
-        if testSuiteDir is not None:
+        if enableTestSuite:
+            testSuiteDir = os.path.join(llvmRepos, "test-suite")
+            lntDir = os.path.join(llvmRepos, "lnt")
+
             setup_test_suite(consumer, sandboxDir, lntDir)
 
             # TODO: Make sure clang is actually built in this config (preferably
@@ -432,6 +436,12 @@
          "used for other purposes as well.")
 buildAndTest.set_defaults(run_command=build_and_test)
 buildAndTest.add_argument(
+    '--repos-dir',
+    dest='repos',
+    required=True,
+    help="Path to the root directory containing the repositories for LLVM and "
+         "the other subprojects.")
+buildAndTest.add_argument(
     '--source-dir',
     dest='sources',
     required=True,
@@ -447,15 +457,15 @@
     dest='stage2',
     help="Path to the build directory for stage 2.")
 buildAndTest.add_argument(
-    "--test-suite",
-    help="Path to the test-suite repo.")
+    "--enable-test-suite",
+    dest='enableTestSuite',
+    action='store_true',
+    default=False,
+    help="Whether or not to run the test-suite with the last compiler built.")
 buildAndTest.add_argument(
     "--sandbox",
     help="Path to the sandbox where the test-suite should be setup.")
 buildAndTest.add_argument(
-    "--lnt",
-    help="Path to the LNT repo.")
-buildAndTest.add_argument(
     '-n', '--dry-run',
     dest='dry',
     action='store_true',
diff --git a/tests/cli/testbuildandtest.py b/tests/cli/testbuildandtest.py
index 948fe3a..a60f7e2 100644
--- a/tests/cli/testbuildandtest.py
+++ b/tests/cli/testbuildandtest.py
@@ -19,12 +19,14 @@
         """
         Test that we dump the correct commands for a single stage build of LLVM.
         """
+        reposDir = "path-to-repos"
         sourceDir = "path-to-sources"
         buildDir = "path-to-stage1"
 
         output = self.run_with_output(
             self.llvm_build_and_test(
                 "--dry-run",
+                "--repos-dir", reposDir,
                 "--source-dir", sourceDir,
                 "--stage1-build-dir", buildDir))
 
@@ -42,20 +44,22 @@
         Test that we dump the correct commands for a single stage build of LLVM
         and a run of the test-suite with the resulting compiler.
         """
+        reposDir = "path-to-repos"
         sourceDir = "path-to-sources"
         buildDir = "path-to-stage1"
-        testSuiteDir = "path-to-test-suite"
         sandboxDir = "path-to-sandbox"
-        lntDir = "path-to-lnt"
+
+        testSuiteDir = os.path.join(reposDir, "test-suite")
+        lntDir = os.path.join(reposDir, "lnt")
 
         output = self.run_with_output(
             self.llvm_build_and_test(
                 "--dry-run",
+                "--repos-dir", reposDir,
                 "--source-dir", sourceDir,
                 "--stage1-build-dir", buildDir,
-                "--test-suite", testSuiteDir,
-                "--sandbox", sandboxDir,
-                "--lnt", lntDir))
+                "--enable-test-suite",
+                "--sandbox", sandboxDir))
 
         commands = output.splitlines()
 
@@ -86,6 +90,7 @@
         """
         Test that we dump the correct commands for a 2-stage build of LLVM.
         """
+        reposDir = "path-to-repos"
         sourceDir = "path-to-sources"
         buildDir1 = "path-to-stage1"
         buildDir2 = "path-to-stage2"
@@ -93,6 +98,7 @@
         output = self.run_with_output(
             self.llvm_build_and_test(
                 "--dry-run",
+                "--repos-dir", reposDir,
                 "--source-dir", sourceDir,
                 "--stage1-build-dir", buildDir1,
                 "--stage2-build-dir", buildDir2))
@@ -123,22 +129,24 @@
         Test that we dump the correct commands for a 2-stage build of LLVM and a
         run of the test-suite with the resulting compiler.
         """
+        reposDir = "path-to-repos"
         sourceDir = "path-to-sources"
         buildDir1 = "path-to-stage1"
         buildDir2 = "path-to-stage2"
-        testSuiteDir = "path-to-test-suite"
         sandboxDir = "path-to-sandbox"
-        lntDir = "path-to-lnt"
+
+        testSuiteDir = os.path.join(reposDir, "test-suite")
+        lntDir = os.path.join(reposDir, "lnt")
 
         output = self.run_with_output(
             self.llvm_build_and_test(
                 "--dry-run",
+                "--repos-dir", reposDir,
                 "--source-dir", sourceDir,
                 "--stage1-build-dir", buildDir1,
                 "--stage2-build-dir", buildDir2,
-                "--test-suite", testSuiteDir,
-                "--sandbox", sandboxDir,
-                "--lnt", lntDir))
+                "--enable-test-suite",
+                "--sandbox", sandboxDir))
 
         commands = output.splitlines()