Skip to content

Commit 3148d10

Browse files
committed
Adding the ability for tests to report they aren't supported on a target
1 parent fb39286 commit 3148d10

File tree

6 files changed

+45
-15
lines changed

6 files changed

+45
-15
lines changed

workspace_tools/build_api.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from os.path import join, exists, basename
2626
from time import time
2727

28-
from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext
28+
from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext, NotSupportedException
2929
from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON
3030
from workspace_tools.targets import TARGET_NAMES, TARGET_MAP
3131
from workspace_tools.libraries import Library
@@ -139,13 +139,13 @@ def build_project(src_path, build_path, target, toolchain_name,
139139
resources.inc_dirs.extend(inc_dirs)
140140
else:
141141
resources.inc_dirs.append(inc_dirs)
142-
143142
# Compile Sources
144143
for path in src_paths:
145144
src = toolchain.scan_resources(path)
146145
objects = toolchain.compile_sources(src, build_path, resources.inc_dirs)
147146
resources.objects.extend(objects)
148147

148+
149149
# Link Program
150150
res, needed_update = toolchain.link_program(resources, build_path, name)
151151

@@ -162,7 +162,12 @@ def build_project(src_path, build_path, target, toolchain_name,
162162
except Exception, e:
163163
if report != None:
164164
end = time()
165-
cur_result["result"] = "FAIL"
165+
166+
if isinstance(e, NotSupportedException):
167+
cur_result["result"] = "NOT_SUPPORTED"
168+
else:
169+
cur_result["result"] = "FAIL"
170+
166171
cur_result["elapsed_time"] = end - start
167172

168173
toolchain_output = toolchain.get_output()

workspace_tools/test_api.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
from workspace_tools.paths import BUILD_DIR
4545
from workspace_tools.paths import HOST_TESTS
4646
from workspace_tools.utils import ToolException
47+
from workspace_tools.utils import NotSupportedException
4748
from workspace_tools.utils import construct_enum
4849
from workspace_tools.targets import TARGET_MAP
4950
from workspace_tools.test_db import BaseDBAccess
@@ -130,6 +131,7 @@ class SingleTestRunner(object):
130131
TEST_RESULT_NO_IMAGE = "NO_IMAGE"
131132
TEST_RESULT_MBED_ASSERT = "MBED_ASSERT"
132133
TEST_RESULT_BUILD_FAILED = "BUILD_FAILED"
134+
TEST_RESULT_NOT_SUPPORTED = "NOT_SUPPORTED"
133135

134136
GLOBAL_LOOPS_COUNT = 1 # How many times each test should be repeated
135137
TEST_LOOPS_LIST = [] # We redefine no.of loops per test_id
@@ -149,7 +151,8 @@ class SingleTestRunner(object):
149151
"no_image" : TEST_RESULT_NO_IMAGE,
150152
"end" : TEST_RESULT_UNDEF,
151153
"mbed_assert" : TEST_RESULT_MBED_ASSERT,
152-
"build_failed" : TEST_RESULT_BUILD_FAILED
154+
"build_failed" : TEST_RESULT_BUILD_FAILED,
155+
"not_supproted" : TEST_RESULT_NOT_SUPPORTED
153156
}
154157

155158
def __init__(self,
@@ -476,27 +479,37 @@ def execute_thread_slice(self, q, target, toolchains, clean, test_ids, build_rep
476479
project_id=test_id,
477480
project_description=test.get_description())
478481

479-
except ToolException:
482+
except Exception, e:
480483
project_name_str = project_name if project_name is not None else test_id
481-
print self.logger.log_line(self.logger.LogType.ERROR, 'There were errors while building project %s'% (project_name_str))
484+
485+
486+
test_result = self.TEST_RESULT_FAIL
487+
488+
if isinstance(e, ToolException):
489+
print self.logger.log_line(self.logger.LogType.ERROR, 'There were errors while building project %s'% (project_name_str))
490+
test_result = self.TEST_RESULT_BUILD_FAILED
491+
elif isinstance(e, NotSupportedException):
492+
print self.logger.log_line(self.logger.LogType.INFO, 'The project %s is not supported'% (project_name_str))
493+
test_result = self.TEST_RESULT_NOT_SUPPORTED
494+
482495

483496
# Append test results to global test summary
484497
self.test_summary.append(
485-
(self.TEST_RESULT_BUILD_FAILED, target, toolchain, test_id, 'Toolchain build failed', 0, 0, '-')
498+
(test_result, target, toolchain, test_id, test.get_description(), 0, 0, '-')
486499
)
487500

488501
# Add detailed test result to test summary structure
489502
if test_id not in self.test_summary_ext[target][toolchain]:
490503
self.test_summary_ext[target][toolchain][test_id] = []
491504

492505
self.test_summary_ext[target][toolchain][test_id].append({ 0: {
493-
'result' : self.TEST_RESULT_BUILD_FAILED,
506+
'result' : test_result,
494507
'output' : '',
495508
'target_name' : target,
496509
'target_name_unique': target,
497510
'toolchain_name' : toolchain,
498511
'id' : test_id,
499-
'description' : 'Toolchain build failed',
512+
'description' : test.get_description(),
500513
'elapsed_time' : 0,
501514
'duration' : 0,
502515
'copy_method' : None
@@ -736,7 +749,8 @@ def generate_test_summary(self, test_summary, shuffle_seed=None):
736749
self.TEST_RESULT_NO_IMAGE : 0,
737750
self.TEST_RESULT_TIMEOUT : 0,
738751
self.TEST_RESULT_MBED_ASSERT : 0,
739-
self.TEST_RESULT_BUILD_FAILED : 0
752+
self.TEST_RESULT_BUILD_FAILED : 0,
753+
self.TEST_RESULT_NOT_SUPPORTED : 0
740754
}
741755

742756
for test in test_summary:

workspace_tools/test_exporters.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def exporter_junit_ioper(self, test_result_ext, test_suite_properties=None):
238238
tc.add_failure_info(description, _stdout)
239239
elif result == 'ERROR':
240240
tc.add_error_info(description, _stdout)
241-
elif result == 'SKIP':
241+
elif result == 'SKIP' or result == 'NOT_SUPPORTED':
242242
tc.add_skipped_info(description, _stdout)
243243

244244
test_cases.append(tc)
@@ -282,7 +282,7 @@ def exporter_junit(self, test_result_ext, test_suite_properties=None):
282282
message = test_result['result']
283283
if test_result['result'] == 'FAIL':
284284
tc.add_failure_info(message, _stdout)
285-
elif test_result['result'] == 'SKIP':
285+
elif test_result['result'] == 'SKIP' or test_result["result"] == 'NOT_SUPPORTED':
286286
tc.add_skipped_info(message, _stdout)
287287
elif test_result['result'] != 'OK':
288288
tc.add_error_info(message, _stdout)
@@ -319,7 +319,7 @@ def exporter_print(self, test_result_ext):
319319

320320
if test_run["result"] == "FAIL":
321321
failures.append(test_run)
322-
elif test_run["result"] == "SKIP":
322+
elif test_run["result"] == "SKIP" or test_run["result"] == "NOT_SUPPORTED":
323323
skips.append(test_run)
324324
elif test_run["result"] == "OK":
325325
successes.append(test_run)

workspace_tools/toolchains/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from inspect import getmro
2727

2828
from multiprocessing import Pool, cpu_count
29-
from workspace_tools.utils import run_cmd, mkdir, rel_path, ToolException, split_path
29+
from workspace_tools.utils import run_cmd, mkdir, rel_path, ToolException, NotSupportedException, split_path
3030
from workspace_tools.settings import BUILD_OPTIONS, MBED_ORG_USER
3131
import workspace_tools.hooks as hooks
3232

@@ -604,6 +604,9 @@ def compile_command(self, source, object, includes):
604604

605605
return None
606606

607+
def is_not_supported_error(self, output):
608+
return "#error directive: [NOT_SUPPORTED]" in output
609+
607610
def compile_output(self, output=[]):
608611
_rc = output[0]
609612
_stderr = output[1]
@@ -621,7 +624,10 @@ def compile_output(self, output=[]):
621624
for line in _stderr.splitlines():
622625
self.tool_error(line)
623626

624-
raise ToolException(_stderr)
627+
if self.is_not_supported_error(_stderr):
628+
raise NotSupportedException(_stderr)
629+
else:
630+
raise ToolException(_stderr)
625631

626632
def compile(self, cc, source, object, includes):
627633
_, ext = splitext(source)

workspace_tools/toolchains/gcc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ def parse_dependencies(self, dep_path):
118118
dependencies = dependencies + [f.replace('\a', ' ') for f in file.split(" ")]
119119
return dependencies
120120

121+
def is_not_supported_error(self, output):
122+
return "error: #error [NOT_SUPPORTED]" in output
123+
121124
def parse_output(self, output):
122125
# The warning/error notification is multiline
123126
WHERE, WHAT = 0, 1

workspace_tools/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ def rel_path(path, base, dot=False):
123123
class ToolException(Exception):
124124
pass
125125

126+
class NotSupportedException(Exception):
127+
pass
126128

127129
def split_path(path):
128130
base, file = split(path)

0 commit comments

Comments
 (0)