Skip to content

Commit

Permalink
Need to be in editable verbose mode to actually see the compilation e…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
lesteve committed Jul 5, 2024
1 parent 4f9ca69 commit 8d396e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion mesonpy/_editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ def _rebuild(self) -> Node:
build_command = ' '.join(self._build_cmd)
raise ImportError(

Check warning on line 347 in mesonpy/_editable.py

View check run for this annotation

Codecov / codecov/patch

mesonpy/_editable.py#L345-L347

Added lines #L345 - L347 were not covered by tests
f'Error in meson-python when building {self._name}: {build_command}\n'
'See above for more details'
'See above for more details (make sure to be in verbose editable mode, '
'for example by setting MESONPY_EDITABLE_VERBOSE=1)'
) from exc


Expand Down
9 changes: 6 additions & 3 deletions tests/test_editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,10 @@ def test_editable_verbose(venv, package_complex, editable_complex, monkeypatch):
assert venv.python('-c', 'import complex') == ''


def test_editable_importerror_on_rebuild_error(venv, package_complex, editable_complex):
def test_editable_importerror_on_rebuild_error(venv, package_complex, editable_complex, monkeypatch):
# Compilation error in in stdout of compiling command only if we are in
# verbose meson editable mode
monkeypatch.setenv('MESONPY_EDITABLE_VERBOSE', '1')
try:
venv.pip('install', os.fspath(editable_complex))
venv.python('-c', 'import complex')
Expand All @@ -320,10 +323,10 @@ def test_editable_importerror_on_rebuild_error(venv, package_complex, editable_c

process = subprocess.run([venv.executable, '-c', 'import complex'], capture_output=True)
assert process.returncode == 1
stdout = process.stdout.decode()
stderr = process.stderr.decode()
assert 'ImportError' in stderr
# TODO Why is the original error not in the stderr???
# assert "compilation_error_here" in stderr
assert 'compilation_error_here' in stdout

# Restore original content and import again, to make sure that the
# workflow of "keep importing until the compilation error is fixed""
Expand Down

0 comments on commit 8d396e6

Please sign in to comment.