Skip to content

Commit

Permalink
_project.py: fix the case where a simple string is passed to host-files
Browse files Browse the repository at this point in the history
also add a test
  • Loading branch information
abderrahim committed Feb 17, 2020
1 parent f126f0a commit fb91adc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/buildstream/_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ def _load_second_pass(self):
host_files = shell_options.get_sequence("host-files", default=[])
for host_file in host_files:
if isinstance(host_file, ScalarNode):
mount = HostMount(host_file)
mount = HostMount(host_file.as_str())
else:
# Some validation
host_file.validate_keys(["path", "host_path", "optional"])
Expand Down
11 changes: 7 additions & 4 deletions tests/integration/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_no_shell(cli, datafiles):


# Test that bind mounts defined in project.conf work
@pytest.mark.parametrize("path", [("/etc/pony.conf"), ("/usr/share/pony/pony.txt")])
@pytest.mark.parametrize("path", [("/etc/pony.conf"), ("/usr/share/pony/pony.txt"), (None)])
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
@pytest.mark.xfail(
Expand All @@ -169,9 +169,12 @@ def test_no_shell(cli, datafiles):
def test_host_files(cli, datafiles, path):
project = str(datafiles)
ponyfile = os.path.join(project, "files", "shell-mount", "pony.txt")
result = execute_shell(
cli, project, ["cat", path], config={"shell": {"host-files": [{"host_path": ponyfile, "path": path}]}}
)
if path is None:
result = execute_shell(cli, project, ["cat", ponyfile], config={"shell": {"host-files": [ponyfile]}})
else:
result = execute_shell(
cli, project, ["cat", path], config={"shell": {"host-files": [{"host_path": ponyfile, "path": path}]}}
)
assert result.exit_code == 0
assert result.output == "pony\n"

Expand Down

0 comments on commit fb91adc

Please sign in to comment.