Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions scripts/pylib/twister/twisterlib/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import zephyr_module
from twisterlib.constants import SUPPORTED_SIMS
from twisterlib.coverage import supported_coverage_formats
from twisterlib.error import TwisterRuntimeError
from twisterlib.log_helper import log_command

logger = logging.getLogger('twister')
Expand Down Expand Up @@ -1192,11 +1191,8 @@ def get_toolchain(self):
toolchain_script = Path(ZEPHYR_BASE) / Path('cmake/verify-toolchain.cmake')
result = self.run_cmake_script([toolchain_script, "FORMAT=json"])

try:
if result['returncode']:
raise TwisterRuntimeError(f"E: {result['returnmsg']}")
except Exception as e:
print(str(e))
if result['returncode'] != 0:
print(f"E: {result['returnmsg']}")
sys.exit(2)
self.toolchain = json.loads(result['stdout'])['ZEPHYR_TOOLCHAIN_VARIANT']
logger.info(f"Using '{self.toolchain}' toolchain.")
11 changes: 5 additions & 6 deletions scripts/tests/twister/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
Tests for environment.py classes' methods
"""

from unittest import mock
import os
import pytest
import shutil

from contextlib import nullcontext
from unittest import mock

import twisterlib.environment
import pytest

import twisterlib.environment

TESTDATA_1 = [
(
Expand Down Expand Up @@ -538,7 +537,7 @@ def mock_popen(command, *args, **kwargs):
'Using \'dummy toolchain\' toolchain.'
),
(
{'returncode': 1},
{'returncode': 1, "returnmsg": "something went wrong"},
2,
None
),
Expand Down Expand Up @@ -572,7 +571,7 @@ def mocked_abspath(path):
twisterlib.environment.TwisterEnv,
'run_cmake_script',
mock.Mock(return_value=script_result)), \
pytest.raises(SystemExit) \
pytest.raises(SystemExit, match='2') \
if exit_value is not None else nullcontext() as exit_info:
twister_env.get_toolchain()

Expand Down
Loading