Skip to content

Commit e601e7c

Browse files
Improve error created when Kind or other dependencies are not install… (DataDog#21402)
* Improve error created when Kind or other dependencies are not installed when running ddev test * Fix read_text signature for Python 3.12 mypy compatibility * Fix read_text signature for Python 3.12 mypy compatibility & Improve error created when Kind or other dependencies are not install * Modifying error message formating * Fix message formatting to a single line * Fix read_text signature to match Python’s definition - add newline parameter * Revert read_text default encoding to UTF-8
1 parent 2bf4d3c commit e601e7c

4 files changed

Lines changed: 11 additions & 5 deletions

File tree

ddev/changelog.d/21402.added

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve error message when Kind or other dependencies are missing; fix read_text signature for Python 3.12 mypy compatibility

ddev/src/ddev/cli/env/start.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ def start(
126126
app.abort(code=process.returncode)
127127

128128
if not result_file.is_file(): # no cov
129-
app.abort(f'No E2E result file found: {result_file}')
129+
errors = process.stderr
130+
app.abort(f'No E2E result file found: {result_file}, Errors: {errors}')
130131

131132
result = json.loads(result_file.read_text())
132133

ddev/src/ddev/utils/fs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def resolve(self, strict=False) -> Path:
4444
# https://bugs.python.org/issue38671
4545
return Path(os.path.realpath(self))
4646

47-
def read_text(self, encoding='utf-8', errors=None) -> str:
47+
def read_text(self, encoding='utf-8', errors=None, newline=None) -> str:
4848
return super().read_text(encoding, errors)
4949

5050
def write_text(self, *args, **kwargs) -> int:

ddev/tests/cli/env/test_start.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,28 @@ def free_port(mocker):
2323
class TestValidations:
2424
def test_no_result_file(self, ddev, helpers, mocker):
2525
result_file = Path()
26+
mock_process = None
2627

2728
def _save_result_file(*args, **kwargs):
28-
nonlocal result_file
29+
nonlocal result_file, mock_process
2930
result_file = Path(os.environ[E2EEnvVars.RESULT_FILE])
30-
return mocker.MagicMock(returncode=0)
31+
mock_process = mocker.MagicMock(returncode=0)
32+
mock_process.stderr = "Kind not installed, please install to run the 'test' command"
33+
return mock_process
3134

3235
mocker.patch('subprocess.run', side_effect=_save_result_file)
3336

3437
integration = 'postgres'
3538
environment = 'py3.12'
3639

3740
result = ddev('env', 'start', integration, environment)
41+
errors = mock_process.stderr
3842

3943
assert result.exit_code == 1, result.output
4044
assert result.output == helpers.dedent(
4145
f"""
4246
─────────────────────────────── Starting: py3.12 ───────────────────────────────
43-
No E2E result file found: {result_file}
47+
No E2E result file found: {result_file}, Errors: {errors}
4448
"""
4549
)
4650

0 commit comments

Comments
 (0)