Skip to content

Commit 9a21b8d

Browse files
committed
relink.py: process_args(): Check that everything is an abs path.
1 parent bef9ee2 commit 9a21b8d

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

relink.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,14 @@ def process_args(args):
421421
if hasattr(args, "items_to_process") and not isinstance(args.items_to_process, list):
422422
args.items_to_process = [args.items_to_process]
423423

424+
# Check that everything is an absolute path (should have been converted, if needed, during
425+
# validate_paths).
426+
if hasattr(args, "items_to_process"):
427+
for item in args.items_to_process:
428+
assert os.path.isabs(item)
429+
if hasattr(args, "target_root"):
430+
assert os.path.isabs(args.target_root)
431+
424432
# Check that every item in items_to_process is a child of inputdata_root
425433
if hasattr(args, "items_to_process"): # Sometimes doesn't if we're testing
426434
for item in args.items_to_process:

tests/relink/test_args.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,16 @@ def test_error_if_source_not_in_inputdata(self):
371371
args = argparse.Namespace(
372372
quiet=False,
373373
verbose=False,
374-
items_to_process="abc123",
375-
inputdata_root="def456",
374+
items_to_process=os.path.abspath("abc123"),
375+
inputdata_root=os.path.abspath("def456"),
376376
)
377377
with pytest.raises(argparse.ArgumentTypeError) as exc_info:
378378
relink.process_args(args)
379379
assert "not under inputdata root" in str(exc_info.value)
380380

381381
def test_error_if_target_in_inputdata(self):
382382
"""Test that process_args errors if target is in inputdata_root."""
383-
inputdata_root = "inputdata"
383+
inputdata_root = os.path.abspath("inputdata")
384384
target_root = os.path.join(inputdata_root, "abc123")
385385
args = argparse.Namespace(
386386
quiet=False,

0 commit comments

Comments
 (0)