Skip to content

Commit 8d74447

Browse files
committed
Finish --build-dir generalize
1 parent 17ed608 commit 8d74447

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lnt/tests/test_suite.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,6 @@ def run_test(self, opts):
193193
if opts.exec_mode and opts.build_dir is None and not opts.exec_interleaved_builds:
194194
self._fatal("--exec requires --build-dir (or use --exec-interleaved-builds)")
195195

196-
if opts.build_dir and not opts.exec_mode and not opts.exec_interleaved_builds:
197-
self._fatal("--build-dir can only be used with --exec or --exec-interleaved-builds")
198-
199196
if opts.exec_interleaved_builds:
200197
# --exec-interleaved-builds implies --exec
201198
opts.exec_mode = True
@@ -216,13 +213,16 @@ def run_test(self, opts):
216213
build_dir)
217214

218215
if opts.build_dir:
219-
# Validate build directory
220216
opts.build_dir = os.path.abspath(opts.build_dir)
221-
if not os.path.exists(opts.build_dir):
222-
self._fatal("--build-dir does not exist: %r" % opts.build_dir)
223-
cmakecache = os.path.join(opts.build_dir, 'CMakeCache.txt')
224-
if not os.path.exists(cmakecache):
225-
self._fatal("--build-dir is not a configured build: %r" % opts.build_dir)
217+
# In exec mode, the build directory must already exist and be configured
218+
if opts.exec_mode or opts.exec_interleaved_builds:
219+
if not os.path.exists(opts.build_dir):
220+
self._fatal("--build-dir does not exist: %r" % opts.build_dir)
221+
cmakecache = os.path.join(opts.build_dir, 'CMakeCache.txt')
222+
if not os.path.exists(cmakecache):
223+
self._fatal("--build-dir is not a configured build: %r" % opts.build_dir)
224+
# In normal/build mode, --build-dir just specifies where to create the build
225+
# (it will be created if it doesn't exist)
226226

227227
if opts.cc is not None:
228228
opts.cc = resolve_command_path(opts.cc)
@@ -319,15 +319,15 @@ def run_test(self, opts):
319319
self.start_time = timestamp()
320320

321321
# Work out where to put our build stuff
322-
if opts.exec_mode and opts.build_dir:
323-
# In exec mode with --build-dir, use the specified build directory
322+
if opts.build_dir:
323+
# User specified an explicit build directory (works in all modes)
324324
basedir = opts.build_dir
325325
elif opts.exec_interleaved_builds:
326326
# For exec-interleaved-builds, each build uses its own directory
327327
# We'll return early from _run_interleaved_builds(), so basedir doesn't matter
328328
basedir = opts.sandbox_path
329329
else:
330-
# Normal mode or build mode: use sandbox/build or sandbox/test-<timestamp>
330+
# Use sandbox/build or sandbox/test-<timestamp>
331331
if opts.timestamp_build:
332332
ts = self.start_time.replace(' ', '_').replace(':', '-')
333333
build_dir_name = "test-%s" % ts
@@ -1364,9 +1364,9 @@ def diagnose(self):
13641364
is_flag=True, default=False)
13651365
@click.option("--build-dir", "build_dir",
13661366
metavar="PATH",
1367-
help="Path to pre-built test directory (used with --exec). "
1368-
"This is the actual build directory (e.g., sandbox/build), "
1369-
"not the sandbox parent directory.",
1367+
help="Specify custom build directory location. With --exec, must point to "
1368+
"an existing configured build. Otherwise, specifies where to create the "
1369+
"build (overriding default sandbox/build).",
13701370
type=click.UNPROCESSED, default=None)
13711371
@click.option("--exec-interleaved-builds", "exec_interleaved_builds",
13721372
metavar="BUILD1,BUILD2,...",

0 commit comments

Comments
 (0)