Skip to content

scriptelement.py, buildelement.py: Report relative directories as errors - #2212

Open
Thanatos9404 wants to merge 2 commits into
apache:masterfrom
Thanatos9404:thanatos/relative-work-directory
Open

Thanatos9404 wants to merge 2 commits into
apache:masterfrom
Thanatos9404:thanatos/relative-work-directory

Conversation

@Thanatos9404

Copy link
Copy Markdown
Contributor

A script element with a relative cwd, like the cwd: elements in the issue, loads fine and then trips the assertion in Sandbox.set_work_directory() during the build, which shows up as a BUG with a traceback. A relative build-root or install-root on a build element, or a relative install root on a script element, fails the same way in mark_directory().

ScriptElement and BuildElement now check these directories in preflight(), after variables are resolved, and raise an ElementError, so bst show and bst build report the element and the path before any job starts. The sandbox assertions stay as they are.

I added tests in tests/format/variables.py and ran the format, frontend and related test modules, plus black, pylint and mypy, locally.

Fixes #2077

The sandbox only accepts absolute paths for the working directory and
for the directories it marks, and checks this with an assertion. So an
element with a relative directory, for example a script element with
`cwd: elements`, loads fine and then fails in the build job with a BUG
message and a traceback.

Check these directories in preflight() and raise an ElementError, so
that the element is reported with a normal error message when it is
loaded, before any job starts.

  o scriptelement.py: Check the working directory and the install root.

  o buildelement.py: Check the build-root and install-root variables.
    The working directory is the build root, which command-subdir is
    joined onto when it is set.

Fixes apache#2077
Check that `bst show` reports a relative working directory or install
root on a script element, and a relative build-root or install-root on
a manual element, as an element error, and that a working directory
given by a variable which resolves to an absolute path is accepted.

This is a part of apache#2077

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An unhandled exception occured, when passing bogus input to bst

1 participant